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 
<lists...@listserv.aol.com> with the
body of "SIGNOFF AOLSERVER" in the email message. You can leave the Subject: 
field of your email blank.

Reply via email to