dcsimg
A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: [RESOLVED] Parsing a SOAP Response

  1. #1
    Bald By Choice jasondefra's Avatar
    Join Date
    Mar 2008
    Location
    Wisconsin, USA
    Posts
    205

    resolved [RESOLVED] Parsing a SOAP Response

    Hi all, I have two web services: one fetches a password, the other builds and sends an email. In order for the email to build I need to give it the password from the first service. My send mail service tests fine, but what I'm having problems with is parsing out the service response of the password request (so I can pass that variable to the second web service).

    Here's the code I currently have:

    PHP Code:
    private function done(serviceResponse:XML):void {
      var 
    mystring:String=serviceResponse.toString();
      var 
    myxml:XML;
      
    myxml=new XML(mystring);
      
    trace (myxml);

    The above code traces this:

    <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <soap:Body>
    <getSendMailPasscodeResponse xmlns="http://www.omittedurl.com/webservices/">
    <getSendMailPasscodeResult>passwordVariableIsHer e</getSendMailPasscodeResult>
    </getSendMailPasscodeResponse>
    </soap:Body>
    </soap:Envelope>


    I can't figure out how to parse this so I can get the 'passwordVariableIsHere' to trace on it's own (if I can get that, then I can subsequently attach it to a variable).

    Thanks.

    ~Jason
    Follow me on Twitter: http://twitter.com/jasondefra

  2. #2
    Bald By Choice jasondefra's Avatar
    Join Date
    Mar 2008
    Location
    Wisconsin, USA
    Posts
    205
    I got it working, though I'm sure there's a much better way to do it. Here's the trace statement:

    PHP Code:

    trace
    (xml.firstChild.childNodes[1].childNodes[1].childNodes[1].childNodes[0]); 
    However, I still don't know how to reference the nodes by name, and am confused as to why it is childNodes[1] instead of childNodes[0] like it would be in Flash 8/AS2. I'll admit I'm still a bit of a noob when it comes to XML parsing in AS3, but if anyone has any tips I would appreciate it. Thanks!

    ~Jason
    Follow me on Twitter: http://twitter.com/jasondefra

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center