WCF服务-从WSDL开发合同

时间:2018-10-16 16:32:31

标签: c# web-services wcf soap wsdl

我需要基于wsdl文件开发WCF Web服务。 首先,我使用了wsdl.exe工具来创建服务器接口以用作WCF服务项目中的合同。

然后,我创建了一个测试客户端项目来调用服务方法,并使用Visual Studio“添加服务引用”工具。 一切正常!

但是,当从另一个“非WCF”客户端调用服务方法时,服务器将无法工作。 我已经注意到,我的SOAP请求与其他客户端请求不同。

这是我的

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
    <NotificaScarto xmlns="http://www.fatturapa.gov.it/sdi/ws/trasmissione/v1.0">
        <notificaScarto xmlns:a="http://www.fatturapa.gov.it/sdi/ws/trasmissione/v1.0/types" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
            <a:File>[long base64 string]</a:File>
            <a:IdentificativoSdI>test</a:IdentificativoSdI>
            <a:NomeFile>TEST</a:NomeFile>
        </notificaScarto>
    </NotificaScarto>
</s:Body>

这是另一个客户端的SOAP请求

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header>
    <WSCorIDSOAPHeader xmlns="http://www.wilytech.com/" CorID="[long base64 string]"></WSCorIDSOAPHeader>
</soapenv:Header>
<soapenv:Body>
    <ns2:notificaScarto xmlns:ns2="http://www.fatturapa.gov.it/sdi/ws/trasmissione/v1.0/types">
        <IdentificativoSdI>2103279</IdentificativoSdI>
        <NomeFile>IT03468570928_18501_NS_002.xml</NomeFile>
        <File>[long base64 string]</File>
    </ns2:notificaScarto>
</soapenv:Body>

wsdl.exe工具生成的合同是

[ServiceContract]
public interface ITrasmissioneFatture
{
    [OperationContract]
    void NotificaScarto(
        //[System.Xml.Serialization.XmlElementAttribute(Namespace = "http://www.fatturapa.gov.it/sdi/ws/trasmissione/v1.0/types")]
    fileSdI_Type notificaScarto);
}

然后我的服务实现类是

[System.Web.Services.Protocols.SoapDocumentService(
        Use = System.Web.Services.Description.SoapBindingUse.Default,
        ParameterStyle = System.Web.Services.Protocols.SoapParameterStyle.Bare,
    RoutingStyle = System.Web.Services.Protocols.SoapServiceRoutingStyle.RequestElement)]
public class TrasmissioneFatture : ITrasmissioneFatture
{
    public void NotificaScarto(/*[XmlElement("", Namespace = "http://www.fatturapa.gov.it/sdi/ws/trasmissione/v1.0/types")]*/ fileSdI_Type notificaScarto)
    {
        if(this.IsTest)
            return;

        //throw new NotImplementedException();
    }
}

我必须在课堂上进行哪些类型的更改才能使其也适用于“非WCF客户端”?

0 个答案:

没有答案
相关问题