The prefix is specified as an argument to the Namespace constructor.
The Namespace variable name (I used "soapenv") does not have to be the
same as the prefix.  Also note the namespace operator :: comes after the
.

 

This should work:

 

var env:XML = new XML(ENVELOPE.toString());

var soapenv:Namespace = new Namespace

("soap-env", "http://schemas.xmlsoap.org/soap/envelope/";);

env.soapenv::Header.header1 = "foo";

env.soapenv::Body.request1 = "bar";

 

-Peter

 

________________________________

From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of Shannon
Sent: Tuesday, December 12, 2006 8:56 PM
To: [email protected]
Subject: [flexcoders] soap-env Namespace problem

 

This code works just fine:

var envelope:XML = <soap-env:Envelope
xmlns:tpro="http://aplaud.com/ns/0.1/tts/profile
<http://aplaud.com/ns/0.1/tts/profile> "
xmlns:tf="http://aplaud.com/ns/0.1/tts/format
<http://aplaud.com/ns/0.1/tts/format> "
xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/
<http://schemas.xmlsoap.org/soap/envelope/> ">
<soap-env:Header>{SomeHeadXML}</soap-env:Header>
<soap-env:Body>{SomeBodyStuff}</soap-env:Body>
</soap-env:Envelope>;
var url:String = "http://my_domain/bleh.php <http://my_domain/bleh.php>
";
var callback:Function = handleBlehResponse;
ur.method = URLRequestMethod.POST;
ur.url = url;
ur.data = envelope; 
ur.requestHeaders.push(RH);
var ul:URLLoader = new URLLoader(ur);
ul.addEventListener(Event.COMPLETE,callback);
ul.load(ur);

But I have many of these to write so I would like to place the soap-
env in a CONSTANT (in the super) and add HEADER and BODY nodes later. 

Something like this...

static public var ENVELOPE:XML = <soap-env:Envelope
xmlns:tpro="http://aplaud.com/ns/0.1/tts/profile
<http://aplaud.com/ns/0.1/tts/profile> "
xmlns:tf="http://aplaud.com/ns/0.1/tts/format
<http://aplaud.com/ns/0.1/tts/format> "
xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/
<http://schemas.xmlsoap.org/soap/envelope/> ">
<soap-env:Header></soap-env:Header>
<soap-env:Body></soap-env:Body>
</soap-env:Envelope>;

var env = new XML(ENVELOPE.toString());
var soap-env:Namespace = new Namespace
("http://schemas.xmlsoap.org/soap/envelope/
<http://schemas.xmlsoap.org/soap/envelope/> ");
env::soap-env.Header = SomeHeadStuff;
env::soap-env.Body = SomeBodyStuff;

I think the trouble is with namespaces, but I have no idea how to 
specify a hyphenated namespace "soap-env" or if I even need to.

TIA

 

Reply via email to