Welcome, Guest
  • Author Topic: XML from WebServiceConnector is tracing "[object Object]"  (Read 2864 times)

    andy

    • Server what's that
    • *
    • Posts: 14
      • View Profile
      • Email
    I'm using the WebServiceConnector in CS3 to load some XML. The trouble is, whenever I trace out the XML, all I get is "[object Object]".

    Here's the code I'm using:


    import mx.services.*;
    import mx.data.components.WebServiceConnector;

    var wscListener:Object = new Object();
    wscListener.result = function(evt:Object) {
       resultsXML = new XML(evt.target.results);
       resultsXML.ignoreWhite = true;
       trace(resultsXML);
    }

    var wsConn:WebServiceConnector = new WebServiceConnector();
    wsConn.WSDLURL = "http://my_ws_URL.asmx?wsdl";
    wsConn.addEventListener("result",wscListener);

    // Button action
    button.onRelease = function() {
       wsConn.operation = "Login";
       wsConn.params = [loginPanel.UN.text, loginPanel.PW.text]; // Username and password from login form
       wsConn.trigger();   
    }



    Any help here would be greatly appreciated, I'm really tearing my hair out on this one. I'm sure the answer is buried away on one of these threads, but I'd be grateful if someone could flag it up.

    Cheers

    Jorge Solis

    • Global Moderator
    • Systems Administrator
    • *****
    • Posts: 14616
      • View Profile
    Try

    trace(evt.target.results)

    To see if you get something meaningful

    Jorge

    andy

    • Server what's that
    • *
    • Posts: 14
      • View Profile
      • Email
    Same outcome, I'm afraid - traces "[object Object]".


    Jorge Solis

    • Global Moderator
    • Systems Administrator
    • *****
    • Posts: 14616
      • View Profile
    Now inspect the objetc, instead of

    trace(resultsXML)

    Use

    for(var i in resultsXML) trace(i+':'+resultsXML)

    Jorge

    andy

    • Server what's that
    • *
    • Posts: 14
      • View Profile
      • Email
    Now inspect the objetc, instead of

    trace(resultsXML)

    Use

    for(var i in resultsXML) trace(i+':'+resultsXML)

    Jorge

    Returns:

    unregisterNamespace:[object Object]
    registerNamespace:[object Object]
    getQNameFromString:[object Object]
    getAttributeByQName:[object Object]
    loadNSMappings:[object Object]
    getNamespaceURI:[object Object]
    getLocalName:[object Object]
    getPrefix:[object Object]
    getQualifiedName:[object Object]
    setValue:[object Object]
    setChildValue:[object Object]
    getQName:[object Object]
    namespaceURI:[object Object]
    localName:[object Object]
    prefix:[object Object]
    previousSibling:[object Object]
    parentNode:[object Object]
    nodeValue:[object Object]
    nodeType:[object Object]
    nodeName:[object Object]
    nextSibling:[object Object]
    lastChild:[object Object]
    firstChild:[object Object]
    childNodes:[object Object]
    attributes:[object Object]
    getPrefixForNamespace:[object Object]
    getNamespaceForPrefix:[object Object]
    toString:[object Object]
    hasChildNodes:[object Object]
    appendChild:[object Object]
    insertBefore:[object Object]
    removeNode:[object Object]
    cloneNode:[object Object]
    getElementsByLocalName:[object Object]
    getElementsByReferencedName:[object Object]
    getElementsByQName:[object Object]
    nscount:[object Object]
    xmlDecl:[object Object]
    status:[object Object]
    loaded:[object Object]
    ignoreWhite:[object Object]
    docTypeDecl:[object Object]
    contentType:[object Object]
    addRequestHeader:[object Object]
    getBytesTotal:[object Object]
    getBytesLoaded:[object Object]
    onData:[object Object]
    onLoad:[object Object]
    sendAndLoad:[object Object]
    send:[object Object]
    load:[object Object]
    parseXML:[object Object]
    createTextNode:[object Object]
    createElement:[object Object]

    Thanks for taking the time to look at this, btw


    Jorge Solis

    • Global Moderator
    • Systems Administrator
    • *****
    • Posts: 14616
      • View Profile
    So you get an empty XML, probably the XML is malformed, load the XML directly in the browser to see if you get some error

    Jorge

    andy

    • Server what's that
    • *
    • Posts: 14
      • View Profile
      • Email
    We have checked the XML, and it seems to be valid.

    One avenue I did explore was the use of SOAPCall.doDecoding, which aparrently can decode returned WS objects into useable XML; but in all the examples I can find, the WebService seems to be called in a different way to the method I'm using, and implementing it it hasn't been as simle as dropping in the line of code.

    Ronald Wernecke

    • Global Moderator
    • Systems Administrator
    • *****
    • Posts: 6203
      • View Profile
      • Professional Support
      • Email
    object Object is OK.
    It is allready a XML-Object.

    You have to read it with the XML functions childNode, getChild, getNextChild etc. - see manual for details
    happy flashing
    8)
    Ronald

    andy

    • Server what's that
    • *
    • Posts: 14
      • View Profile
      • Email
    A little belated, this, but I do hate it when I come across threads where no outcome is posted.

    In the end, I used this method:

    Code: [Select]
    var pc1:PendingCall = wsConn.TrainingLogin(loginPanel.username.text, loginPanel.password.text);
    pc1.onResult = function():Void {
    //Success
    trainingLoginResultsLoaded(pc1.response);
    }

    To be honest I am not up to speed on the differences between WebServiceConnector and PendingCall (the solution was proposed by another coder who had used it successfully), and I don't know why the XML returned by this method should have been more accessible. I'm glad it worked, though; and in the interests of furthering my understanding, I'd would be grateful if anyone could shed some light on why it worked!

    Jorge Solis

    • Global Moderator
    • Systems Administrator
    • *****
    • Posts: 14616
      • View Profile
    The PendingCall (not used anymore in AS3) sets an onResult and onFault callbacks and was used for asynchronous calls (not only webservices, but remoting) It's not related to what you get as a result, and also not related to be accesible or not.
    In your case, the trainingLoginResultsLoaded should probably parse the XML returned by your service, that's it

    Jorge