1

I am trying to access the sap soap API from .NET but get an error 'Unrecognized message version.' my code

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();
Saeed Zhiany
  • 2,051
  • 9
  • 30
  • 41
rahoof
  • 85
  • 1
  • 7
  • Using **.NET Core 5.0** and getting the same error. Strangely this is actually working on my local environment with the link `http://Dev:8088/mockZWS_WSDL`. The problem comes when i try to use a production link `http://192.168.0.20:8000/sap/wsdl/bndg_0/wsdl11/doc?sap-client=10` [This answer](https://stackoverflow.com/a/58825875/10278470) suggested removing the `?wsdl` extension but my link does not have that. [This one](https://stackoverflow.com/a/4168416/10278470) suggested that I `set bindings` but i believe in **.Net core** that has to be done in `appsettings.json` and have no idea how. – Towernter Jul 07 '22 at 09:00

1 Answers1

0

It looks like you are using the wsdl link instead of the wsdl endpoint. I faced the same issue working with a SAP wsdl file. . In my case i noticed i was using the wsdl url instead of the wsdl endpoint

My wsdl url is like: http://192.168.0.11:8088/sap/bc/srt/wsdl/bndg_WBTSRN34RT681000000C0A8010A/wsdl11/allinone/ws_policy/document?sap-client=200

All i needed was to use the wsdl endpoint insted of the wsdl url. To find the wsdl endpoint open the wsdl file and check the address location under the wsdl:service tag

  <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>
Towernter
  • 210
  • 2
  • 10