NetTalk Central

Author Topic: POST and parameters  (Read 5853 times)

AtoB

  • Jr. Member
  • **
  • Posts: 74
    • View Profile
    • Email
POST and parameters
« on: December 19, 2015, 03:16:30 AM »
Hi all,

I can't get parameters working with a webservice via a POST. I'm posting three parameters (see below the request that arrives serverside): "tabbed=1&traditional=0&readable=1"

In the primefields routine I expect the parameters to be accesible. In this routine the _postdata_ is filled with this string, but I can only get the FIRST parameter with the p_Web.GetValue('') command ....

I've dived into the netweb.clw file a little and it looks like something goes wrong in the NetwebserverWorker._ParseSettings method: I expect the line to be split on the "&" characters but it only sees one parameter (the part after the first "=", goes into the value of the first parameter). But I'm clueless to what is causing this

Can somebody tell me what I'm doing wrong here or what to check for?

TIA,
Ton


This is the request (incoming at the server)

POST /wsSupply/setLines HTTP/1.0
Accept: application/json
Accept-Language: en
Accept-Encoding:  gzip
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.2.16) Gecko/20110319 Firefox/3.6.16 ( .NET CLR 3.5.30729; .NET4.0C)
Host: localhost:8088
Content-Length: 33
Connection: Keep-Alive

tabbed=1&traditional=0&readable=1

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11244
    • View Profile
Re: POST and parameters
« Reply #1 on: December 20, 2015, 11:54:25 PM »
I set up a quick testing using NetDemo to send, and Example 77 to receive, but I don't see the problem you hare having Ton.

Perhaps set up a small example showing the effect?

cheers
Bruce

AtoB

  • Jr. Member
  • **
  • Posts: 74
    • View Profile
    • Email
Re: POST and parameters
« Reply #2 on: December 21, 2015, 05:40:16 AM »
Hi Bruce,

you're right it works in the examples.

And now the strange thing:

I've dived into the netweb.clw a little more and added/uncommented some self._trace calls. What I found out really troubles me: in my app the calls to the _ParseSettings method where the 5/6th parameter is omitted, the OMITTED(p_sep) still is False (and that's why the whole _postdata_ string isn't being split) !!!

For each post to the server the _Parsettings is called (at least) three times and the last one should be splitting the parameters. In my app the following code is called (fragment from the _HandlePost method), both by my app as well as for example the web77 app:

   elsif self.RequestBoundary <> ''
      self._ParseSettings(self.RequestData.DataString,x+4,self.RequestData.DataStringLen,0,self.RequestBoundary,net:Multipart)
    else
      self._trace('!!! this call to _ParseSettings is used !!!')
      self._ParseSettings(self.RequestData.DataString,x+4,self.RequestData.DataStringLen)
    end
  end
  self._trace('recs localdataq : ' & records(self._LocalDataQueue))
  loop qindex# = 1 to records(self._LocalDataQueue)
    get(self._LocalDataQueue, qindex#)
    self._trace('element : ' & qindex# & ' param : ' & self._LocalDataQueue.name & ' val : ' & self._LocalDataQueue.value)
  end

So in both apps the parameters in the calling statement are the same, but somehow, the implementation of the _ParseSettings method fails because of the omitted(p_sep) is not working ...

So it's more that omitted is not returning the right value somehow ...

(already removed obj files etc and recompiled stuff a dozen of time ..., but I am really clueless to what is going on here ...)

Regards,
Ton

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11244
    • View Profile
Re: POST and parameters
« Reply #3 on: December 21, 2015, 07:19:14 PM »
Is your server app legacy or ABC?

AtoB

  • Jr. Member
  • **
  • Posts: 74
    • View Profile
    • Email
Re: POST and parameters
« Reply #4 on: December 22, 2015, 02:26:03 AM »
Hi Bruce,

neither <g> It mostly resembles legacy I guess.

This app basicly is (quite a lot of) global data and call to the Netwebserver procedure, from there on it seems there is no code of mine even in sight (which is a good thing). Today a created a new NetWebServiceMethod with nothing in it only for testing, same problem.

There must be something in my app/code that causes this omitted statement to misbehave. But for the the moment I haven't got the slightest idea what that could be. I don't have that much code in c10 either so don't wether that might add something to it ... I'll park this for a couple of days/weeks as I have to much other stuff to do, but will keep you posted

Sorry for posting this over here, but at first I thougth it had to be nettalk as there was this incoming request that was perfectly ok and the rest was nettalk methods calling nettalk methods ... jumping to conclusions again

thanks and regards,
Ton

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11244
    • View Profile
Re: POST and parameters
« Reply #5 on: December 23, 2015, 04:25:02 AM »
Hi Ton,

let me re-phrase the question.

The app which contains the WebHandler procedure, is it set to use the Clarion templates or the ABC templates?
the way the two sets of templates generate objects is different, which in turn can affect omitted procedures.

So the "chain" of the template, in which the nettalk procedures sit, is important.

cheers
Bruce

AtoB

  • Jr. Member
  • **
  • Posts: 74
    • View Profile
    • Email
Re: POST and parameters
« Reply #6 on: February 24, 2016, 05:58:00 AM »
Hi Bruce,

sorry for very late response (had to switch to other activities ...)

as far as I can tell, het nettalk templates see my templateset as family "cw20", so as legacy.

The strange thing is that I experience the omitted error in the NetWebServerWorkerBase._ParseSettings method and that this method is only called from within the source code (so I don't see how the template chain would influence the omitted statement not working as expected ...)

Regards,
Ton

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11244
    • View Profile
Re: POST and parameters
« Reply #7 on: March 15, 2016, 06:12:59 AM »
Hi Ton,

I've tweaked 9.07 to handle the p_sep parameter being omitted or blank.

The reason it's "not omitted" is because your derived method is calling the parent, and at that point not omitting the parameter.

cheers
Bruce

AtoB

  • Jr. Member
  • **
  • Posts: 74
    • View Profile
    • Email
Re: POST and parameters
« Reply #8 on: August 02, 2016, 11:23:11 AM »
Hi Bruce,

sorry for the late reply (way too much other stuff on my plate), but I recently upgraded and started with webservices again indeed now it works !!!

Thanks!