On Wed, Feb 3, 2010 at 6:58 AM, Fenton, Brian <[email protected]> wrote:
> Hi Jeff,
>
> many thanks for that pointer! That makes a lot of sense. Unfortunately it's
> not working for me with that particular StockQuote web service. Now I know
> the web service is quite slow but it works fine with the sockets approach. I
> tried different timeouts but no joy. I wonder is it my AOLserver's (4.0.10)
> version of ns_http? I can't seem to find any free web services to test
> against - that webserviceX.NET is very slow.
>
> My other question is - I'm hoping to do an SSL version once I have the
> basic code working. I don't think there's a HTTPS version of ns_http, is
> there? At least there is an SSL version of ns_sockopen
> (ns_openssl_sockopen). Would that be the way to go?
>
There is ns_httpsget and ns_httpspost in ns_openssl.
Dave
>
> Here's my code:
>
> set result ""
>
> set soap_request {<?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://schemas.xmlsoap.org/soap/envelope/"><soap:Body><GetQuote xmlns="
> http://www.webserviceX.NET/
> "><symbol>GOOG</symbol></GetQuote></soap:Body></soap:Envelope>}
>
> set type "text/xml"
>
> set rqset [ns_set new rqset]
> ns_set put $rqset SOAPAction "http://www.webserviceX.NET/GetQuote"
>
>
> if {[catch {set rqid [ns_http queue POST "
> http://www.webserviceX.NET/stockquote.asmx" $soap_request $rqset]} err ]}
> {
> set result $err
> ns_log Notice "Brian error result=$result"
> } else {
> set status [ns_http wait $rqid result 60]
> ns_log Notice "Brian after wait rqid=$rqid status=$status result=$result"
> }
>
> ns_return 200 text/plain $result
>
>
> Brian
>
> ________________________________________
> From: AOLserver Discussion [[email protected]] On Behalf Of Jeff
> Rogers [[email protected]]
> Sent: 03 February 2010 07:12
> To: [email protected]
> Subject: Re: [AOLSERVER] differences between ns_httppost and sockets?
>
> Hi Brian,
>
> ns_httppost does url-encoding of the name-value pairs you pass in as
> qsset. For SOAP you need to just post the xml message, not as a
> name-value pair. If you sniffed the actual request you're sending with
> ns_httppost it would be something like
> Message=<?xml version="1.0" .....
>
> Try using ns_http queue instead.
>
> set rqid [ns_http queue POST http://www.webserviceX.NET/stockquote.asmx
> $soap_request $rqset]
> ns_http wait $rqid result
>
> http://panoptic.com/wiki/aolserver/Ns_http for reference.
>
> -J
>
> Fenton, Brian wrote:
> > Hi
> >
> > I`m having some difficulties that hopefully somebody here could assist me
> with. I`m hand-coding a request to a SOAP service and I can`t get it working
> with AOLserver`s ns_httppost command, but it works fine using sockets. I`m
> wondering could it be some headers or encoding that ns_httppost does? Or
> maybe a timeout? I`ve seen some articles on the web that suggest putting
> \r\n between the headers and the body (which you can see in the sockets
> example) - does ns_httppost automatically do that for me? If not how would I
> do it?
> >
> > I`m using AOLserver 4.0.10
> >
> >
> > Here`s the code using ns_httppost that doesn`t work - just returns empty
> string:
> >
> > set result ""
> > set soap_request {<?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://schemas.xmlsoap.org/soap/envelope/"><soap:Body><GetQuote xmlns="
> http://www.webserviceX.NET/
> "><symbol>GOOG</symbol></GetQuote></soap:Body></soap:Envelope>}
> > set type "text/xml"
> > set rqset [ns_set new rqset]
> > ns_set put $rqset SOAPAction "http://www.webserviceX.NET/GetQuote"
> > set qsset [ns_set new qsset]
> > ns_set put $qsset Message $soap_request
> > set cmd {set page [ns_httppost "
> http://www.webserviceX.NET/stockquote.asmx" $rqset $qsset $type ]}
> > if {[catch $cmd errmsg]} {
> > set result $errmsg
> > } else {
> > set result $page
> > }
> > ns_return 200 text/plain $result
> >
> >
> >
> > And here`s the sockets program (based on some fine code written by Tom
> Jackson) - this works perfectly (abeit it takes a while to come back):
> >
> > set SOAP {<?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://schemas.xmlsoap.org/soap/envelope/">
> > <soap:Body>
> > <GetQuote xmlns="http://www.webserviceX.NET/">
> > <symbol>GOOG</symbol>
> > </GetQuote>
> > </soap:Body>
> > </soap:Envelope>}
> >
> > set length [string length $SOAP]
> > set headers ""
> > set fds [ns_sockopen www.webserviceX.NET 80]
> > set rid [lindex $fds 0]
> > set wid [lindex $fds 1]
> > puts $wid "POST /stockquote.asmx HTTP/1.1
> > Host: www.webservicex.net
> > Content-Type: text/xml; charset=utf-8
> > Content-Length: $length
> > SOAPAction: \"http://www.webserviceX.NET/GetQuote\"
> > $SOAP"
> > flush $wid
> > while {[set line [string trim [gets $rid]]] != ""} {
> > lappend headers $line
> > }
> > set page [read $rid]
> > close $rid
> > close $wid
> >
> > ns_return 200 text/plain "
> > Sent:
> > POST /stockquote.asmx HTTP/1.1
> > Host: www.webservicex.net
> > Content-Type: text/xml; charset=utf-8
> > Content-Length: $length
> > SOAPAction: \"http://www.webserviceX.NET/GetQuote\"
> > $SOAP
> > Received:
> > [join $headers "\n"]\n\n$page"
> >
> > Any suggestions?
> > Many thanks,
> > Brian
> >
> >
> > --
> > AOLserver - http://www.aolserver.com/
> >
> > To Remove yourself from this list, simply send an email to<
> [email protected]> with the
> > body of "SIGNOFF AOLSERVER" in the email message. You can leave the
> Subject: field of your email blank.
>
>
> --
> AOLserver - http://www.aolserver.com/
>
> To Remove yourself from this list, simply send an email to <
> [email protected]> with the
> body of "SIGNOFF AOLSERVER" in the email message. You can leave the
> Subject: field of your email blank.
>
>
> --
> AOLserver - http://www.aolserver.com/
>
> To Remove yourself from this list, simply send an email to <
> [email protected]> with the
> body of "SIGNOFF AOLSERVER" in the email message. You can leave the
> Subject: field of your email blank.
>
--
Dave Bauer
[email protected]
http://www.solutiongrove.com
--
AOLserver - http://www.aolserver.com/
To Remove yourself from this list, simply send an email to
<[email protected]> with the
body of "SIGNOFF AOLSERVER" in the email message. You can leave the Subject:
field of your email blank.