1. jean-louis cantin
  2. PowerBuilder
  3. Thursday, 28 November 2019 11:06 AM UTC

Hello,
I use Appeon PowerBuilder 2019.
Does anyone have an example of simple use of Web Services with this tool?

I tried the following example:
Call SOAP Web Services Using HTTPClient Object
But that doesn't work for me.

Thank you very much.

Armeen Mazda @Appeon Accepted Answer Pending Moderation
  1. Thursday, 28 November 2019 15:05 PM UTC
  2. PowerBuilder
  3. # 1

Hi Jean-Louis, 

We need more info to try to help you.

Did you create the Web service in PowerBuilder or is it created by somebody else using different tool?

What type of web service it is and what format is the data?  REST/JSON?  SOAP/XML?

How did you write your code in PowerScript for HTTPClient object?

What error code are you getting?

Regards,
Armeen

Comment
There are no comments made yet.
jean-louis cantin Accepted Answer Pending Moderation
  1. Monday, 2 December 2019 09:20 AM UTC
  2. PowerBuilder
  3. # 2

Hello Armeen,
I have to use WebServices developed by someone else in Windev.
The format used is SOAP/XML
Here is the example code I got from the site for a test and it doesn't work :

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 = '<?xml version="1.0" encoding="utf-8"?>'+&
'<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" '+&
'xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">'+&
' <soap:Body>'+&
' <of_add xmlns="http://tempurl.org">'+&
' <ai_test>2</ai_test>'+&
' </of_add>'+&
' </soap:Body>'+&
'</soap:Envelope>'

lo_client = Create httpClient
lo_client.SetRequestHeader("Content-Type", "text/xml")
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

Thanks a lot

Regards,

Jean-Louis

Comment
  1. Mark Lee @Appeon
  2. Tuesday, 3 December 2019 03:25 AM UTC
Hi Jean,

This code example shows you how to use HttpClient object.

If you want to test it, you need to create a local SOAP server. That means, you need to make sure the link http://localhost/invoice/n_webservice.asmx works in your dev machine first.

You can find how to create .NET Web Service Targets in the local PB help documentation.

But this tech is obsolete, if you want to create Web Services, PowerBuilder 2019 supports doing so using DataWindow technology, C# programming language, and REST standard. Here are some tutorials: https://docs.appeon.com/appeon_online_help/snapdevelop2019/Create_a_Web_API/index.html and https://docs.appeon.com/appeon_online_help/powerbuilder/CRUD_Operations_with_.NET_DataStore/index.html

You can use any C# IDE to maintain your Web API project, but of course the tools PowerBuilder provides are simpler and more productive ;-)

Regards,
  1. Helpful
  1. Ricardo Jasso
  2. Tuesday, 3 December 2019 04:00 AM UTC
Jean,



Mark is right. If the url is "http://localhost/invoice/n_webservice.asmx"; the HTTP client will look for it in the computer the application is running. Is the web service located in the local machine? If not, change the url to the correct address.



Also, I noticed a bad namespace reference. I don't think xmlns="http://tempurl.org"; is correct. I believe it should be xmlns="http://tempuri.org";;;. Change the "l" for an "i".



Regards,

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