簡體   English   中英

WCF元數據缺少操作

[英]WCF metadata missing operations

我有一個在Visual Studio中運行的簡單Web服務。 如果我嘗試查看元數據,則會丟失有關操作的信息,因此svcutil會生成客戶端代碼,而無需任何方法。 我的設置有什么問題嗎?

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

我的手術去了哪里?

解決了這個問題。 為OperationContract設置ReplyAction =“*”表示WsdlExporter(發布元數據)將忽略該操作。 設置任何其他值可以修復它。

令我困擾的是,svcutil默認將replyaction設置為*,這意味着默認情況下svcutil會創建有效破壞元數據的服務。

嘗試從你的enpoint的地址刪除FCRPublish ...你的mex端點在那里似乎沒問題,所以我相信它應該工作

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM