WCF元数据丢失的操作 [英] WCF metadata missing operations

查看:154
本文介绍了WCF元数据丢失的操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Visual Studio中一个简单的Web服务上运行。如果我试图查看它缺少有关操作信息的元数据等SvcUtil工具生成客户端code没有任何方法。这有什么错我的设置?

I have a simple webservice running in Visual Studio. If I attempt to view the metadata it is missing information about the operation and so svcutil generates client code without any methods. Is there anything wrong with my setup?

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

在哪里我已运行了?

Where has my operation gone?

推荐答案

工作了。设置ReplyAction =*为OperationContract的指WsdlExporter(该公司出版的元数据)将忽略该操作。设置其他值修复它。

Worked it out. Setting ReplyAction="*" for an OperationContract means the WsdlExporter (which publishes the metadata) will ignore that Operation. Setting any other value fixes it.

让我困扰的这个是SvcUtil工具会默认设置replyaction为*,这意味着SvcUtil工具默认创建服务,其元数据被有效打破。

What bothers me about this is that svcutil will by default set replyaction to * which means svcutil by default creates services for which the metadata is effectively broken.

这篇关于WCF元数据丢失的操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆