1. Nabeel Aslam
  2. PowerBuilder
  3. Monday, 11 April 2022 09:50 AM UTC

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_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"
li_StatusCode = lo_client.GetResponseStatusCode()
ls_ret = lo_client.GetResponseStatusText( )
li_ret = lo_client.getresponsebody(ls_data)
destroy lo_client


Attachments (1)
Daryl Foster Accepted Answer Pending Moderation
  1. Monday, 11 April 2022 23:34 PM UTC
  2. PowerBuilder
  3. # 1

Hi Nabeel,

Have you had a look at this tech article which explains how to call a SOAP Web Service with HttpClient? https://community.appeon.com/index.php/articles-blogs/tutorials-articles/2-powerbuilder/236-call-soap-web-services-using-httpclient-object

Soap is all about passing XML messages back and forth.  One obvious issue with your code above is that you are setting a Content-Type header of "application/soap+xml", but you are actually sending plain text key value pairs (maybe it should have been "application/x-www-form-urlencoded"?).  I would suggest using Fiddler or something similar to check exactly what content and messages get passed back and forth with your current solution so you can see the actual message formats you will need to reproduce using HttpClient. Once you've got the actual message formats it would probably be good to do as Chris suggests and try to replicate it with Postman before implementing it in Powerbuilder with HttpClient.

Do you have any current documentation for the web service you are trying to call?  It may have the information required to recreate the messages.

  1. Nabeel Aslam
  2. Tuesday, 12 April 2022 10:55 AM UTC
Thanks for reply Daryl,

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'

  1. Helpful
  1. Nabeel Aslam
  2. Tuesday, 12 April 2022 10:58 AM UTC
we have already look shared article but It quite different with our service type. we are using below mentioned url for service consumption not .asmx. If you have any helping source related to this then please do share with us. Thank you

  1. Helpful
  1. Daryl Foster
  2. Wednesday, 13 April 2022 01:41 AM UTC
Hi Nabeel, have you got any documentation for the web service that you are currently using?

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.
  1. Helpful
There are no comments made yet.
Andreas Mykonios Accepted Answer Pending Moderation
  1. Monday, 11 April 2022 12:50 PM UTC
  2. PowerBuilder
  3. # 2


Are you sure that using http://tempuri.org/... still works? I don't believe it's currently doing anything.


  1. Nabeel Aslam
  2. Tuesday, 12 April 2022 10:49 AM UTC
Thanks for reply Andreas,

If you any alternate solution/help to consume .NET WCF Service and call service methods then please do share with us.


  1. Helpful
There are no comments made yet.
Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Monday, 11 April 2022 12:47 PM UTC
  2. PowerBuilder
  3. # 3

Hi Nabeel;

  Were you able to call the WCF Web service OK using POSTMAN? If so, that might give you some idea of what setting(s) you need to adjust for.

Regards ... Chris

  1. Nabeel Aslam
  2. Tuesday, 12 April 2022 11:00 AM UTC
Hi Chris,

Thanks for quick reply.

Yes we have already using postman to consume .Net WCF Service but we did not find the exact header and content-type to consume it on postman IDE. if you have any idea about setting then please do share with us. Thank you

  1. Helpful
There are no comments made yet.
  • Page :
  • 1

There are no replies made for this question yet.
However, you are not allowed to reply to this question.