I'm trying to establish a 'session' with a mailing house's web services...
First step is to get a security token -- which I've got working great thanks to Ivan OpenXML syntax question.
But, apparently I have to pass both the security token, and the session ID, which comes in the form of a cookie, back on subsequent requests to other methods on the same server.
There is lots of documentation on setting cookies when creating web services, but I cant find how to read a cookie, so that I can pass the session it back to the server on subsequent requests in a HEADER clause. OR does the SQLA web client just do this automatically, like a web browser does?
Here is my code... and the code commented out doesn't work (syntax near BEGIN). Code was lifted from NEXT_HTTP_RESPONSE_HEADER documentation
I tried the same LOOP code in the procedure that calls this one, and while the code runs, it produces no result, indicating to me that the calling procedure doesn't have access to the headers -- I need to get them from within this function.
So, that's my question... how do I get the cookie and send it back?
I'm running on SQLA 18.104.22.16844
First, if you are defining a procedure that does a HTTP SOAP call to another HTTP server then you cannot define a body, hence why you are getting an error at "BEGIN".
To pass a cookie back to the other HTTP server you must define a "COOKIE" header in the out-going HTTP request. To do this you use the HEADER clause in your create procedure (or function) declaration. Example:
Then pass in the header string that will set the cookie value. E.g.
The actual value that you set (in above example: "sessionid=some-value") will be dependent on the cookie value that you got back from the server when you made the call.
See the documentation of create procedure statement for web services in the 12.0.1 docs.
There is also an example in your SQL Anywhere installation called "soapsession.sql" that illustrates how to do this (and I have attached it for your viewing pleasure :-)
If you need to extract the cookie from the HTTP headers from your first request to the server then you need to define your routine as a procedure (not a function) and extract the SET-COOKIE header from the result set returned from the procedure.
Example: Here is a procedure that does a generic web request call (some code extracted out of one of my apps):
And here is a snippet of code that can be used to get the cookie from the headers:
I had the same question as above. When i try this example, it sort of works, but the cookie is only the last pair of cookies in the response. Here's the cookie info it shows in the query result (attribute,value): 'Set-Cookie','BIGServer-8080=123432138.36895.0000; path=/'
But in Mozilla I can inspect the cookie that gets returned, and it has 11 sets of cookies in the Cookie result. (eg, something like this. values have been changed, shortened to protect privacy): LogoURL=www.blah.com; BlahTicket=12341341234123%7C41ee026bc0000000%7C41df3c04d7800000%7C; BlahUser=blaha%7C41ee026bc0000000%7C41df3c04d7800000%7C; BIGServer-8080=123432138.36895.0000;
How can I get all the other cookie pairs? I'm using Sqlanywhere 10.0.1 build 4135. Thanks,
answered 21 Oct '11, 20:04