1. Moshe Tangi
  2. PowerBuilder
  3. Tuesday, 17 July 2018 04:47 AM UTC

Hi all

I have build a target ws. One of its functions needs to return a file.

What is the best way of doing that ?

I have tried convert file into blob but the proxy ws "understands" that as ANY type , why ?

 

Any ideas ?

Thanks

 

Marco Meoni Accepted Answer Pending Moderation
  1. Tuesday, 17 July 2018 10:03 AM UTC
  2. PowerBuilder
  3. # 1

Hi Moshe,

keep the return value/argument as Blob.

When you deploy the WS it will be converted into a byte array (as visible from your PB proxy).

Then you just need to have your WS client reading the byte array:

 

 

byte lbytes[]
Blob lblb
...

// call WS
l_rc = lnv_webservice.myfunction(lbytes)

// convert byte array into blob
lBlobLen = UpperBound(lbytes)
lblb = Blob(Space(lBlobLen), EncodingAnsi!)
For lBytePos = 1 To lBlobLen
   BlobEdit(lblb, lBytePos, lbytes[lBytePos], EncodingANSI!)
Next

 

Best,

.m

Comment
  1. Moshe Tangi
  2. Tuesday, 17 July 2018 10:48 AM UTC
Hi Marco

Thanks

one more question :

Why I can not operate on files on h.d from the ws functions ? I have applied an application pool with administrator user for the application under IIS , I have tested my code outside the ws and its works fine .

I have checked the files permissions …

what is mandatory for iis ws to work if I want to read files from h.d ?

thanks
  1. Helpful
There are no comments made yet.
Marco Meoni Accepted Answer Pending Moderation
  1. Tuesday, 17 July 2018 13:00 PM UTC
  2. PowerBuilder
  3. # 2

Hi,

WSs do not have rights to access folders outside the IIS sandbox.

best,

.m

Comment
  1. Chris Pollach @Appeon
  2. Tuesday, 17 July 2018 14:13 PM UTC
Hi Moshe / Marco;

You need to delegate access to the Folder(s) / File(s) outside your Web Service's "sandbox" by having the WS call an thread outside of IIS. You can see an example of this in my PDF example: https://sourceforge.net/projects/stdfndclass/files/Applications/WebService/PDF

The external App thread can move files In/Out of the WS "sandbox" as needed.

HTH

Regards ... Chris
  1. Helpful
There are no comments made yet.
Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Tuesday, 17 July 2018 13:37 PM UTC
  2. PowerBuilder
  3. # 3

Hi Moshe;

     Remember that any data returned from a Web Service is formatted in XML. Thus, any BLOB data needs to be converted to a Base64 format in order to pass through the XML schema.

Regards ... Chris

Comment
  1. Moshe Tangi
  2. Tuesday, 17 July 2018 14:46 PM UTC
Hi Chris



" any BLOB data needs to be converted to a Base64 format in order to pass through the XML schema."

What does it mean ? the functions converts a file into blob , now , it needs to get to the client … ??

How do I go from here ?

  1. Helpful
  1. Chris Pollach @Appeon
  2. Tuesday, 17 July 2018 15:06 PM UTC
You would need to call the Base64 methods in the O/S to perform that functionality. PB2017R3 will now support the Base64 Encode/Decode command features when released at the end of July, 2018.



For now though - you might want to just declare your WS as returning a BYTE [ ] array and then follow Marco's processing suggestion.
  1. Helpful
  1. Moshe Tangi
  2. Wednesday, 18 July 2018 17:03 PM UTC
I did try to send array of bytes but the pb does not support array as returned parameter from function
  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.