【问题标题】:When I try to access data from SAP in .NET I get an error 'Unrecognized message version.'当我尝试从 .NET 中的 SAP 访问数据时,我收到错误消息“无法识别的消息版本”。
【发布时间】: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


【解决方案1】:

您似乎使用的是 wsdl 链接,而不是 wsdl 端点。 我在使用SAP wsdl 文件时遇到了同样的问题。 .就我而言,我注意到我使用的是 wsdl url 而不是 wsdl 端点

我的wsdl url 就像:http://192.168.0.11:8088/sap/bc/srt/wsdl/bndg_WBTSRN34RT681000000C0A8010A/wsdl11/allinone/ws_policy/document?sap-client=200

我只需要使用 wsdl url 中的 wsdl 端点。 要找到 wsdl 端点,请打开 wsdl 文件 并检查 wsdl:service 标签下的 address location

  <wsdl:service name="ZWS_FILEService">
    <wsdl:port name="ZWS_FILE" binding="tns:ZWS_FILE">
      <soap:address location="http://192.168.0.11:8088/sap/bc/srt/rfc/sap/zws_file/200/zws_file/zws_file"/>
    </wsdl:port>
  </wsdl:service>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-05-03
    • 1970-01-01
    • 2022-11-28
    • 1970-01-01
    相关资源
    最近更新 更多