Connection Information

To perform the requested action, WordPress needs to access your web server. Please enter your FTP credentials to proceed. If you do not remember your credentials, you should contact your web host.

Connection Type

Call SOAP Web Service using HTTPClient object – PB Docs 2022 – PowerBuilder Library

Call SOAP Web Service using HTTPClient object – PB Docs 2022

Call SOAP Web Service using HTTPClient object

Background

With PowerBuilder prior to PB 2017 R2, in order to consume a SOAP
Web service, you need to create a Web service proxy and then associate
it with 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. Due to historical reasons, there are many
limitations and defects calling SOAP Web service using this
approach.

Here is the sample code:

Call SOAP Web service using
HTTPClient

Since the introduction of HTTPClient object in PB 2017 R2, 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.)

tr_037.png

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).

tr_038.png

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.

tr_039.png

Here is the sample code:

The new approach for calling SOAP Web service is clean and simple
and it gives you more flexibility than the previous approach. 

Note: If you want to use the PBDOM Object to build the XML
content, you can refer to this
knowledge base
.

Call simple ASP.NET Web Service using
HTTPClient

1. Build a Web Service

Build a simple Web Service project based on .NET Framework, then
directly add a Web Service (ASMX) object WebService into this
project.

tr_040.png

Here below is the C# code for reference:

2. Find the correct arguments to call the WebService 

This sample Web Service has only two APIs. One is the HelloWorld
method that returns a string and the other one is the Add method that
has two int type input parameters and returns an int value.

tr_041.png

First of all, use a third party tool to verify what protocol and
arguments you need to use to call this Web Service API.

For example, we use Postman to verify it here.

tr_042.png

From the result you can see the request format of the current API
is different from the one we introduced in the previous section. The
Content-Type should be set to application/x-www-form-urlencoded instead
of application/xml.

tr_043.png

3. Use the HTTPClient object to call the Add method of this
API.

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

tr_044.png

Here below is the sample code:


Document get from Powerbuilder help
Thank you for watching.
Was this article helpful?
Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x