- Jesper Trebbien
- PowerBuilder
- Friday, 21 July 2023 03:16 PM UTC
Hi there,
I need to call a webservice using HTTPclient.
The service have several parameters (strings) and one parameter should contain XML-query.
When post with XML-query 400/Bad request is returned. With empty parameter 200/Ok is returned.
How should the XML in the string parameter be set?
Service description:
The code:
httpClient lo_client
integer li_ret , i , li_StatusCode
string ls_xml_request
string ls_url
string ls_data
string ls_body
string ls_ret
ls_xml_request = '<?xml version="1.0" encoding="windows-1252"?><EKSTYR PROGRAM="EKSMEDN">'+&
'<COPYBOOK1 COPY="EKS-MEDL-NAVN"><EFTERSOEG>klausen</EFTERSOEG>'+&
'<POSTSOEG>2100</POSTSOEG></COPYBOOK1></EKSTYR>'
ls_url ="http://prod.upic.intern/upicservice.asmx"
ls_body ='<?xml version="1.0" encoding="utf-8"?>'+&
'<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" '+&
'xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">'+&
' <soap12:Body>'+&
' <CallUpic xmlns="http://tempuri.org/">'+&
' <strPersonaleNr>999</strPersonaleNr>'+&
' <strValidatering>0</strValidatering>'+&
' <strProgram>EKSTYR</strProgram>'+&
' <strTransKode>10</strTransKode>'+&
' <strCopyBook>L10000</strCopyBook>'+&
' <strParm>'+ls_xml_request+'</strParm>'+&
' <strUTM></strUTM>'+&
' </CallUpic>'+&
' </soap12:Body>'+&
'</soap12:Envelope>'
lo_client = Create httpClient
lo_client.SetRequestHeader("Content-Type", "application/soap+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
Best Regards
Jesper
Find Questions by Tag
Helpful?
If a reply or comment is helpful for you, please don’t hesitate to click the Helpful button. This action is further confirmation of their invaluable contribution to the Appeon Community.