Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/ssh/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# webservice c中的重载方法#_C#_.net_Web Services_Soap_Overloading - Fatal编程技术网

C# webservice c中的重载方法#

C# webservice c中的重载方法#,c#,.net,web-services,soap,overloading,C#,.net,Web Services,Soap,Overloading,我在一个Web服务中重载了如下方法: [SoapHeader("Authentication")] [WebMethod(MessageName = "DeferringTransaction", Description = "Deferring Transaction")] public WsResponse SendTransaction(WsDeferringTransaction wsDeferringTransaction) { factory.

我在一个Web服务中重载了如下方法:

[SoapHeader("Authentication")]
    [WebMethod(MessageName = "DeferringTransaction", Description = "Deferring Transaction")]
    public WsResponse SendTransaction(WsDeferringTransaction wsDeferringTransaction)
    {
        factory.LoadSettings();
        WsResponse response = new WsResponse();
        response.ErrorCode = "Test";
        response.ReturnCode = 1;
        return response;
    }
    [SoapHeader("Authentication")]
    [WebMethod(MessageName = "ProcessedTransaction", Description = "Processed Transaction")]

    public WsResponse SendTransaction(WsProcessedTransaction wsProcessedTransaction)
    {
        factory.LoadSettings();
        WsResponse response = new WsResponse();
        response.ErrorCode = "Test";
        response.ReturnCode = 1;
        return response;
    }
但是,当我尝试使用此Web服务时,SendTransaction方法会显示另一个名称:SendTransaction和SendTransaction1

 ServiceReference1.WsDeferringTransaction wsDeferringTransaction = new ServiceReference1.WsDeferringTransaction()
        {
            CaptiveId = 1,
            TransactionDeferringId = 2
        };

        ServiceReference1.WsResponse r = ws.SendTransaction(u, wsDeferringTransaction);

        ServiceReference1.WsProcessedTransaction wsProcessedTransaction = new ServiceReference1.WsProcessedTransaction()
        {
            DocumentNumber = 4,
            TransactionSequenceNumber = 450
        };

        ServiceReference1.WsResponse r2 = ws.SendTransaction1(u,wsProcessedTransaction);
是否可以创建重载方法并使用相同的名称使用它?问题是否可能是因为SoapHeader?顺便说一下,我已经使用WsiProfiles进行了webServiceBinding。无:

   [WebServiceBinding(ConformsTo = WsiProfiles.None)]

如果您使用的是SOAP,则导出的WSDL中,方法名称必须具有唯一的名称

根据您使用的技术,有不同的方法指定方法名称。例如,在WCF中,可以使用[OperationContract]属性指定名称

else方法重载很容易在web服务类中实现。请按照链接查看:-


如果您使用的是SOAP,则导出的WSDL中的方法名称必须具有唯一的名称

根据您使用的技术,有不同的方法指定方法名称。例如,在WCF中,可以使用[OperationContract]属性指定名称

else方法重载很容易在web服务类中实现。请按照链接查看:-