Hi Everyone,
We are migrating from PB 12.5.2 build 5629 to Appeon 2021. After code migration, we are trying to consume WCF Service using HTTPClient because the existing SOAP Connection and Create Instance approach is obsolete on latest Appeon 2021. During .NET service consumption we are facing response error of 400 bad request. Can anyone help us to resolve this issue or provide a alternate solution to consume .NET service. Source code has been place below for you reference.
Suggest the change that need to be incorporate
httpClient lo_client
integer li_ret , i , li_StatusCode
String lo_xml_request
string ls_url,ls_return,ls_soap_action
string ls_data
string ls_body
string ls_ret
lo_client = Create httpClient
ls_url="http://cms7017:49161/WKFLoginManager.svc?wsdl"
ls_soap_action ="http://tempuri.org/ILoginManager/LoginUser"
lo_client.SetRequestHeader("soapAction", ls_soap_action)
lo_client.SetRequestHeader("Content-Type", "application/soap+xml; charset=utf-8")
ls_body="username=ib2&password=a1!&moduleid=cms&clientmachine=cms&request_dte=2022-11-04 10:13:00.193"
lo_client.sendrequest("POST",ls_url,ls_body)
li_StatusCode = lo_client.GetResponseStatusCode()
ls_ret = lo_client.GetResponseStatusText( )
li_ret = lo_client.getresponsebody(ls_data)
destroy lo_client
Yes currently we are using Postman IDE for service response checking but we are unable to find exact setting/headers for it and application/x-www-form-urlencoded not working in our case. It shows error we try this header type for our service. For your reference we attached the error screen shot. Please look into it if you can help us further in this regard. Thank you.
Error Description:
(415) cannot process the message with pplication/x-www-form-urlencoded because the content type was not expected as 'application/soap+xml; charset=utf-8'
Nabeel
ls_url="http://cms7017:49161/WKFLoginManager.svc
Have you got your existing (PB12.5) working code that you can share?
If it was me and I didn't have any documentation but I had working code, I would use Fiddler, Wireshark, SoapUI or something similar to trace all the http traffic from the working solution so I could see exactly what the working solution is sending and receiving from the webservice and then replicate that in Postman and then Powerbuilder using httpclient.