2010-11-18 12 views
13

J'ai un simple service Web fonctionnant dans Visual Studio. Si j'essaie d'afficher les métadonnées, il manque des informations sur l'opération et svcutil génère du code client sans aucune méthode. Y a-t-il un problème avec ma configuration?Opérations manquantes sur les métadonnées WCF

<system.serviceModel> 
    <bindings> 
     <basicHttpBinding> 
      <binding name="FCRPublishSOAP" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true"> 
       <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384"/> 
       <security mode="None"> 
        <transport clientCredentialType="None" proxyCredentialType="None" realm=""/> 
        <message clientCredentialType="UserName" algorithmSuite="Default"/> 
       </security> 
      </binding> 
     </basicHttpBinding> 
    </bindings> 
    <services> 
     <service name="Test.Publish.FCRPublish" behaviorConfiguration="SimpleServiceBehavior"> 
      <endpoint address="FCRPublish" behaviorConfiguration="" binding="basicHttpBinding" bindingConfiguration="FCRPublishSOAP" contract="IFCRPublish"/> 
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /> 
    </service> 
    </services> 
<behaviors> 
    <serviceBehaviors> 
    <behavior name="SimpleServiceBehavior"> 
     <serviceMetadata httpGetEnabled="True" policyVersion="Policy15" /> 
    </behavior> 
    </serviceBehaviors> 
</behaviors> 

Interface:

[System.ServiceModel.ServiceContractAttribute(Namespace="http://Test/Publish", ConfigurationName="IFCRPublish")] 
public interface IFCRPublish 
{ 

    // CODEGEN: Generating message contract since the operation PublishNotification is neither RPC nor document wrapped. 
    [System.ServiceModel.OperationContractAttribute(Action="http://Test/PublishNotification", ReplyAction="*")] 
    PublishNotificationResponse1 PublishNotification(PublishNotificationRequest1 request); 
} 

Réponse:

[System.Diagnostics.DebuggerStepThroughAttribute()] 
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")] 
[System.ServiceModel.MessageContractAttribute(IsWrapped=false)] 
public partial class PublishNotificationResponse1 
{ 

    [System.ServiceModel.MessageBodyMemberAttribute(Namespace="http://Test/PublishTypes", Order=0)] 
    public PublishNotificationResponse PublishNotificationResponse; 

    public PublishNotificationResponse1() 
    { 
    } 

    public PublishNotificationResponse1(PublishNotificationResponse PublishNotificationResponse) 
    { 
     this.PublishNotificationResponse = PublishNotificationResponse; 
    } 
} 

Demande:

[System.Diagnostics.DebuggerStepThroughAttribute()] 
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")] 
[System.ServiceModel.MessageContractAttribute(IsWrapped=false)] 
public partial class PublishNotificationRequest1 
{ 

    [System.ServiceModel.MessageBodyMemberAttribute(Namespace="http://Test/PublishTypes", Order=0)] 
    public PublishNotification PublishNotification; 

    public PublishNotificationRequest1() 
    { 
    } 

    public PublishNotificationRequest1(PublishNotification PublishNotification) 
    { 
     this.PublishNotification = PublishNotification; 
    } 
} 

Voici les métadonnées que je reçois:

<wsdl:import namespace="http://Test/Publish" location="http://localhost:3992/FCRPublish.svc?wsdl=wsdl0"/> 
<wsdl:types/> 
<wsdl:binding name="BasicHttpBinding_IFCRPublish" type="i0:IFCRPublish"> 
    <soap:binding transport="http://schemas.xmlsoap.org/soap/http"/> 
</wsdl:binding> 
<wsdl:service name="FCRPublish"> 
    <wsdl:port name="BasicHttpBinding_IFCRPublish" binding="tns:BasicHttpBinding_IFCRPublish"> 
     <soap:address location="http://localhost:3992/FCRPublish.svc"/> 
    </wsdl:port> 
</wsdl:service> 

Où est passée mon activité?

+0

Est-ce que 'PublishNotificationResponse1' a un attribut' DataContract'? –

+0

Non mais il a un attribut MessageContract. Je vais modifier le message pour inclure les objets de demande et de réponse. – haymansfield

Répondre

30

travaillé dessus. Définir ReplyAction = "*" pour un OperationContract signifie que WsdlExporter (qui publie les métadonnées) ignorera cette opération. Définir toute autre valeur le fixe. Ce qui m'énerve à propos de ceci est que svcutil positionnera par défaut replyaction à * ce qui signifie que svcutil crée par défaut des services pour lesquels les métadonnées sont effectivement rompues.

+0

Excellent travail pour trouver cela. Merci beaucoup. Je travaille aussi avec l'outil WCSF Blue pour la création de clients. – Lijo

+0

Je viens de rencontrer ça aussi ... il doit y avoir une raison pour laquelle, ça vient de gâcher un après-midi pour moi. – Jammer

0

essayez de supprimer FCRPublish à l'adresse de votre enpoint ... votre point de terminaison est là et MEX semble ok, donc je crois qu'il devrait travailler

+0

J'ai essayé cela sans succès. – haymansfield

+0

en regardant de plus près votre code, je n'ai jamais ajouté un 'MessageBodyMemberAttribute' sans un' MessageHeaderAttribute', pourriez-vous en ajouter un juste au cas où? – sebagomez