Pregunta

Recibo un error al intentar usar el Cliente de prueba WCF con mi servicio WCF. Aquí está el código de servicio:

[ServiceContract]
public interface IEmployeeService
{
    [OperationContract(Name = "GetEmployee")]
    [WebGet(RequestFormat = WebMessageFormat.Xml,
        UriTemplate = "/Employees/{employeeNumber}")]
    Employee GetEmployee(string employeeNumber);
}

public Employee GetEmployee(string employeeNumber)
{
    var employeeNumberValue = Convert.ToInt32(employeeNumber);
    var employee = DataProvider.GetEmployee(employeeNumberValue);
    return employee;
}

<system.serviceModel>
    <services>
        <service name="Employees.Services.EmployeeService"
                 behaviorConfiguration="metaBehavior">
            <endpoint address=""
                      behaviorConfiguration="webHttp"
                      binding="webHttpBinding"
                      contract="Employees.Services.IEmployeeService">
            </endpoint>
            <endpoint address="mex"
                      binding="mexHttpBinding"
                      contract="IMetadataExchange">
            </endpoint>
        </service>
    </services>
    <behaviors>
        <endpointBehaviors>
            <behavior name="webHttp">
                <webHttp/>
            </behavior>
        </endpointBehaviors>
        <serviceBehaviors>
            <behavior name="metaBehavior">
                <serviceMetadata httpGetEnabled="true" />
            </behavior>
        </serviceBehaviors>
    </behaviors>
</system.serviceModel>

Puedo conectarme al servicio utilizando el Cliente de prueba WCF, pero cuando intento invocar GetEmployee (employeeNumber) aparece el siguiente error:

Error al invocar el servicio. Causas posibles: el servicio está fuera de línea o inaccesible; la configuración del lado del cliente no coincide con el proxy; El proxy existente no es válido. Consulte el seguimiento de la pila para obtener más detalles. Puede intentar recuperarse iniciando un nuevo proxy, restaurando la configuración predeterminada o actualizando el servicio.

Pude llamar con éxito a este servicio enviando una solicitud desde el navegador.

¿Alguna idea de por qué no puedo usar el WCF Test Client?

¿Fue útil?

Solución

Por favor ignora mi respuesta anterior. No creo que el problema esté en la configuración del lado del cliente.

Ver Prueba WCF Cliente y WebHttpBinding .

  

Esto es una limitación de la web   modelo de programación en sí. A diferencia del jabón   puntos finales (es decir, aquellos con   BasicHttpBinding, WSHttpBinding, etc.)   que tienen una manera de exponer metadatos   sobre sí mismo (WSDL o Mex) con   información sobre todas las operaciones /   parámetros en el punto final, hay   Actualmente no hay forma estándar de exponer   metadatos para un punto final no SOAP, y   eso es exactamente lo que el   Los puntos finales basados ??en webHttpBinding son. En   en resumen, el cliente de prueba WCF no será   útil para puntos finales basados ??en la web. Si   algún estándar para representar   los puntos finales de estilo web surgen cuando WCF   envía su próxima versión, probablemente   actualizar el cliente de prueba para admitirlo,   pero por ahora no hay ninguno   adoptado.

Otros consejos

Creo que su configuración es incorrecta, debe agregar el modo de seguridad de nodo = " Ninguno " y atributo bindingConfiguration = " NoneSecurity "

Cambiar como mi configuración, intente nuevamente:

<system.serviceModel>
    <bindings>
      <wsHttpBinding>
        <binding name="NoneSecurity"
          maxBufferPoolSize="12000000" maxReceivedMessageSize="12000000" useDefaultWebProxy="false">
          <readerQuotas maxStringContentLength="12000000" maxArrayLength="12000000"/>
          <security mode="None"/>
        </binding>
      </wsHttpBinding>
    </bindings>
    <services>
      <service behaviorConfiguration="Elong.GlobalHotel.Host.IHotelAPIBehavior"
        name="Elong.GlobalHotel.Host.IHotelAPI">
        <endpoint address="" binding="wsHttpBinding" bindingConfiguration="NoneSecurity" contract="Elong.GlobalHotel.Host.IIHotelAPI">
          <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="Elong.GlobalHotel.Host.IHotelAPIBehavior">
          <serviceMetadata httpGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="false" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>
  I had a similar problem, the solution was in a minor error in the message alias ... that very generic message ... in our case was assigned a Boolean false if the right is true.
  This value was in the MDM application that was running on websphere.

la ruta en mi caso:

   /opt/infamdm/hub/server/resources/cmxserver.properties
   /opt/infamdm/hub/cleanse/resources/cmxcleanse.properties
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top