【发布时间】:2017-02-03 09:52:00
【问题描述】:
我在一个 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.None 的 webServiceBinding:
[WebServiceBinding(ConformsTo = WsiProfiles.None)]
【问题讨论】:
标签: c# .net web-services soap overloading