【发布时间】:2022-07-14 16:45:18
【问题描述】:
我正在尝试从 .NET 访问 sap soap API,但收到错误 'Unrecognized message version.' 我的代码
String endpointurl = "http://link/wsdl/flv_10002A111AD1/bndg_url/sap/bc/srt/rfc/sap/zhr_emp_leave_balance_chk/410/zhr_emp_leave_balance_chk/zhr_emp_leave_balance_chk?sap-client=410";
BasicHttpBinding binding = new BasicHttpBinding();
//If you need HTTP with Basic Auth for internal network or dev environments. Otherwise remove these two lines:
binding.Security.Mode = BasicHttpSecurityMode.TransportCredentialOnly;
binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Basic;
EndpointAddress endpoint = new EndpointAddress(endpointurl);
ZHR_EMP_LEAVE_BALANCE_CHKClient wsclient = new ServiceReference1.ZHR_EMP_LEAVE_BALANCE_CHKClient(binding, endpoint);
wsclient.ClientCredentials.UserName.UserName = "user";
wsclient.ClientCredentials.UserName.Password = "password";
//Here you can use client
ServiceReference1.ZhrGetEmployeeLeaveWs re = new ZhrGetEmployeeLeaveWs();
re.IvPernr = "id";
var request = new ServiceReference1.ZhrGetEmployeeLeaveWsRequest(re);
var response = await wsclient.ZhrGetEmployeeLeaveWsAsync(re);
r = response.ZhrGetEmployeeLeaveWsResponse.EsDtls.LeaveBalance.ToString();
【问题讨论】:
-
使用 .NET Core 5.0 并得到相同的错误。奇怪的是,这实际上是在我的本地环境中使用链接
http://Dev:8088/mockZWS_WSDL工作的。当我尝试使用生产链接http://192.168.0.20:8000/sap/wsdl/bndg_0/wsdl11/doc?sap-client=10This answer 建议删除?wsdl扩展时,问题就出现了,但我的链接没有那个。 This one 建议我set bindings但我相信必须在appsettings.json中完成的 .Net core 并且不知道如何。
标签: c# .net wcf .net-core sap-pi