NetTalk Central

Author Topic: Webservices : how to create method with queue and singular variables as paramete  (Read 4485 times)

AtoB

  • Jr. Member
  • **
  • Posts: 74
    • View Profile
    • Email
Hi all,

so far I've created only methods with a couple of single variables as incoming parameters. Now I want to add the possibility to handle both these singular variables and some compound json (to be stored in a queue). I've added a queue to the incoming parameters and studied the genereted help file from the service, but apart from the soap structures I don't see the queue occuring in this help ...

with only a list of variables one can specify these as parameters in the url (&somevar=somevalue), but I guess the compound json should be put in the request body directly (with corresponding headers set to the right "content-type" so server knows how to handle), but where do my singular variable go now?

Singular var = "readable"
Compound json should go into the "SomeQueue"

This is part of the example request for the soap handling:

POST /wsSupply HTTP/1.1
Host: localhost:8088
Content-Type: application/soap+xml
Content-Length: length

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
  <soap:Body>
    <sets xmlns="">
      <readable>value</readable>
      <SomeQueue_list>
        <SomeQueue>
          <SQ_TEST>value</SQ_TEST>
        </SomeQueue>
        <SomeQueue>
          <SQ_TEST>value</SQ_TEST>
        </SomeQueue>
      </SomeQueue_list>
    </sets>
  </soap:Body>
</soap:Envelope>

And this is the HTTP POST for JSON:

POST /sets HTTP/1.1
Host: localhost:8088
Content-Type: application/x-www-form-urlencoded
Accept: application/json
Content-Length: length

readable=value

But here there is nothing generated with regards to the "SomeQueue" structure ...

How should one compose such a (json) request?

TIA
Ton

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11244
    • View Profile
Hi Ton,

seems ok here.
Do you have the jFiles global extension added to the app?

Can you perhaps duplicate in the example app, just add a test method there and send that to me please?

cheers
Bruce


AtoB

  • Jr. Member
  • **
  • Posts: 74
    • View Profile
    • Email
Hi Bruce,

I've modified the "TestQueueParameter" procedure of the web77 app and attached it as txa (zipped). I've added a simple variable "SomeVar" as an incoming parameter.

The code below is generated for the JSON post request. It shows the "SomeVar", but I cannot see the DepartmentQueue in the JSON request ...

What I actualy want to know is how to construct a json request with both this "somevar" and a queue. I guess the Queue shouldn't go into header, but into the body as json, but where should "somevar" go then (should it go into the json too?), But if all goes into the body the requested content-type shouldn't probably not be "application/x-www-form-urlencoded" any more ...

So many questions :-)

regards,
Ton



!-------------------------------------------------------------------------------------------
ExampleJSONPostRequest  Routine
  egRequest.SetValue('')
  egRequest.append('<div class="nt-http-method ui-widget-header ui-corner-all">HTTP POST (JSON)</div>')
  egRequest.append('The following is a sample HTTP POST request and response. The placeholders shown need to be replaced with actual values.<br/><br/>')
  egRequest.append('<div class="nt-example">Example Request</div><br/>')
  egRequest.append('<div class="nt-request nt-response ui-corner-all">POST /TestQueueParameter HTTP/1.1<br/>' &|
                'Host: '&clip(p_web.RequestHost)&'<br/>' &|
                'Content-Type: application/x-www-form-urlencoded<br/>' &|
                'Accept: application/json<br/>' &|
                'Content-Length: <span class="nt-place">length</span><br/><br/>' &|
                p_web.Nocolon('SomeVar=<span class="nt-place">value</span>') &|
                '</div><br/>')
  egRequest.append('<div class="nt-example">Example Response</div><br/>')
  packet.Append(egRequest.GetValue())

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11244
    • View Profile
rather than send a TXA which I have to import etc, rather just zip the example app, dict and data together and post that. That's a lot quicker for me to inspect on this side. Thanks.

cheers
Bruce

AtoB

  • Jr. Member
  • **
  • Posts: 74
    • View Profile
    • Email
Hi Bruce,

wasn't aware of that, attached the "complete" zip. Let me know if you need anything else

regards,
Ton

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11244
    • View Profile
ok, I see what's happening.
So the "simple" requests (simple GET & POST) can't do "lists" in their data. (The GET only has a URL and a POST only has the data area.)

So to send lists you need either a SOAP request (ie XML) or a JSON formatted PostData request. At the moment the examples page is not showing the formatted JSON request though.

I'll try and get that added for an upcoming build.

The Json request will work, as is, it's just the doc which is lacking.

Cheers
Bruce


AtoB

  • Jr. Member
  • **
  • Posts: 74
    • View Profile
    • Email
Hi Bruce,

yep, that's what I noticed.

Btw. you don't have change the docs for me (or at least not in a hurry ...). I was mainly intrested in where the parameter should go then, but it's the same as for the xml/soap handling: all parameters then move into the json (to the postdata section) and nettalk will parse it the same way as if it was urlencoded

Thanks!

Ton