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
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,
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