×

Discussion Board

Page 1 of 2 12 LastLast
Results 1 to 15 of 16
  1. #1
    Regular Contributor
    Join Date
    Jan 2007
    Posts
    135

    Flash and web services

    hello,

    I am trying to call web services using flash lite 2.1 and even 3.0 and I have been partially successful.

    my problem relates to the decoding of "complex" objects in the web service response. For any response object defined as a string, it works fine.

    For more complex object and from the example I have seen , I was expecting to access the defined parameters like:
    result.param1, result.param2
    if the response type contains multiple elements which names are param1, param2.

    Has anybody been successful in decoding complex objects in the web service response ?

    thanks in advance for your help
    Jean-philippe
    jean-philippe

  2. #2
    Product Specialist
    Join Date
    Jun 2003
    Location
    UK
    Posts
    191

    Re: Flash and web services

    Hi Jean-philippe,

    When you say "For any response object defined as a string, it works fine". Are you saying that you can in fact trace the string containing the object?

    What happens if you cast the string as an object? var obj:Object = Object(myString);?

    You might find it easier to use SWX if you are creating the web feed too.
    www.swxformat.org

    Mark
    Mark Doherty
    Developer Evangelist
    Adobe Systems, Mobile and Devices EMEA

  3. #3
    Regular Contributor
    Join Date
    Jan 2007
    Posts
    135

    Re: Flash and web services

    if the logoutResponse type in the WSDL (for a logout web service request) contains a unique string
    <element name="logoutResponse">
    <complexType>
    <sequence>
    <element name="status" type="xsd:string"/>
    </sequence>
    </complexType>
    </element>

    then you can retrieve the response with the following code:

    resultObj = accessService.logout(Token, "user0");
    accessService.onLoad = trace("loading");
    resultObj.onResult = function(result) {
    trace (result); --> (display the returned string) }


    however if the web service returns a more complex type like
    I]<element name="logoutResponse">
    <complexType>
    <sequence>
    <element name="status" type="xsd:string"/>
    <element name="ref" type="xsd:string"/>
    </sequence>
    </complexType>
    </element>[/I]

    I tried the following code;

    resultObj = accessService.logout(Token, "user");
    accessService.onLoad = trace("loading");
    resultObj.onResult = function(result) {
    trace (result.status); --> (display "undefined") }


    any suggestion to retrieve the two parameters ?
    Have a nice day
    Jean-philippe
    jean-philippe

  4. #4
    Product Specialist
    Join Date
    Jun 2003
    Location
    UK
    Posts
    191

    Re: Flash and web services

    Hi Jean-philippe,

    Thanks for the detail, so it looks like you simply need to turn the response into an XML object. Then you can parse the object for the relevant data.

    I have some XML examples on my blog in the examples section where you'll find lots of little code snippets. Look for the context-aware garden sample which handles XML. Please do take care when dealing with XML as it does bloat the memory usage, use it sparingly.

    Regards,

    Mark

    http://www.flashmobileblog.com
    Mark Doherty
    Developer Evangelist
    Adobe Systems, Mobile and Devices EMEA

  5. #5
    Regular Contributor
    Join Date
    Jan 2007
    Posts
    135

    Re: Flash and web services

    well I am not sure to understand what to do in order to decode the result.

    the response includes:
    <status>200</status><auc>gam10+cft+icnv</auc><userid>gam10</userid>

    I tried this:
    resultObj.onResult = function(result:String) {
    var xml = new XML(result);
    var aNode:XMLNode = xml.childNodes[0];
    //trace(aNode.nodeName.toUpperCase() );
    trace(aNode.toString());
    var aNode1:XMLNode = xml.childNodes[1];
    //trace(aNode.nodeName.toUpperCase() );
    trace(aNode1.toString());
    }

    I get 200 for the first trace and undefined for the other one.


    How do you transform the result object into an xml object ?

    thanks for your help
    Jean-philippe
    jean-philippe

  6. #6
    Product Specialist
    Join Date
    Jun 2003
    Location
    UK
    Posts
    191

    Re: Flash and web services

    Hey,

    So if your result is:

    <status>200</status>
    <auc>gam10+cft+icnv</auc>
    <userid>gam10</userid>

    then you need to add some parent node to enable the tree to be built.

    var xml:XML = new XML("<root><status>200</status><auc>gam10+cft+icnv</auc><userid>gam10</userid></root>");

    if(xml.hasChildNodes()==true)
    {
    if(xml.firstChild.childNodes[0].nodeName=="status");
    {
    trace(xml.firstChild.childNodes[0].firstChild.nodeValue);
    }
    if(xml.firstChild.childNodes[1].nodeName=="auc");
    {
    trace(xml.firstChild.childNodes[1].firstChild.nodeValue);
    }
    if(xml.firstChild.childNodes[2].nodeName=="userid");
    {
    trace(xml.firstChild.childNodes[2].firstChild.nodeValue);
    }
    }
    stop();
    Mark Doherty
    Developer Evangelist
    Adobe Systems, Mobile and Devices EMEA

  7. #7
    Regular Contributor
    Join Date
    Jan 2007
    Posts
    135

    Re: Flash and web services

    No it is not the content of the result object. it is the structure of the soap body in the 200 ok message. But I get nothing in teh result except the value of the <status> element.

    is anybody aware of flash limitation to decode multiple parameter in teh response?

    Thanks
    Jean-philippe
    jean-philippe

  8. #8
    Product Specialist
    Join Date
    Jun 2003
    Location
    UK
    Posts
    191

    Re: Flash and web services

    You said, "How do you transform the result object into an xml object ?". the above example shows how to transform strings into XML.

    If you want to work with webservices then you will have to work within the confines of Flash. Right now it supports the loading of Key Value pairs, XML and of course movieclips which can be created server side (SWX).

    To work with webservices then you will have to ether parse the responses into something Flash understands or create a proxy server.

    What do you mean by "decode multiple parameter in teh response" ?

    Mark
    Mark Doherty
    Developer Evangelist
    Adobe Systems, Mobile and Devices EMEA

  9. #9
    Regular Contributor
    Join Date
    Jan 2007
    Posts
    135

    Re: Flash and web services

    if I get

    <status>200</status>
    <auc>gam10+cft+icnv</auc>
    <userid>gam10</userid>
    in the SOAP body of the web service response, that means that the response contains 3 parameters i.e. status, auc and userid in the response: I want to access them

    the result is an object when I issue a trace(result) I get 200 i.e. the value of the first parameter but no way to access the others. the content of the response is not a well formed XML as there is nothing more than what is described without root element. Does that mean that I cannot use the webservice class on flash lite for my web service

    I tried the generic proxy example but until now without success but that may be a probleme at the php level.
    the web service also uses import of xsd types. It may not be supported by flash lite.

    thanks for your help
    Jean-philippe
    jean-philippe

  10. #10
    Registered User
    Join Date
    Jul 2008
    Posts
    6

    Re: Flash and web services

    Hi Jean-philippe,

    You dont need to add a root node to your XML, the code below seems to work fine (obviously replace the XML string with your web service reply):

    var xml:XML = new XML("<status>200</status><auc>gam10+cft+icnv</auc><userid>gam10</userid>");
    var childNodes:Array = xml.childNodes;
    var nodeValue0:String = childNodes[0].firstChild.nodeValue;
    var nodeValue1:String = childNodes[1].firstChild.nodeValue;
    var nodeValue2:String = childNodes[2].firstChild.nodeValue;
    trace("xml = "+xml);
    trace("childNodes = "+childNodes);
    trace("childNodes[0] = "+childNodes[0]);
    trace("childNodes[1] = "+childNodes[1]);
    trace("childNodes[2] = "+childNodes[2]);
    trace("nodeValue0 = "+nodeValue0);
    trace("nodeValue1 = "+nodeValue1);
    trace("nodeValue2 = "+nodeValue2);


    Regards
    Paul

  11. #11
    Regular Contributor
    Join Date
    Jan 2007
    Posts
    135

    Re: Flash and web services

    Paul and Mark, definitly I appreciate your help

    unfortunately when I talk about:
    "<status>200</status><auc>gam10+cft+icnv</auc><userid>gam10</userid>", it is what I see in the ethereal trace of the web service response (the soap body), not the object returned by the webservice class. when I issue a trace(result), I see 200 i.e. the value of the first parameter and nothing else. So my conclusion is that the result object doesn't reference the content of the soap body but deliver the decoding of the first parameter. :-)

    From adobe.

    <<<To send complex data, use Flash Remoting. Complex data in output parameters, on the other hand, does not cause any problems.>>>(http://www.adobe.com/devnet/flash/ar...rvices_03.html)
    so I don't know where is the problem


    has anybody looked at what is presented here
    http://www.adobe.com/devnet/flash/ar...rvices_06.html

    thanks Jean-philippe
    jean-philippe

  12. #12
    Product Specialist
    Join Date
    Jun 2003
    Location
    UK
    Posts
    191

    Re: Flash and web services

    Hi Jean-philippe,

    Can you cast the object to a String and then trace it out?

    You could also change the publishing settings to work in Flash 8 and use the debugger :-)

    var resultStr = String(result);
    trace(resultStr);
    Mark Doherty
    Developer Evangelist
    Adobe Systems, Mobile and Devices EMEA

  13. #13
    Regular Contributor
    Join Date
    Jan 2007
    Posts
    135

    Re: Flash and web services

    yep I've got "200"
    jean-philippe

  14. #14
    Product Specialist
    Join Date
    Jun 2003
    Location
    UK
    Posts
    191

    Re: Flash and web services

    How frustrating.. Can you create a simple test case and send it to me please?

    mdoherty at adobe dot com

    Thanks,

    Mark
    Mark Doherty
    Developer Evangelist
    Adobe Systems, Mobile and Devices EMEA

  15. #15
    Regular Contributor
    Join Date
    Jan 2007
    Posts
    135

    Re: Flash and web services

    Mark,

    that's very of you to offer your help. I eventually found what's working and what's not.

    what's working:
    the response to a web service request is defined as a single element/ object (the object can be a complex structure)

    what's not working:
    the response is defined as multiple elements

    As I control the web service I changed the wsdl

    from/

    <element name="loginResponse">
    <complexType>
    <sequence>
    <element name="status" type="xsd:string"/>
    <element name="auc" type="xsd:string"/>
    <element name="userid" type="xsd:string"/>
    </sequence>
    </complexType>
    </element>

    to:

    <element name="loginResponse">
    <complexType>
    <sequence>
    <element name="result" type="tns:loginresp"/>
    </sequence>
    </complexType>
    </element>
    <complexType name="loginresp">
    <sequence>
    <element name="status" type="xsd:string"/>
    <element name="auc" type="xsd:string"/>
    <element name="userid" type="xsd:string"/>
    </sequence>
    </complexType>


    then I was able to get the xml schema <result><status>200</status>....</result> as the returned object and able to decode it using the XML class.

    Have a nice day
    Jean-philippe
    jean-philippe

Similar Threads

  1. Replies: 0
    Last Post: 2008-03-31, 18:51
  2. Ask the Expert: Risalmin on Web Runtime and Flash
    By Nokia Ron in forum [Archived] Flash Lite on Nokia Devices
    Replies: 0
    Last Post: 2008-03-31, 18:49
  3. S60 3rd Edition - IMEI retrival via Flash Lite
    By mikebrant in forum [Archived] Flash Lite on Nokia Devices
    Replies: 1
    Last Post: 2008-03-05, 23:55
  4. N73: Web browser vs Services web browser
    By mfarooqkhan78 in forum Symbian Networking & Messaging (Closed)
    Replies: 1
    Last Post: 2006-11-15, 17:26

Posting Permissions

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