当前位置 : 主页 > 网页制作 > xml >

xml – 首先是WCF合同:没有公开任何方法

来源:互联网 收集:自由互联 发布时间:2021-06-13
我收到了一堆带有一堆XSD的WSDL,我正在使用这些来创建一个WCF服务.我正在使用svcutil.exe来生成服务类,一切都基本正常 – 除了服务不公开任何方法. 从svcutil生成的.cs文件包含以下接口:
我收到了一堆带有一堆XSD的WSDL,我正在使用这些来创建一个WCF服务.我正在使用svcutil.exe来生成服务类,一切都基本正常 – 除了服务不公开任何方法.

从svcutil生成的.cs文件包含以下接口:

[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
[System.ServiceModel.ServiceContractAttribute(Namespace="http://serviceplatformen.dk/xml/wsdl/soap11/DistributionService/1/port", ConfigurationName="DistributionReceiverWebServicePort")]
public interface DistributionReceiverWebServicePort
{

    [System.ServiceModel.OperationContractAttribute(Action="", ReplyAction="*")]
    [System.ServiceModel.FaultContractAttribute(typeof(serviceplatformen.dk.xml.wsdl.soap11.DistributionService._1.types.TransportkvitteringType), Action="", Name="TransportKvittering", Namespace="http://serviceplatformen.dk/xml/wsdl/soap11/DistributionService/1/types")]
    [System.ServiceModel.XmlSerializerFormatAttribute()]
    FordelingsobjektModtagResponse FordelingsobjektModtag(FordelingsobjektModtagRequest request);
}

有问题的类型如下所示:

[System.CodeDom.Compiler.GeneratedCodeAttribute("svcutil", "4.0.30319.33440")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(Namespace="http://serviceplatformen.dk/xml/wsdl/soap11/DistributionService/1/types")]
public partial class ForretningskvitteringType
{

    private ForretningsValideringsKodeType forretningsValideringsKodeField;

    private string begrundelseField;

    private FejlType[] fejlListeField;

    /// <remarks/>
    [System.Xml.Serialization.XmlElementAttribute(Order=1)]
    public string Begrundelse
    {
        get
        {
            return this.begrundelseField;
        }
        set
        {
            this.begrundelseField = value;
        }
    }

    ...
}

我注意到没有任何类型使用DataContract / DataMember属性进行修饰.这是必需的,还是由类型的其他属性覆盖?

我的服务公开的WSDL(没有任何操作)是这样的:

<?xml version="1.0" encoding="utf-8"?>
<wsdl:definitions name="FKService" targetNamespace="http://serviceplatformen.dk/xml/wsdl/soap11/DistributionService/1/port" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" xmlns:wsx="http://schemas.xmlsoap.org/ws/2004/09/mex" xmlns:wsap="http://schemas.xmlsoap.org/ws/2004/08/addressing/policy" xmlns:msc="http://schemas.microsoft.com/ws/2005/12/wsdl/contract" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns="http://serviceplatformen.dk/xml/wsdl/soap11/DistributionService/1/port" xmlns:wsa10="http://www.w3.org/2005/08/addressing" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing">
  <wsp:Policy wsu:Id="MetadataExchangeHttpBinding_DistributionReceiverWebServicePort_policy">
    <wsp:ExactlyOne>
      <wsp:All>
        <wsaw:UsingAddressing/>
      </wsp:All>
    </wsp:ExactlyOne>
  </wsp:Policy>
  <wsdl:types/>
  <wsdl:portType name="DistributionReceiverWebServicePort"/>
  <wsdl:binding name="BasicHttpBinding_DistributionReceiverWebServicePort" type="tns:DistributionReceiverWebServicePort">
    <soap:binding transport="http://schemas.xmlsoap.org/soap/http"/>
  </wsdl:binding>
  <wsdl:binding name="MetadataExchangeHttpBinding_DistributionReceiverWebServicePort" type="tns:DistributionReceiverWebServicePort">
    <wsp:PolicyReference URI="#MetadataExchangeHttpBinding_DistributionReceiverWebServicePort_policy"/>
    <soap12:binding transport="http://schemas.xmlsoap.org/soap/http"/>
  </wsdl:binding>
  <wsdl:service name="FKService">
    <wsdl:port name="BasicHttpBinding_DistributionReceiverWebServicePort" binding="tns:BasicHttpBinding_DistributionReceiverWebServicePort">
      <soap:address location="http://localhost:8082/FKService/"/>
    </wsdl:port>
    <wsdl:port name="MetadataExchangeHttpBinding_DistributionReceiverWebServicePort" binding="tns:MetadataExchangeHttpBinding_DistributionReceiverWebServicePort">
      <soap12:address location="http://localhost:8082/FKService/mex"/>
      <wsa10:EndpointReference>
        <wsa10:Address>http://localhost:8082/FKService/mex</wsa10:Address>
      </wsa10:EndpointReference>
    </wsdl:port>
  </wsdl:service>
</wsdl:definitions>

我想我错过了一些非常明显的东西,但是什么呢?

显然svcutil将ReplyAction =“*”添加到操作契约中,这会导致奇怪的行为.

删除OperationContractAttribute的此规范后,问题就消失了.

[System.ServiceModel.ServiceContractAttribute(Namespace="http://tempuri.org/xml/wsdl/soap11/DistributionService/1/port", ConfigurationName="DistributionReceiverWebServicePort")]
public interface DistributionReceiverWebServicePort
{
    [System.ServiceModel.OperationContractAttribute(Action="")]
    [System.ServiceModel.FaultContractAttribute(typeof(TransportkvitteringType), Action="", Name="TransportKvittering", Namespace="http://tempuri.org/xml/wsdl/soap11/DistributionService/1/types")]
    [System.ServiceModel.XmlSerializerFormatAttribute()]
    FordelingsobjektModtagResponse FordelingsobjektModtag(FordelingsobjektModtagRequest request);
}

也可以看看

https://shishkin.wordpress.com/2007/03/21/wcf-actions-asterisk-and-metadata/

https://social.msdn.microsoft.com/Forums/vstudio/en-US/41f5fe72-3ab3-4741-867e-a93119fe62aa/svcutil-generates-replyaction

网友评论