1. Jesper Trebbien
  2. PowerBuilder
  3. Friday, 21 July 2023 15: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 

 

Roland Smith Accepted Answer Pending Moderation
  1. Friday, 21 July 2023 17:25 PM UTC
  2. PowerBuilder
  3. # 1

The XML is the posted data. Convert the XML string to a UTF8 blob and post that.

Comment
There are no comments made yet.
Arnd Schmidt Accepted Answer Pending Moderation
  1. Friday, 21 July 2023 15:52 PM UTC
  2. PowerBuilder
  3. # 2
Hi Jesper,
 
you have to encode the needed XML or use CDATA.

https://stackoverflow.com/questions/5715404/soap-ui-how-to-pass-xml-inside-parameter

hth

Arnd

Comment
  1. Jesper Trebbien
  2. Sunday, 23 July 2023 07:58 AM UTC
Hi Arnd

I just changed < to &lt; like this:

ls_xml_request = '&lt;?xml version="1.0" encoding="windows-1252"?>&lt;EKSTYR PROGRAM="EKSMEDN">'+&

'&lt;COPYBOOK1 COPY="EKS-MEDL-NAVN">&lt;EFTERSOEG>klausen&lt;/EFTERSOEG>'+&

'&lt;POSTSOEG>2100&lt;/POSTSOEG>&lt;/COPYBOOK1>&lt;/EKSTYR>'

It works!

I am very pleased. Thank you.

BR Jesper
  1. Helpful
  1. Miguel Leeuwe
  2. Sunday, 23 July 2023 08:18 AM UTC
Hi,

Please mark as resolved!
  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.