NetTalk Central

Author Topic: WebService file upload error's  (Read 4595 times)

astahl

  • Sr. Member
  • ****
  • Posts: 308
    • View Profile
    • Email
WebService file upload error's
« on: February 21, 2015, 05:04:17 AM »
Hi Bruce,

Trying the new file upload service you talked about in last week's webinar. I am getting the below errors when compiling.

PrimeParameters  routine
  If p_web.xml = 0 ! incoming parameters are just url encoded, either in the URL, or as post data, or as a cookie.
    If p_web.IfExistsValue('username') then username = p_web.GetValue('username').
    If username = ''
    p_web.AddServiceError(Error:MustNotBeBlank,'FilesUpload', 'username', 'Parameter must not be zero or blank','')
    End
    If p_web.IfExistsValue('password') then password = p_web.GetValue('password').
    If password = ''
    p_web.AddServiceError(Error:MustNotBeBlank,'FilesUpload', 'password', 'Parameter must not be zero or blank','')
    End
    If p_web.IfExistsValue('jobnumber') then jobnumber = p_web.GetValue('jobnumber').
    If jobnumber = ''
    p_web.AddServiceError(Error:MustNotBeBlank,'FilesUpload', 'jobnumber', 'Parameter must not be zero or blank','')
    End
    filename.Free()
    If p_web.IfExistsValue('filename') then filename.SetValue(p_web.GetFileFromPost('filename')).
    ! p_web.RequestMethodType could be one of NetWebServer_GET, NetWebServer_PUT, NetWebServer_POST, NetWebServer_DELETE
  Else ! incoming parameters are in an xml structure
    strxml.SetValue(p_web.GetValue('xml'))
    Clear(username)
    username = strxml.between(p_web.Nocolon('<username>',Net:SingleUnderscore+Net:NoSpaces),p_web.Nocolon('</username>',Net:SingleUnderscore+Net:NoSpaces))
    If username = ''
    p_web.AddServiceError(Error:MustNotBeBlank,'FilesUpload', 'username', 'Parameter must not be zero or blank','')
    End
    Clear(password)
    password = strxml.between(p_web.Nocolon('<password>',Net:SingleUnderscore+Net:NoSpaces),p_web.Nocolon('</password>',Net:SingleUnderscore+Net:NoSpaces))
    If password = ''
    p_web.AddServiceError(Error:MustNotBeBlank,'FilesUpload', 'password', 'Parameter must not be zero or blank','')
    End
    Clear(jobnumber)
    jobnumber = strxml.between(p_web.Nocolon('<jobnumber>',Net:SingleUnderscore+Net:NoSpaces),p_web.Nocolon('</jobnumber>',Net:SingleUnderscore+Net:NoSpaces))
    If jobnumber = ''
    p_web.AddServiceError(Error:MustNotBeBlank,'FilesUpload', 'jobnumber', 'Parameter must not be zero or blank','')
    End
    filename.Free()
    filename.SetValue(strxml.between(p_web.Nocolon('<filename>',Net:SingleUnderscore+Net:NoSpaces),p_web.Nocolon('</filename>',Net:SingleUnderscore+Net:NoSpaces)))
    filename.Base64Decode()
  End


Not sure what I need to set for the filename.

Ashley

astahl

  • Sr. Member
  • ****
  • Posts: 308
    • View Profile
    • Email
Re: WebService file upload error's
« Reply #1 on: February 21, 2015, 05:25:21 AM »
Hi Bruce,

It needed StringTheory declared in LocalData ,
ST                   Class(StringTheory)

I had StringTheory extension populated but it did not pick it up so I put it in local data and it has now compiled.

I think it should have told me it needed StringTheory for the Parameter when I selected Type as a File in the Parameters List.

Also how would one request a report as a service in pdf format to download?


Ashley
« Last Edit: February 21, 2015, 05:38:34 AM by astahl »

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11251
    • View Profile
Re: WebService file upload error's
« Reply #2 on: February 23, 2015, 12:02:41 AM »
Hi Ashley,

thanks - I'll look into the StringTheory thing - that should be easier methinks.

>> Also how would one request a report as a service in pdf format to download?

I guess an example of that would be helpful - I'll try and put one together.
I guess this is specifically for the case where a _program_ is getting the PDF? and presumably saving it for a user somewhere?

cheers
Bruce

astahl

  • Sr. Member
  • ****
  • Posts: 308
    • View Profile
    • Email
Re: WebService file upload error's
« Reply #3 on: February 23, 2015, 03:47:43 AM »
Hi Bruce,

Thanks for looking into that.

Yes, your presumption is correct. I would like to have some reports and a data export as a service. That would allow a client to request these on demand instead of us having to generate all at once, and then ftp all to the client.

How does on get the files name from the post? Is the file uploaded first and then the Service Method called?

Also I am now getting this in my file upload service documentation(see attached png) since I added String Theory to filename.

Thanks for all the help!

Ashley


[attachment deleted by admin]
« Last Edit: February 23, 2015, 05:44:17 AM by astahl »

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11251
    • View Profile
Re: WebService file upload error's
« Reply #4 on: February 23, 2015, 10:46:09 PM »
Hi Ashley,

>> How does one get the files name from the post?

In my app I added a second field to the parameters list. ie one for the filename, one for the file itself. This gives the client program
the ability to set the name explicitly.

>> Is the file uploaded first and then the Service Method called?

yes. The file is received, and in ram when the ServiceMethod is called. At this point though it has not been saved. If you want to save it then call
ST.SaveFile(whatever)
where ST is the name of your File Parameter.

>> Also I am now getting this in my file upload service documentation(see attached png) since I added String Theory to filename.

yes, thanks, I'm looking into this.

cheers
Bruce


astahl

  • Sr. Member
  • ****
  • Posts: 308
    • View Profile
    • Email
Re: WebService file upload error's
« Reply #5 on: February 24, 2015, 03:30:08 AM »
Hi Bruce,

Info much appreciated.

Thanks,

Ashley