Re: Tcl - Soap - Loosing My Mind
- From: nichols_scott@xxxxxxxxx
- Date: Fri, 27 Jul 2007 08:26:05 -0700
On Jul 26, 10:48 am, BMWM3...@xxxxxxxxx wrote:
Gerald...I'm constrained in what version of TCL I can use to
TCL8.3...therefore I cannot use WS::Client (or I wouldn't be asking
this)....wanted to get that out of the way first.
Anyway, the below code runs FINE when I hard-code the Soap into a
variable and returns correctly from the Web Service (SimpleEcho
WebService). (See QUERY output)
However, when I build the Soap document...it fails w/Malformed error.
Visually, they look identical. (See XML Output)
I've changed the Servername....but the output is what it is (probably
butchered in copy/paste)
My question is what is the difference, cause of the failure between
the @@5 XML@@ and the QUERY (hardcode).
Thank you in advance, this is something stupid (Probably me).
CODE:
package require http
package require tdom
package require tls
proc MAIN { } {
global sessionID
if { [catch {
puts "SimpleEcho"
lappend headers SOAPAction PAASServer:SimpleEcho
set url "http://MYSERVERName:8001/service/PAASServer/op"
set TNS "tns1"
dom createDocument "SOAP-ENV:Envelope" doc
$doc documentElement env
$env setAttribute \
"xmlns:SOAP-ENV" "http://schemas.xmlsoap.org/soap/
envelope/" \
"xmlns:SOAP-ENC" "http://schemas.xmlsoap.org/soap/
encoding/" \
"xmlns:xsi" "http://www.w3.org/2001/XMLSchema-
instance" \
"xmlns:xs" "http://www.w3.org/2001/XMLSchema"
$env setAttribute \
"xlmns:$TNS" "http://MYSERVERName:8001/service/PAASServer"
$env appendChild [$doc createElement "SOAP-ENV:Body" bod]
$bod appendChild [$doc createElement $TNS:SimpleEchoRequest
reply]
$reply appendChild [$doc createElement $TNS:TestString node]
$node appendFromList [list #text "THIS IS THE ULTIMATE TEST"]
append xml \
{<?xml version="1.0" encoding="utf-8"?>} \
"\n" \
[$doc asXML -indent none -doctypeDeclaration 0]
set soapyxml [string trim [$doc asXML -indent none -
doctypeDeclaration 0]]
set xml {<?xml version="1.0" encoding="utf-8"?>}
append xml $soapyxml
set xml2 $xml
$doc delete
set query {<?xml version="1.0" encoding="utf-8"?><SOAP-
ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/
envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tns1="http://MYSERVERName:8001/
service/PAASServer"><SOAP-
ENV:Body><tns1:SimpleEchoRequest><tns1:TestString>This is a test of
PAAS</tns1:TestString></tns1:SimpleEchoRequest></SOAP-ENV:Body></SOAP-
ENV:Envelope>}
puts "@@@@@@@@@@@@5 XML@@@@@@@@@@@@@@@@@@@@@@"
puts "\n$xml"
puts "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"
puts "QUERY:"
puts "\n$query"
if {[llength $headers]} {
#::log::puts debug [list ::http::geturl $url -query $query
-type text/xml -headers $headers]
set token [::http::geturl $url -query $query -type "text/xml" -
headers $headers]
# set token [::http::geturl $url -query $xml -type text/xml -
headers $headers]
} else {
#::log::puts debug [list ::http::geturl $url -query $query -
type text/xml]
set token [::http::geturl $url -query $xml -type text/xml]
}
::http::wait $token
set results [::http::data $token]
puts "RESULTS:$results"
puts "**************2nd REQUEST Using XML*************"
if {[llength $headers]} {
#::log::puts debug [list ::http::geturl $url -query $query
-type text/xml -headers $headers]
# set token [::http::geturl $url -query $query -type "text/xml" -
headers $headers]
set token [::http::geturl $url -query $xml -type text/xml -
headers $headers]
} else {
#::log::puts debug [list ::http::geturl $url -query $query -
type text/xml]
set token [::http::geturl $url -query $xml -type text/xml]
}
::http::wait $token
set results [::http::data $token]
puts "RESULTS:$results"
set responseListOfList $results
# responderRespond -destination $source -group $group -id $id -
type "DS" -data "\{$responseListOfList\}"
} errorString] } {
catch {
puts "ERROR: $errorString"
# Respond with a failure
#responderRespondFailure -destination $source -group
$group -id $id -type "DS" -reason "\{$errorString\}"
}
}
puts "---------------------------------------------------------"
}
MAIN
**********************************************************************
OUTPUT:
SimpleEcho
@@@@@@@@@@@@5 XML@@@@@@@@@@@@@@@@@@@@@@
<?xml version="1.0" encoding="utf-8"?><SOAP-ENV:Envelope xmlns:SOAP-
ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://
schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/
XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema"
xlmns:tns1="http://MYSERVERName:8001/service/PAASServer"><SOAP-
ENV:Body><tns1:SimpleEchoRequest><tns1:TestString>THIS IS THE ULTIMATE
TEST</tns1:TestString></tns1:SimpleEchoRequest></SOAP-ENV:Body></SOAP-
ENV:Envelope>
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
QUERY:
<?xml version="1.0" encoding="utf-8"?><SOAP-ENV:Envelope xmlns:SOAP-
ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://
schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/
XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:tns1="http://MYSERVERName:8001/service/PAASServer"><SOAP-
ENV:Body><tns1:SimpleEchoRequest><tns1:TestString>This is a test of
PAAS</tns1:TestString></tns1:SimpleEchoRequest></SOAP-ENV:Body></SOAP-
ENV:Envelope>
RESULTS:<?xml version="1.0" encoding="utf-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/
envelope/" xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/1999/XMLSchema" xmlns:SOAP-ENC="http://
schemas.xmlsoap.org/soap/encoding/" xmlns:PAASServer="http://
MYSERVERName:8001/service/PAASServer"><SOAP-
ENV:Body><PAASServer:SimpleEchoResults><PAASServer:SimpleEchoResult>This
is a test of PAAS</PAASServer:SimpleEchoResult></
PAASServer:SimpleEchoResults></SOAP-ENV:Body></SOAP-ENV:Envelope>
**************2nd REQUEST Using XML*************
RESULTS:<?xml version="1.0" encoding="utf-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/
envelope/" xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/1999/XMLSchema" xmlns:SOAP-ENC="http://
schemas.xmlsoap.org/soap/encoding/"><SOAP-ENV:Body><SOAP-
ENV:Fault><SOAP-ENV:faultcode>CLIENT</SOAP-ENV:faultcode><SOAP-
ENV:faultstring>Malformed Request -- not understood ''</SOAP-
ENV:faultstring><SOAP-ENV:detail><e:errorInfo
xmlns:e="urn:TclErrorInfo"><errorCode>Server MALFORMED_REQUEST
domDoc00D010C0</errorCode><stackTrace></stackTrace></e:errorInfo></
SOAP-ENV:detail></SOAP-ENV:Fault></SOAP-ENV:Body></SOAP-ENV:Envelope>
---------------------------------------------------------
Mike
Hi Mike,
The only thing I see different is the xmlns attributes. This could be
causing problems. There's a Tcl SOAP API that should make this a
little easier for you: http://tclsoap.sourceforge.net/#methods. The
only thing is you'll have to read the published WSDL usually found on
the web server thats hosts the SOAP webservice to find the following
parameters used in TclSOAP -uri, -proxy, -params, and -name. -uri is
the XML namespace to use. -proxy is the end point URL to connect to,
params are the remote method parameters, and -name is the remote
method name to call.
.
- References:
- Tcl - Soap - Loosing My Mind
- From: BMWM3LUV
- Tcl - Soap - Loosing My Mind
- Prev by Date: Re: passing exec a cat, sed and grep command sequence
- Next by Date: Re: passing exec a cat, sed and grep command sequence
- Previous by thread: Tcl - Soap - Loosing My Mind
- Next by thread: Can't get this regular expression figured out
- Index(es):
Relevant Pages
|