2009-03-02 16 views
5

Je reçois une erreur lorsque j'essaie d'utiliser le client de test WCF avec mon service WCF. Voici le code de service:Erreur du client de test WCF: Impossible d'appeler le service

[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> 

Je suis en mesure de se connecter au service à l'aide du test WCF client, mais lorsque je tente d'invoquer GetEmployee (employeeNumber) Je reçois l'erreur suivante:

Impossible de invoquez le service. Causes possibles: Le service est hors ligne ou inaccessible; la configuration côté client ne correspond pas au proxy; le proxy existant est invalide. Reportez-vous à la trace de la pile pour plus de détails. Vous pouvez essayer de récupérer en démarrant un nouveau proxy, en restaurant la configuration par défaut ou en actualisant le service.

J'ai réussi à appeler ce service en envoyant une requête au navigateur.

Une idée de pourquoi je ne peux pas utiliser le client de test WCF?

Répondre

11

Veuillez ignorer ma réponse précédente. Je ne pense pas que le problème réside dans la configuration côté client.

Voir WCF Test Client and WebHttpBinding.

This is a limitation of the web programming model itself. Unlike SOAP endpoints (i.e., those with BasicHttpBinding, WSHttpBinding, etc) which have a way to expose metadata about itself (WSDL or Mex) with information about all the operations/ parameters in the endpoint, there's currently no standard way to expose metadata for a non-SOAP endpoint - and that's exactly what the webHttpBinding-based endpoints are. In short, the WCF Test Client won't be useful for web-based endpoints. If some standard for representing web-style endpoints emerges when WCF ships its next version, we'll likely update the test client to support it, but for now there's none widely adopted.

+0

@ stimpy77, j'ai simplement cité la réponse liée par un employé MS. Dans WCF, la liaison est appelée [WebHttpBinding] (http://msdn.microsoft.com/en-us/library/system.servicemodel.webhttpbinding.aspx) et en WSDL 2, elle s'appelle [HTTP Binding] (http://www.w3.org/TR/wsdl20-adjuncts/#http-binding), mais il est assez clair du contexte ce que "web-based" signifie ici. Le terme REST va bien au-delà de l'exposition des méthodes via HTTP. Il s'agit de traiter les choses comme des ressources et d'utiliser des verbes HTTP, etc. Voir [Richardson Maturity Model] (http://martinfowler.com/articles/richardsonMaturityModel.html). –

0

Je pense que votre config ne va pas, vous devez ajouter le mode de sécurité noeud = "Aucun" et attribuer bindingConfiguration = "NoneSecurity"

Modifier comme ma config, essayez à nouveau:

<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> 
0
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. 

le chemin dans mon cas:

/opt/infamdm/hub/server/resources/cmxserver.properties 
    /opt/infamdm/hub/cleanse/resources/cmxcleanse.properties