1. Hannu Pikkarainen
  2. PowerBuilder
  3. Tuesday, 8 May 2018 10:47 AM UTC

Hi,

When I consume a Web Service with a PB client, response comes in XML-format and is stored in a variable created by Web Service Proxy Wizard. I can then process the contents of that variable in code but is there any way I could save the contents to a XML-file. 

BR, Hannu

Marco Meoni Accepted Answer Pending Moderation
  1. Tuesday, 8 May 2018 11:34 AM UTC
  2. PowerBuilder
  3. # 1

Hello Hannu,
I assume you get the response in a String variable, formatted as XML.
Dumping that string to a file is simply:

li_fid = FileOpen("out.xml", TextMode!, Write!, LockWrite!, Append!)
FileWriteEx(li_fid, ls_xml_response)

Another approach is to connect the Web Service using a WS-DW instead of the Proxy object, and then use SaveAs().

Best,
Marco

Comment
  1. Hannu Pikkarainen
  2. Thursday, 24 May 2018 11:12 AM UTC
Hi,



It was not so simple. The responce is a string in XML-format, but because it is declared as complex type



type variables

    hahka_GetUnreadInvoicesResultInvoice invoice[]

    string version

end variables



I can't use it with FileWriteEx:



hahka_getunreadinvoicesresult laskut

laskut = px_Service.getunreadinvoices(1,password)

tdsto = FileOpen(tiedostox,TextMode!,Write!,LockWrite!,Append!)



// this causes error in compiler becaus laskut is not of type string : FileWriteEx(tdsto,laskut)

FileWriteEx(tdsto,string(laskut)) // this produces only empty string to the file

FileClose(tdsto)



BR, Hannu



 



 





 



 

  1. Helpful
  1. Chris Pollach @Appeon
  2. Thursday, 24 May 2018 14:09 PM UTC
Hi Hannu;



   The problem is with your FileOpen ( ). Instead of TEXTMode! - use StreamMode!  instead.



HTH



Regards ... Chris

  1. Helpful
  1. Hannu Pikkarainen
  2. Monday, 28 May 2018 13:44 PM UTC
Hi Chris,



It did not help, compiler does not accept FileWriteEx(tdsto,laskut) because laskut is not string neither blob, it's type of hahka_getunreadinvoicesresult.



BR, Hannu



 



 

  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.