2010-11-18 2 views
13

У меня есть простой веб-сервис, работающий в Visual Studio. Если я попытаюсь просмотреть метаданные, у вас отсутствует информация об операции, поэтому svcutil генерирует код клиента без каких-либо методов. Что-то не так с моей настройкой?Метаданные 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> 

Интерфейс:

[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); 
} 

Ответ:

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

Запрос:

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

Это метаданные, которые я получаю:

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

Куда ушла моя операция?

+0

Имеет ли 'PublishNotificationResponse1' атрибут' DataContract'? –

+0

Нет, но он имеет атрибут MessageContract. Я отредактирую сообщение, чтобы включить объекты запроса и ответа. – haymansfield

ответ

30

Работали его. Установка ReplyAction = "*" для OperationContract означает, что WsdlExporter (который публикует метаданные) игнорирует эту операцию. Установка любого другого значения исправляет его.

Что меня беспокоит, так это то, что svcutil будет по умолчанию устанавливать ответ на *, что означает, что svcutil по умолчанию создает службы, для которых метаданные эффективно нарушены.

+0

Отличная работа по поиску этого. Благодаря тонну. Я также работаю с инструментом WCSF Blue для создания клиента. – Lijo

+0

Я тоже натолкнулся на это ... должна быть причина, почему это просто потратило день на меня. – Jammer

0

попробуйте удалить FCRPublish из адреса вашего enpoint ... ваш MEX конечной точки есть и, кажется, хорошо, так что я считаю, что это должно работать

+0

Я пробовал это без везения. – haymansfield

+0

более пристально смотрю на ваш код, я никогда не добавлял 'MessageBodyMemberAttribute' без' MessageHeaderAttribute', вы могли бы добавить его на всякий случай? – sebagomez

Смежные вопросы