NetTalk Central

Author Topic: How do I create a webservice that receives a pdf and one of its parameters ?  (Read 5365 times)

MikeR

  • Sr. Member
  • ****
  • Posts: 265
    • View Profile
    • Email
Hi clever people,

I have finally manged to call a webservice that receives a pdf as input ,
I now need to write one that receives a pdf as one of its parameters.
Who can point me in the correct direction ?

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11298
    • View Profile
there's not really much to do Mike,

an incoming PDF will mean that the incoming POST is a multi-part thing, with the PDF file set as a "file upload". So all the usual stuff applies really, the incoming file will land in the uploads folder and the other parameters will be in the Value queue.

another approach is that the incoming xml can "contain" the file (usually encoded with Mime64 or whatever) as one of the fields. Large xml sure, but very do-able as well.

cheers
Bruce

MikeR

  • Sr. Member
  • ****
  • Posts: 265
    • View Profile
    • Email
thanks Bruce, but i'm still a bit confused.
option 1.
do I create a form that accepts for example two memory fields and a upload file.
the user of my service must use a post to call me.
When I receive the post I need to know that the uploaded file is linked to the two other parameters I receive in the post. I'm  not sure this method will allow me that control.

option2.
Tell the user of my service to send me an xmlstring with three parms where the third one is the pdf encoded.
I don't know how to seperate the pdf file out of the xmlstring so I can decode it and store it.

Do these questions make sense ? ???



peterH

  • Sr. Member
  • ****
  • Posts: 413
    • View Profile
Use option2 and you're close. Since you control the ws you decide which parms and tags to use. Then, parse the XML string yourself or use xFiles (recommended). Also, take a look at the webservice example, that should make things clearer. The pdf file is just an encoded string when you receive it. Decode it and you have a file you can save to disk. If you've got StringTheory use that.

It may take some trial and error until you get it right but it's really not that difficult.

HTH
Peter

MikeR

  • Sr. Member
  • ****
  • Posts: 265
    • View Profile
    • Email
thanks Peter, that was my original idea, to use xFiles to move the xml into a group.
But what data type do I use for the pdffilestring ?