Re: Tcl - Soap - Loosing My Mind



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.

.



Relevant Pages

  • Re: FasterCSV - varying headers
    ... user's headers as if they followed my original specifications exactly. ... 2: Product Price ... # The following is a simple menu selection for columns. ... puts "d: Done" ...
    (comp.lang.ruby)
  • Tcl - Soap - Loosing My Mind
    ... (See XML Output) ... lappend headers SOAPAction PAASServer:SimpleEcho ... append xml $soapyxml ... puts "@@@@@@@@@@@@5 XML@@@@@@@@@@@@@@@@@@@@@@" ...
    (comp.lang.tcl)
  • Re: How to convert plain ASCII text file to RTF?
    ... I was just trying to adapt the example in the man pages: ... To extract all the C sources and headers from an archive named ... > tar -xvf somefile.tar ... So as Steven J Masta said earlier, it just puts ...
    (comp.unix.bsd.freebsd.misc)
  • FasterCSV - varying headers
    ... programming in general. ... user's headers as if they followed my original specifications exactly. ... attr_accessor:clientid ... puts "What is the client ID?" ...
    (comp.lang.ruby)
  • Re: InsertXml - not getting the same result as opening xml file
    ... I will make a suggestion to MS along the lines you have suggested. ... insert the XML file: ... > a template which contains the headers and footers, ...
    (microsoft.public.office.developer.vba)