Hello ,
Is it possible to consume wcf web service with powertbuiler 2017 r3 ?
if any one have code sample it can be most hekpfull
Thanks
Hello ,
Is it possible to consume wcf web service with powertbuiler 2017 r3 ?
if any one have code sample it can be most hekpfull
Thanks
Hi Moshe
Here is some test code I used to connect to a "Real World" service:
n_httpclient l_http
string ls_test, ls_response
ulong lul_length
blob lblob_data, lblob_response
integer li_rc
ls_test = '<?xml version="1.0" encoding="utf-8"?><SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"> <SOAP-ENV:Header>' + &
'<wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">' + &
' <wsse:UsernameToken>' + &
' <wsse:Username>MainstayTest</wsse:Username>' + &
' <wsse:Password>xxxxxxxxxxx</wsse:Password>' + &
' </wsse:UsernameToken>' + &
'</wsse:Security>' + &
'</SOAP-ENV:Header>' + &
'<SOAP-ENV:Body>' + &
' <OTA_PingRQ xmlns="http://www.opentravel.org/OTA/2003/05" EchoToken="123456789" TimeStamp="2019-10-16T17:32:20+01:00" Version="1">' + &
' <EchoData> Hello World </EchoData>' + &
' </OTA_PingRQ>' + &
'</SOAP-ENV:Body>' + &
'</SOAP-ENV:Envelope>'
lblob_data = blob(ls_test, EncodingUTF8!)
l_http = Create n_httpclient
l_http.autoreaddata = true
l_http.secureprotocol = 5 // TLS 1.2
l_http.timeout = 60
lul_length = Len(lblob_data)
li_rc = l_http.clearrequestheaders( )
li_rc = l_http.SetRequestHeader("Content-Length", String(lul_length))
//SetRequestHeader("Content-Type", 'application/soap+xml; charset=utf-8')
li_rc = l_http.SetRequestHeader("Content-Type", 'text/xml;charset=UTF-8')
li_rc = l_http.SetRequestheader( 'Accept-Encoding', 'text/xml;charset=UTF-8')
li_rc = l_http.SetRequestheader( 'Host', 'cmtpi.siteminder.com')
li_rc = l_http.SetRequestheader( 'Connection', 'Keep-Alive')
li_rc = l_http.SetRequestheader( 'User-Agent', 'Apache-HttpClient/4.1.1 (java 1.5)')
li_rc = l_http.SetRequestheader( 'Accept', 'text/xml')
li_rc = l_http.SetRequestHeader("SOAPAction", '"http://www.siteminder.com.au/pmsxchange/PingRQ"')
//messagebox('Headers', l_http.getrequestheaders( ))
li_rc = l_http.sendrequest( 'POST', 'https://cmtpi.siteminder.com/pmsxchangev2/services/MAINSTAY', ls_test)
//https://cmtpi.siteminder.com/pmsxchangev2/services/MAINSTAY
//li_rc = l_http.postdatastart( 'https://cmtpi.siteminder.com/pmsxchangev2/services/MAINSTAY')
//li_rc = l_http.postdata(lblob_data,lul_length)
//li_rc = l_http.postdata( ls_test, len(ls_test))
//li_rc = l_http.postdataend( )
//li_rc = l_http.getresponsebody( ls_response)
li_rc = l_http.getresponsestatuscode( )
li_rc = l_http.getresponsebody( ls_response)
li_rc = len(ls_response)
long ll_file
ll_file = fileopen("c:\temp\response.txt", streammode!,write!,shared!,replace!)
filewrite(ll_file, ls_response)
fileclose(ll_file)
Messagebox('Response',ls_response)
ls_response = l_http.getresponseheaders( )
messagebox('Response Head', ls_response)
//li_rc = l_http.getresponsestatuscode( )
//li_rc = l_http.readdata( lblob_response , 1024*16)
//ls_response = string(lblob_response, EncodingUTF8!)
=====================================================================
The commented out code was used to understand the postdata and readdata functions. I then used sendrequest becuase it is much easier.
The key parts are setting the Header attributes to match the call you are making. Then structure the XML body to match the message structure. Get everything right and it just works :)
Hi ,
Plz see the attached pic below ,
What do I do from here ?
I can see the WSDL file , but I want to consume it with httpclient object and not with soap object
How do I build all the parameters ? the ws function gets and object array .. How do I apply it with the httpclient object ?
Thanks
Hi Moshe,
Please refer to the bellow article "Call SOAP Web Services Using HTTPClient Object" to rewrite your code to call WCF web service.
You will find that it is using the same code except for the XML Serializer format parameter. However, if you use the string variable to set the value, then there will be no different.
You may utilize the below two objects added in PB 2017 R3 for receiving web service APIs.
RESTClient
BTW, if the "Call SOAP Web Services Using HTTPClient Object" article can’t help you, please also let us know.
You can report it to our support ticketing system (https://www.appeon.com/standardsupport/newbug) with a sample reproducible test case to us for study.
Regards,
Hi Moshe;
FWIW: I have not tried interacting with WCF specifically, but I am guessing that the new HTTPClient will be able to interact with a WCF Web Service. One of the main challenges though is when the WCF WS responds. It will probably use an XML format. For parsing that XML data stream, you will have to use the PBDOM feature of PB.
Regards ... Chris