User Rating: 5 / 5

Star ActiveStar ActiveStar ActiveStar ActiveStar Active

Since PowerBuilder 2017 R2, we have a new HTTPClient object, which is a base object for sending HTTP requests and receiving HTTP responses from a resource identified by a URI. Compared to the Inet object, the HTTPClient object is easier to use and supports more methods (Get/Post/Put/Delete) and more SSL protocols (TLS 1.0, TLS 1.1, TLS 1.2, SSL 2.0, and SSL 3.0).

Among other things, the HTTPClient can be also used to consume SOAP Web services. This is particularly useful as the Web Service Proxy has many limitations and defects calling SOAP Web services such as not supporting TLS 1.2. This article is to show how you can use the new HTTPClient to call your existing SOAP Web services instead. 

Call SOAP Web services using Web Service Proxy

As a background story, let's revisit how PB consumes a SOAP Web service in the past. Firstly, you need to create a Web Service Proxy and then associate it with the pbsoapclient170.pbd or import pbsoapclient170.pbx.

Then in PB IDE, you instantiate the PB proxy with the SOAP Web service link and use the SOAPConnection object to call the associated Web service methods. 

Here is the sample code:

SoapConnection conn // Define SoapConnection

n_webservicesoap proxy_obj // Declare the proxy

long rVal

integer li_rtn

string str_endpoint

str_endpoint = "http://localhost/invoice/n_webservice.asmx?WSDL"

conn = create SoapConnection  //Instantiate connection

rVal = Conn.CreateInstance(proxy_obj, "n_webservicesoap", str_endpoint)

// Create proxy object


  li_rtn = proxy_obj.of_add(2)     //invoke Web service of_add method.

catch(SoapException e)

   messagebox("Error", "Cannot invoke Web service")

   // Error handling  

end try

destroy conn

Call SOAP Web services using HTTPClient

With the new HTTPClient object, we have a better option to call SOAP Web service.

1. Find the Correct SOAP Web service parameters

Open the SOAP Web service on IE as shown below. Copy the associated SOAP sample request. Refer to the highlighted content below. (If you don’t see this content, please contact your service provider to get such a sample request.)


Use a third party tool like Postman to verify what protocol and arguments you need to use to successfully call the Web service API.

Note: You need to replace the argument in the XML you copied in the previous step with the real argument to call the API. In this sample, we replace the word short (data type of the parameter ai_test for the of_add method) with the real argument(2).

2. Use the HTTPClient object to call the API.

After you verified successfully with Postman, apply the same protocol and arguments to HTTPClient object in your PB code. 

Here is the sample code:

httpClient lo_client

integer li_ret , i , li_StatusCode

String lo_xml_request

string ls_url

string ls_data

string ls_body

string ls_ret


ls_url ="http://localhost/invoice/n_webservice.asmx"

ls_body = ''+&


'xmlns:xsd="" xmlns:soap="">'+&

'  '+&

'    '+&

'      2'+&

'    '+&

'  '+&



lo_client = Create httpClient

lo_client.SetRequestHeader("Content-Type", "text/xml")



li_StatusCode = lo_client.GetResponseStatusCode()

ls_ret = lo_client.GetResponseStatusText( )

li_ret = lo_client.getresponsebody(  ls_data)

destroy lo_clien

The new approach for calling SOAP Web services is clean and simple, and it gives you more flexibility than the previous approach. We hope that you will find this article useful in your implementation of the consumption of SOAP Web services in your applications. 


Comments (8)

  1. Miguel Leeuwe

Hi Tom,

Thank you for sharing this knowledge but I have some questions:

Could you please explain how to "Use a third party tool like Postman to verify what protocol and arguments you need to use to successfully call the Web service API."?
I've downloaded PostMan but I don't see what to do with it to "get the protocol and arguments". Then I neither see where to put the "protol" once I would have gotten it.

Also: Is this faster then using the traditional way with Soap? Sorry for my ignorance and thank you.

  Comment was last edited about 1 month ago by Miguel Leeuwe Miguel Leeuwe
  1. Tom Jiang    Miguel Leeuwe

Hi Miguel,

We mentioned Postman mainly for you to test and verify if you can directly call the API from your service provider successfully on your machine.

It would also help you to understand how to set up the parameters for HTTPClient. If your service provider has already provided you a complete API documentation, you can ignore this part.

Regrading how to use Postman, we suggest that you do a Google search or refer to the tutorial on Postman’s official site.

BTW, HTTPClient object is for sure much better than the traditional way with SOAP both in terms of flexibility and efficiency. You can give it a try.


Tom Jiang

  1. Miguel Leeuwe    Tom Jiang

Thank you.

  1. Sergey Khudyakov

Hi Tom

I was trying to migrate Soap client with .NET assembly from PowerBuilder 11.5 where it was running perfectly.
In PB 2017 R3 Web Service proxy was deployed succesfully, but when I call web service method, raised SoapException:
The SoapClient doesn't support .NET proxy

Are you still supporting .NET assembly for web services?


  1. Tom Jiang    Sergey Khudyakov

1. Please refer to PB help or the following link. SOAPClient is obsoleted, which means it is no longer eligible for technical support and will not be enhanced.

2. About supporting .NET assembly for web services
PB 2017 is inherited from PB 12.6. No restrictions or changes are made on this feature. In other words, if it works in PB 12.6, it should still work in PB 2017. But if you do have problem using it, we suggest that you use HTTPClient to rewrite your function.

  1. Sergey Khudyakov    Tom Jiang

Thank you for reply Tom.

Yes, I already tested new HTTPClient and even make nice visual interface to work with it.

And yes, it's good to have full control for making http request and parsing http response.

(Sometime when I was stacked with old SoapClient with complex Web Servicis, I was thinking that will be nice to have naked HttpClient and here is it ))

From the other side you may need more coding and may be use PBDOM for parsing complex response body.

  1. Topher Chen    Sergey Khudyakov

Hi Sergey,

Are you able to use HttpClient in .Net Assembly?
We are facing an issue using webservice proxy to call WebService on .Net Assembly, but there is a performance issue, it takes around 1.5 second to make a call even it is just a 'Helleworld' like program, so we want to use HttpClient which is much faster, but .Net assembly doesn't support it.

  1. Roland Smith

How do you create the web service? You can't call one until it exists.

There are no comments posted here yet