ArrayCollection to webservices

OK i know how to get the result i want and bind it to a
datagrid.
I know how to send simple variables to my webservice (built
in coldfusion) and get a result back
but I dont know how to send an arrayCollection from flex to a
webservice. I know flash remoting is supposed to be better, but I
dont have root access to the server.
anyone point me to a resource that will walk me through
this?

can u explain abt this line
var plist:ArrayCollection = e .
result.simRingNumberList;

Similar Messages

  • Mx: webservice; Arraycollections; Message Board

    Hello. New to Flex 2 and having a spot of trouble. Creating a
    message board as a sub section of a flex app. and need advice on
    how to go about this. Not sure if I should be using data grids or
    even how to connect to a remote server (via webservice or
    arraycollection).. If there are any flex applications that I may
    see as an example or if there is any help that can advise me, it
    would be much appreciated. Thank you.

    I did further research, maybe this will give you a clue:
    I browsed into code of Message Board taskflow (peopleconnections-view.jar -> oracle.webcenter.peopleconnections.wall.controller.taskflows.WallViewer.xml). The first activity in this taskflow is method call - checkGroupSpaceName, which execures method bound as #{pageFlowScope.WCPeopleConnWallViewerBean.checkGroupSpaceName}
    I decompiled oracle.webcenter.peopleconnections.wall.internal.view.WallViewerBean class. In checkGroupSpaceName method there is a line
    scope = ServiceContext.getContext().findScope(spaceName)
    On the jspx page where Message Boards taskflow is added, I've put a line:
    <af:outputText value="#{serviceCtx.allScopes}" id="pt_ot2"/>
    which displays as output:
    [Scope[name=defaultScope, guid=s8bba98ff_4cbb_40b8_beee_296c916a23ed]]
    So clearly Webcenter does not "see" the scope of any space, especially it doesn't see "myspace" scope.
    Any ideas what do do?

  • How to convert an array collection instance to a complex object for interaction with webservice

    Hi there,
    I have a stubborn problem that I am trying to work out the best way to solve the problem.  I am interacting with a WebService via HTTPService calling a method called find(String name) and this returns me a List of ComplexObjects that contain general string and int params and also lists of other Complex Objects.  Now using the code:
    ArrayCollection newOriginalResultsArray = new ArrayCollection(event.result as Array)
    flex converts my complex objects results to an arraycollection so that I can use it in datagrids etc.  Now up until this part is all good.  My problem is when getting a single instance from the results list, updating it by moving data around in a new datagrid for example - I want to interact with the webservice again to do an create/update.  This is where I am having problems - because these webservice methods require the complex object as a parameter - I am struggling to understand how I can convert the array collection instance back to my complex object without iterating over it and casting it back (maybe this is the only way - but I am hoping not).
    I am hoping that there is a simple solution that I am missing and that there is some smart cookie out there that could provide me with an answer - or at least somewhere to start looking. I guess if I have no other alternative - maybe I need to get the people who built the service to change it to accept an array - and let them do the conversion.
    Any help would be greatly appreciated.
    Bert

    Hi Bert,
    According to my knowledge you can use describeType(Object) method which will return an XML... That XML will contain Properties and values just iterate through the XML and create a new Object..   Probably u can use this method...
    public function getObject(reqObj:Object,obj:Object,instanceName:String,name:String=null,index:int=-1):Obj ect
                if(!reqObj)
                    reqObj = new Object();
                var classInfo:XML = describeType(obj);
                var className:String = instanceName;
                if(name!=null)
                    className=name+"."+className;
                if(index!=-1)
                    className=className+"["+index+"]";
                for each (var v:XML in classInfo..accessor)
                    var attributeName:String=v.@name;
                    var value:* = obj[attributeName]
                    var type:String = v.@type;
                    if(!value)
                        reqObj[className+"."+attributeName] = value; 
                    else if(type == "mx.collections::ArrayCollection")
                        for(var i:int=0;i<value.length;i++)
                            var temp:Object=value.getItemAt(i);
                            getReqObject(reqObj,temp,attributeName,className,i);
                    else if(type == "String" || type == "Number" || type == "int" || type == "Boolean")
                        reqObj[ className+"."+attributeName] = value; 
                    else if (type == "Object")
                        for (var p:String in value)
                            reqObj[ className+"."+attributeName+"."+p] = value[p];
                    else
                        getReqObject(reqObj,value,attributeName,className);
                return reqObj;
    Thanks,
    Pradeep

  • How to put the return data from webservice to a text field

    Dear All ,
    I created a function module for calculating the square of the input given  and created a webservice using the create webservice option available for function modules.
    function module:-
    FUNCTION ZJK_FLEX_TEST.
    *"*"Local Interface:
    *"  IMPORTING
    *"     VALUE(DATA) TYPE  ZSLNO OPTIONAL
    *"  EXPORTING
    *"     VALUE(DATA1) TYPE  ZSLNO
    *"  TABLES
    *"      IT_DAT STRUCTURE  ZWBSER OPTIONAL
    data: wa_dat LIKE LINE OF it_dat.
    data1 = DATA * data.
    wa_dat-results =  data * data .
    APPEND wa_dat TO it_dat.
    ENDFUNCTION.
    and i passed the it_dat in table fields and data1 in the export paramenters of FM.
    but in the flex i am not getting the table values. but i am able to get the data1 value. but the problem is . I am getting it as an XML format.
    <s0:ZJK_FLEX_TEST.Response xmlns:s0="urn:sap-com:document:sap:rfc:functions" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
      <DATA1>0000025</DATA1>
    </s0:ZJK_FLEX_TEST.Response>
    so how to set the value of data1 to my text field in the flex .

    Hi Jay,
    resultFormat="e4x" will give you resultset in XMLListCollection otherwise resultset will be an ArrayCollection.
    For your example try with this statement after web service result:
    txtInput.text = ws.ZJK_FLEX_TEST.lastResult.DATA1.toString();
    where ws is id for web srvc and txtinput is a simple textInput control UI.
    I hope this will solve your query.
    Regards,
    Vivek

  • Adding and "empty" row to an ArrayCollection

    Hi,
    I've got an ArrayCollection named CompanyList which has been
    populated by a webservice.
    Each "row" structure is the same.
    I want to add a new row with the same elements as an existing
    row.
    I'm trying the followng, but of course the new row is being
    bound to the first row, which is powerfull... just not what I want!
    I'm hoping of course there's a simple way to do this :-)
    Can anyone enlighten me?
    var newRow:Object = companyList[0];
    companyList.addItem(newRow);
    companyList[companyList.length - 1].pkey = '0';
    companyList[companyList.length - 1].name = '';

    I think you need to do the following:
    var newRow:Object = {};
    companyList.addItem(newRow);
    companyList[companyList.length - 1].pkey =
    companyList[0].pkey;
    companyList[companyList.length - 1].name =
    companyList[0].name';

  • How to handle multiple SOAP requests for ArrayCollection initialization?

    Hello.
    I want to initialize some ArrayCollection with objects, which receive field values via SOAP requests (in getUdfValuePrj function).
    for (var i:int=0; i < data.length; i++)
      var task:Task=new Task();
      task.laborio = getUdfValuePrj(data[i].id, LABORIOUSNESS);
    tempTaskArray.addItem(task);
    Here is my WebService:
    private function initWebServices(wsdl:String):void
      _udfWs = new WebService();
      _udfWs.wsdl = wsdl;
      _udfWs.getTaskUDFValue.addEventListener("result",
      getTaskUDFValueResult);
      _udfWs.getTaskUDFValue.addEventListener("fault", handleFault);
      _udfWs.loadWSDL();
    The question is, how functions getUdfValuePrj and getTaskUDFValueResult should look like?
    I think that is no good:
    private function getTaskUDFValueResult(event:ResultEvent):String
      _udfValue = event.result as String;
    private function getUdfValuePrj (taskId:String, udfCaption:String):String
      _udfValue = "Loading...";
      _udfWs.getTaskUDFValue (taskId,udfCaption);
      while (_udfValue == "Loading...")
      return _udfValue;

    There is no any ideas, or may be you don't understand me?

  • Flash Builder 4.6 - results of web service into arrayCollection?

    Hello,
    I'm coming from Flex 2 environment where it seemed easy to create an array collection from the data returned from my webservice using ArrayCollection and ArrayUtil.
    I've since switched over to flash builder 4 and am using the data services wizard to retrieve my data.  My problem is once i can retrieve my data, how can i access and manipulate it (besides dragging it into a datagrid etc).
    For example, i'd like to get the record count of items returned (ie - 32 items found).  When using an Array Collection & flex 2 i was able to simply access the ac.length parameter.
    Another example would be if i needed to access a specific item in the data (ie - username).  I previously (flex 2) was able to use something like ac.getItemAt(0).USERNAME
    Is the data returned from the webservice already in some type of array?  Can anybody shed some light for me?  I would appreicate any help.
    thank you.

    Have a resultHandler and in that resultHandler
    assign the returned to a ArrayCollection variable,
    assign your datagrid's dataprovider to the ArrayCollection
    data comes back as generic objects

  • Calling functions from SOAP webservice. Can't access webservice functions.

    Hi flex gurus,
    I am quite new to flex. I am working on an flex application where I am trying to remotely invoke a SOAP webservice which is a wsdl file from Adobe flex 4.6.
    I have authenticated the webservice(Basic Authentication Done) and got access to wsdl but I am unable to call the functions in it. I just want to pass the username and password for the user login to the service function which will give me the data useful for my application, but nothing is returned when the webservice function is called.
    I am totally blocked at this point. Please help me.
    Thanks in advance.

    Below is my code snippet. But nothing is returned from th service, what is the problem???
    <?xml version="1.0" encoding="utf-8"?>
    <s:View xmlns:fx="http://ns.adobe.com/mxml/2009"
            xmlns:s="library://ns.adobe.com/flex/spark" title="CheckWS" >
        <fx:Script>
            <![CDATA[
                import flash.net.drm.AuthenticationMethod;
                import mx.collections.ArrayCollection;
                import mx.messaging.messages.SOAPMessage;
                import mx.rpc.AsyncToken;
                import mx.rpc.events.FaultEvent;
                import mx.rpc.events.ResultEvent;
                import mx.rpc.http.HTTPService;
                import mx.rpc.soap.AbstractWebService;
                import mx.rpc.soap.Operation;
                import mx.rpc.soap.SOAPFault;
                import mx.rpc.soap.SOAPHeader;
                import mx.rpc.soap.SOAPResult;
                import mx.rpc.soap.WebService;
                import mx.rpc.wsdl.WSDLBinding;
                import mx.utils.Base64Encoder;
                public var resultdata:String;
                private function send_data(service:mx.rpc.http.HTTPService):void {
                    var encoder:Base64Encoder = new Base64Encoder();           
                    encoder.insertNewLines = false;           
                    encoder.encode("auth_usrname:auth_pswd");
                    service.headers = {Authorization:"Basic " + encoder.toString()};
                    service.send();
                //protected function soapWS_resultHandler(event:ResultEvent):void
                    // TODO Auto-generated method stub
                    /* var i:int;
                    var webresult:String=event.result.toString();
                    i = 0; */
                    /* var i:int;
                    resultdata = event.result.toString();
                    i = 0;
            ]]>
        </fx:Script>
        <fx:Declarations>
            <!-- Place non-visual elements (e.g., services, value objects) here -->
            <s:HTTPService id="soapWS"
                           url="My_Web_URL?wsdl" result="soapWS_resultHandler(event)" resultFormat="xml" useProxy="false" method="POST">
                <s:request xmlns="">
                    <Username>{username.text}</Username>
                    <Password>{password.text}</Password>
                </s:request>
                <s:result >
                    <![CDATA[
                        var i:int;
                        dgUserRequest.visible = true;
                        var obj:Object = new Object();
                        obj = event.result;
                    //    dgUserRequest.dataProvider = event.result.toString();
                    //    var str:String = new String();
                        resultdata = obj.toString();
                        i = 0;
                    ]]>                                                       
                </s:result>
            </s:HTTPService>
        </fx:Declarations>
        <s:Form x="20" y="10" width="100%">
            <s:FormItem color="blue">
                <s:Label text="Username" />    
                <s:TextInput id="username"/>
            </s:FormItem>
            <s:FormItem color="blue">
                <s:Label text="Password" />    
                <s:TextInput id="password"/>    
            </s:FormItem>
            <s:FormItem color="yellow">
                <s:Button label="Submit" click="send_data(soapWS)"/>
            </s:FormItem>
        </s:Form>
        <s:DataGrid id="dgUserRequest" x="20" y="300"
                     dataProvider="{resultdata}" width="100%">
            <s:columns>
                <s:ArrayList>
                    <s:GridColumn dataField="password" headerText="Password" />
                    <s:GridColumn dataField="username" headerText="User Name"/>
                </s:ArrayList>
            </s:columns>
        </s:DataGrid>
    </s:View>

  • Arraycollection to database

    I have an arraycollection that is populated from a
    webservice. Users can edit all fields and possible every row in teh
    database will need to be modified. I'm trying to find the best way
    to get this data back to coldfusion to modify several database rows
    at once. Should I loop through the rows on the Flex side and make
    several webservice calls to update the database one row at a time?
    Or is there a way to pass the arraycollection back to coldfusion as
    an object and look through it on the server side. Any help
    (including code samples or tutorials) would be greatly appreciated.
    Eric

    David,
    Can't speak for epsnowden, but my main question is how to
    prepare this update on the Flex side. Once I figure out a good way
    to send an array or a long xml string to the CF server, I'm sure I
    can handle it on the ColdFusion side.
    Thanks for the offer, though.
    So to repeat, does anyone know an elegant way to send updates
    to a Flex datagrid back to ColdFusion? For extra credit, I'd prefer
    to only update rows that were changed.
    Thanks,
    Steve

  • Filling a tree with the result of calls to a document/wrapped soap1.1 webservice

    Hi,
    I'm having trouble with filling a tree with the result to
    calls to a document/wrapped soap 1.1 webservice.
    I first declared the webservice in the mxml file as it was in
    the examples and tried to call it with no luck. The fault was it
    wasn't finding the document type for the call's unique parameter. I
    figured out the solution to this, I added a method in the
    webservice declaration having a single element named the same as
    the required parameter, and inside it, the "actual" parameters,
    bound to variables defined elsewhere.
    The reason for wanting the tree to be filled programatically,
    is the potential whole contents of the tree can be about 1.000.000
    nodes. Huge.
    quote:
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="
    http://www.adobe.com/2006/mxml"
    layout="absolute" applicationComplete="initM()">
    <mx:Script>
    <![CDATA[
    import mx.collections.ArrayCollection;
    import mx.controls.Alert;
    import mx.controls.treeClasses.TreeListData;
    [Bindable] public var aParentId:String = null;
    [Bindable] public var aLevel:Number = 0;
    ]]>
    </mx:Script>
    <mx:WebService id="lws" wsdl="
    http://myServer/myContext/myPortURI?WSDL"
    useProxy="false" makeObjectsBindable="true">
    <mx:operation name="getNodes" resultFormat="object">
    <mx:request>
    <getNodesElement>
    <parentId>{aParentId}</parentId>
    <level>{aLevel}</level>
    </getNodesElement>
    </mx:request>
    </mx:operation>
    </mx:WebService>
    <mx:Tree x="0" y="0" width="326" height="100%"
    id="layoutTree" enabled="true" labelField="nodeName">
    <mx:dataProvider>{lws.getNodes.lastResult}</mx:dataProvider>
    </mx:Tree>
    <mx:Script>
    <![CDATA[
    public function initM():void {
    lws.getNodes.send();
    return;
    ]]>
    </mx:Script>
    </mx:Application>
    So, here's the problem:
    1.- In both Java2 and .NET, I've been able to produce sets of
    proxy classes from the webservice wsdl, these include a proxy class
    for the service port and a set of classes for both the call
    parameter types and the call result types. I have not found yet a
    way to do the same with flex2, so I wonder, can I produce the
    required classes for dealing with such a webservice in an automatic
    way with flex2?
    2.- The second problem, is I haven't found a way to make a
    webservice call in sychronous mode, and I can't seem to find a way
    to set the parameters for the subsequent calls to the webservice.
    Is there a way to make a call to such webservice programatically? I
    mean, I've been able to make the first call I need programatically,
    but what if I end up making 2 or more simultaneous calls? I can't
    rely on setting the `variables defined elsewhere` before each call,
    because of possible concurrency issues (calls will be long after
    the 2nd level of the tree), so I wonder if there's a way to make a
    call to such webservice (document/wrapped, soap1.1) passing it the
    parameters programatically. If so, can I just put the parameters or
    do I have to produce the complete enclosure? If I have to produce
    also the enclosure, any hint on how to do so? I will need to pass
    different parentId, level pairs probably triggered by tree events.
    3.- the other problem, finally, is Tree looks quite different
    to me than the Java2 one. In java2, I can easily produce a changing
    model for the tree wich will even handle the calls to the
    webservice as needed (triggered by the tree itself), making it a
    `live model`. If there is a way to produce the same behaviour in
    flex2, I haven't found it yet. Sure, I've only downloaded the trial
    version yesterday, so I may have overlooked some docs or blogs.
    Any hints would be appreciated, specially on programatically
    modifying the tree, and making calls to the webservice changing the
    parameters every time.

    I would re-post to the Flex Data Services forum.

  • Calling WebServices using Flex Builder

    Hello,
    I want to use a WebService in the Flex Builder. I first defined the WebService:
    <mx:WebService id="test" wsdl="http://ld9030.wdf.sap.corp:50050/sap/bc/srt/rfc/sap/ZTP_TEST4?wsdl" result="log(event)" showBusyCursor="true">
    I have 2 importing parameters in the WebService (IText and IText2).
    But in the log-method, I cannot access these parameters:
        private function log(event:ResultEvent):void {
         var test1 = event.result.IText;
    Do you know, how I can access the import parameters?
    Please find attached the wsdl definition.
    Thanks,
    Thomas
      <?xml version="1.0" encoding="utf-8" ?>
    - <wsdl:definitions targetNamespace="urn:sap-com:document:sap:soap:functions:mc-style" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="urn:sap-com:document:sap:soap:functions:mc-style" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    - <wsdl:types>
    - <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:tns="urn:sap-com:document:sap:soap:functions:mc-style" targetNamespace="urn:sap-com:document:sap:soap:functions:mc-style" elementFormDefault="unqualified" attributeFormDefault="qualified">
    - <xsd:element name="TpTest">
    - <xsd:complexType>
    - <xsd:sequence>
      <xsd:element name="IFlag" type="xsd:string" />
      <xsd:element name="IFlag2" type="xsd:string" />
      </xsd:sequence>
      </xsd:complexType>
      </xsd:element>
    - <xsd:element name="TpTestResponse">
    - <xsd:complexType>
    - <xsd:sequence>
      <xsd:element name="EText" type="xsd:string" />
      <xsd:element name="EText2" type="xsd:string" />
      </xsd:sequence>
      </xsd:complexType>
      </xsd:element>
      </xsd:schema>
      </wsdl:types>
    - <wsdl:message name="TpTest">
      <wsdl:part name="parameters" element="tns:TpTest" />
      </wsdl:message>
    - <wsdl:message name="TpTestResponse">
      <wsdl:part name="parameters" element="tns:TpTestResponse" />
      </wsdl:message>
    - <wsdl:portType name="ZTP_TEST4">
    - <wsdl:operation name="TpTest">
      <wsdl:input message="tns:TpTest" />
      <wsdl:output message="tns:TpTestResponse" />
      </wsdl:operation>
      </wsdl:portType>
    - <wsdl:binding name="ZTP_TEST4SoapBinding" type="tns:ZTP_TEST4">
      <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" />
    - <wsdl:operation name="TpTest">
      <soap:operation soapAction="" />
    - <wsdl:input>
      <soap:body use="literal" />
      </wsdl:input>
    - <wsdl:output>
      <soap:body use="literal" />
      </wsdl:output>
      </wsdl:operation>
      </wsdl:binding>
    - <wsdl:service name="ZTP_TEST4Service">
    - <wsdl:port name="ZTP_TEST4SoapBinding" binding="tns:ZTP_TEST4SoapBinding">
      <soap:address location="http://us4419.wdf.sap.corp:50050/sap/bc/srt/rfc/sap/ZTP_TEST4?sap-client=000" />
      </wsdl:port>
      </wsdl:service>
      </wsdl:definitions>

    You can try putting the URL in a var as the next example:
    private var wsdl:String = "http://sapbdo5.bdo-argentina.com:8002/sap/bc/srt/rfc/sap/ZVER_TABLA?wsdl=1.1";
    private var wsdl2:String = "http://sapbdo5.bdo-argentina.com:8002/sap/bc/srt/rfc/sap/ZVER_TABLA?sap-client=600&wsdl=1.1";
              [Bindable] private var datos:ArrayCollection;
              private function retrieve_data():void{
                   //ws.loadWSDL(wsdl);
                                                                    ws.loadWSDL(wsdl2);
                   ws.ZVER_TABLA(txt.text);
              private function handleError(ev:Event):void{
                   Alert.show("Se produjo un error");
              private function handleResult(ev:ResultEvent):void{
                   datos = ev.result.DATA;
         ]]>
    </mx:Script>
    <mx:WebService id="ws" showBusyCursor="true" makeObjectsBindable="true">
         <mx:operation name="ZVER_TABLA" fault="handleError(event)"
         result="handleResult(event)"/>
    </mx:WebService>
    <mx:TextInput id="txt" enter="retrieve_data()" x="10" y="10"/>
    <mx:Button label="Ver datos" click="retrieve_data()" x="178" y="10"/>
    <mx:DataGrid id="dtGrid" horizontalScrollPolicy="auto" dataProvider=""
    verticalScrollPolicy="auto" right="10" bottom="10" top="40" left="10"
    visible="false"/>

  • Webservice returns null values (Flex)

    Hi all,
    I created a webservice in abap,
    (a RFC and a Function Web Service).
    It exports a table type and contains data from a Ztable.
    When i request it from Flex, it returns rows, but they contain NULL values, why ?
    I can request and display bapi webservices that comes with in SapNetweaver trial 7.1 but i cant display my own webservice.
    Result like this;
    result     generated.webservices.ZCUSTOMERS_TT (@2205981)     
         [inherited]     
         [0]     generated.webservices.ZCUSTOMERS (@2362c91)     
              CLIENT     null     
              ID     null     
              NAME     null     
         [1]     generated.webservices.ZCUSTOMERS (@23a4129)     
         [2]     generated.webservices.ZCUSTOMERS (@23a42e1)     
         [3]     generated.webservices.ZCUSTOMERS (@23a41c9)     
    it is true that there are 4 rows in table, but all client, id and name is null
    why ?

    thanks for answer but my problem didint solved.
    My webservice can return normal values like integer or decimal and i can read it from flex.
    but when i try to view tables, i always get null values BUT item count is true :=) i have 4 item in z table and 4 rows returns in array from webservice but NULL values :=).
    I can't return structure as well.
    result     mx.utils.ObjectProxy (@211af29)     
         DEGER     1     
         GS_CUSTOMER     generated.webservices.ZCUSTOMERS (@22ce719)     
              CLIENT     null     
              ID     null     
              NAME     null     
         GT_CUSTOMER     mx.collections.ArrayCollection (@210cd01)     
              [inherited]     
              [0]     generated.webservices.ZCUSTOMERS (@22cef61)     
                   CLIENT     null     
                   ID     null     
                   NAME     null     
              [1]     generated.webservices.ZCUSTOMERS (@22ced31)     
              [2]     generated.webservices.ZCUSTOMERS (@22cedd1)     
              [3]     generated.webservices.ZCUSTOMERS (@22cea11)     
              source     Array (@22687e9)     
         object     Object (@22ce8a9)     
         type     null     
         uid     "723117ED-66EC-C93B-9E66-C0FD4F01246C"     
         ZCUSTOMER_TT     generated.webservices.ZCUSTOMERS_TT (@22eb941)     
    What do you use, when declaring variables ?
    Like or type or ref to ? Can it be a problem ?
    here is my function export inteface.
    http://img241.imageshack.us/img241/9258/screenhunter01jun082052.gif
    Edited by: bilen cekic on Jun 8, 2009 8:26 PM

  • Consume SAP WebService Bean with Flex

    Hello,
    I have an flex application thaht call an sap java webservice bean. And this bean have his own xml namespace.
    How can I read this xml in flex ?
    I have done some test with e4x but I found no solution.
    flex :
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
         <mx:Script>
              <![CDATA[
                   import mx.controls.Alert;
                   import mx.collections.ArrayCollection;
                   import mx.rpc.events.ResultEvent;
                   [Bindable] private var liste:ArrayCollection = new ArrayCollection();
                   private function go(event:Event):void {
                        ws.getIViews.send();
                   private function ergebnis(event:ResultEvent):void {
                        for each(var xml:XML in event.result) {
                   liste.addItem(xml.child("pns:link"));
                        //liste = event.result as ArrayCollection;
                   private function fehler(event:Event):void {
                        Alert.show(event.target.toString(),"Fehler");
              ]]>
         </mx:Script>
         <mx:WebService id="ws" wsdl="http://x.xxt.net:50000/xxPortalServices/Config1?wsdl">
              <mx:operation name="getIViews" result="ergebnis(event)" resultFormat="e4x" fault="fehler(event)">
                   <mx:request>
                        <id>
                        </id>                    
                   </mx:request>
              </mx:operation>
         </mx:WebService>
         <mx:Button id="get" click="go(event)" label="hol"/>
         <mx:DataGrid id="dg" dataProvider="" x="61" y="65">
              <mx:columns>
                   <mx:DataGridColumn dataField="link"/>
              </mx:columns>
         </mx:DataGrid>
    </mx:Application>
    XML:
    <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
       <SOAP-ENV:Body>
          <rpl:getIViewsResponse xmlns:rpl="urn:xxPortalServicesVi">
             <rpl:Response xmlns:pns="urn:com.xx.ws.prt">
                <pns:IViewsModelDTO>
                   <pns:link>test123</pns:link>
                   <pns:pcdpath>portal_content/XX</pns:pcdpath>
                   <pns:title>test123</pns:title>
                </pns:IViewsModelDTO>
             </rpl:Response>
          </rpl:getIViewsResponse>
       </SOAP-ENV:Body>
    </SOAP-ENV:Envelope>
    Edited by: Daniel Rothmund on Oct 17, 2009 6:47 PM

    namespace soapen = "http://schemas.xmlsoap.org/soap/envelope/";
    namespace rpl = "urn:xxPortalServicesVi";
    namespace pns = "urn:com.xx.ws.prt" ;
    use namespace soapen;
    somevariable = responsexml.someelement (to read the entire soap body)
    use namespace rpl ;
    somevariable = responsexml.someelement (to read getIViewsResponse)
    use namespace pns ;
    somevariable = responseexml.someelement (to read rpl:Response)
    i haven't tested this, but should work.
    you may also check this
    http://livedocs.adobe.com/flex/3/html/help.html?content=data_access_6.html
    Regards
    Raja
    Edited by: Durairaj Athavan Raja on Oct 26, 2009 8:40 AM

  • WebService, HttpService, namespace

    I've happily been using htttpService calls, connecting to my
    own PHP scripts without many problems. But I now have to use
    services provided by a third party. The services can be used with
    either webService or httpService, but all return xml data with an
    included namespace. (xmlns="
    http://www.example.com/api").
    This seems to make life difficult, and I suspect I'm missing some
    magic ingredient. My biggest problem is populating a datagrid with
    the returned data.
    1. Problems using ArrayCollection
    If I use the webService call, and *don't* use the e4x
    resultFormat, I can populate the grid by setting the dataProvider
    to service.operation.lastResult. This works OK.
    If, instead, I set the dataProvider to an mx:ArrayCollection
    object like below, it doesn't work. No data appears in the grid.
    (This method is illustrated in a number of examples in the docs.)
    <mx:ArrayCollection id="statesAC"
    source="service.operation.lastResult" />
    But if I add an mx:Binding element, and point this to the
    ArrayCollection, it works.
    <mx:Binding source="service.operation.lastResult"
    destination="statesAC" />
    <mx:ArrayCollection id="statesAC" />
    I should be happy that this works, but I'd be more
    comfortable knowing why the middle approach doesn't, especially as
    the docs seem to push this as a preferred approach. Any thoughts?
    2. Problems using XMLListCollection
    This is more troubling, as I'd prefer to use an
    XMLListCollection to populate the grid.
    I've had no success using the webService approach. I can't
    get any of the above techniques for ArrayCollection to work for an
    XMLListCollection. No data appears in the grid.
    I've had more success with httpService and handling and
    converting the XML directly in the service's result event. But this
    also is not straightforward:
    -- I have to set a namespace, using either "default xml
    namespace = ...." or "use namespace ...". Without doing this, I'm
    unable to extract an XMLList from the returned XML. (The XMLList is
    used to make the XMLListCollection for the DataGrid.)
    -- It seems that the DataGrid's dataField properties are not
    recognised when a namespace is being used, even when the
    above-mentioned namespace settings are in place. A labelFunction
    has to be used, but even that is not straightforward.
    Assuming a property name of "Name", this won't work for a
    column setting (no data appear in the column):
    <mx:DataGridColumn dataField="Name" headerText="Name"/>
    This will work:
    public function gridFunction(item:Object,
    column:DataGridColumn):String {
    return item.Name;
    <mx:DataGridColumn headerText="Name"
    labelFunction="gridFunction"/>
    But this won't (although it works with XML that has no
    namespace set):
    public function gridFunction(item:Object,
    column:DataGridColumn):String {
    var fieldName:String = column.dataField;
    return item[fieldName];
    <mx:DataGridColumn headerText="Name"
    labelFunction="gridFunction"/>
    The labelFunction approach, although it displays data, still
    leaves isues with sorting. I'm sure this is not how things are
    meant to be.
    Any insights as to how to make this easier would be
    appreciated, especially with regard to working with
    XMLListCollections.

    From the webservice example.........
    http://www.cflex.net/showfiledetails.cfm?ChannelID=1&Object=File&objectID=582
    Instead of using:
    default xml namespace = "http://www.webservicex.net"; to
    define the default namespace of the Webservice,
    You can automatically find the namespace of the Webservice
    and set it to your default namespace in your result handler. Then
    you would be able to use multiple webservices in multiple result
    handlers.
    [Bindable]private var xmlResult:XML;
    private var wsDefaultNS:Namespace;
    private var wsDefaultNS:Namespace;
    private function onResult(oEvent:ResultEvent):void
    xmlResult = XML(oEvent.result);
    wsDefaultNS = xmlResult.namespace();
    default xml namespace = Namespace(wsDefaultNS);
    I have only been able to get data from webservices into a
    datagrid by the labelfunction. I don't know of another way.

  • Getting ioerrorevent type ioerror during webservice call from mobile app

    Hi,
    I building a mobile employee directory and for that I am using Flash Builder 4.6/AIR 3.1.0. I am using RESTful web service to get XML results and to display on my mobile application. I am getting the same below error when accessing the webservice from mobile app (Android - Galaxy Tab 7 inch).
    Error: [IOErrorEvent type="ioError" bubbles=false cancelable=false eventPhase=2 text="Error # 2032"] URL: http://adfdevp.alshaya.com:7013/RESTEmployeeDetails-EmployeeDetails-co">http://adfdevp.alshaya.com:7013/RESTEmployeeDetails-EmployeeDetails-co ntext-root/jersey/restlabhttp://adfdevp.alshaya.com:7013/RESTEmployeeDetails-http://adfdevp.alshaya.com:7013/RESTEm ployeeDetails-EmployeeDetails-co ntext-root/jersey/restlabEmployeeDetails-context-root/jersey/restlab
    The same code is working in Flash Builder 4.6. I have checked Network Monitor to "Disabled" before deploying to mobile. What am i doing wrong here? I am pasting my code below-
    <?xml version="1.0" encoding="utf-8"?>
    <s:View xmlns:fx="http://ns.adobe.com/mxml/2009" 
       xmlns:s="library://ns.adobe.com/flex/spark" title="HomeView" xmlns:dao="dao.*"
       xmlns:mx="library://ns.adobe.com/flex/mx">
    <fx:Script>
       <![CDATA[
        import mx.collections.ArrayCollection;
        import mx.collections.IList;
        import mx.collections.XMLListCollection;
        import mx.events.FlexEvent;
        import mx.rpc.events.FaultEvent;
        import mx.rpc.events.ResultEvent;
        import mx.rpc.xml.SimpleXMLDecoder;
        import mx.utils.ArrayUtil;
        import valueObjects.EmployeeDetail; 
        [Bindable] 
        private var myXml:XML;
        [Bindable]
        public var resultCollection:IList;
        public function handleXml(event:ResultEvent):void
         var xmlListCollection:XMLListCollection = new XMLListCollection(event.result.children());
         var xmlListCollectionValues:XMLListCollection = new XMLListCollection(event.result.emp.children());
         var resultArray:Array = xmlListCollection.toArray();
         var resultArrayValues:Array = xmlListCollectionValues.toArray();
         var objEmployeeDetails:EmployeeDetail;
         var resultCollection:ArrayCollection = new ArrayCollection();
         var j:int = 0;
         for(var i:int=0;i<resultArray.length;i++){
          objEmployeeDetails = new EmployeeDetail();
          objEmployeeDetails.brand = resultArrayValues[j];
          objEmployeeDetails.division = resultArrayValues[j+1];
          objEmployeeDetails.email = resultArrayValues[j+2];
          objEmployeeDetails.employee_name = resultArrayValues[j+3];
          objEmployeeDetails.employee_number = resultArrayValues[j+4];
          objEmployeeDetails.grade = resultArrayValues[j+5];
          objEmployeeDetails.mobile = resultArrayValues[j+6];
          objEmployeeDetails.position = resultArrayValues[j+7];
          j = j + 8;
          resultCollection.addItem(objEmployeeDetails);
         list.dataProvider = resultCollection;
         //return resultCollection;
        public function handleFault(event:FaultEvent):void
         //Alert.show(event.fault.faultDetail, "Error");              
        protected function sesrchEmployee():void
         xmlRpc.send();
       ]]>
    </fx:Script>
    <fx:Declarations>
       <dao:EmployeeDAO id="srv"/>
       <mx:HTTPService id="xmlRpc" 
           url="http://adfdevp.alshaya.com:7013/RESTEmployeeDetails-EmployeeDetails-co ntext-root/jersey/restlab"
           result="handleXml(event)" 
           fault="handleFault(event)" 
           resultFormat="e4x" showBusyCursor="true">
        <mx:request xmlns="">
         <data>{key.text}</data>
         <data>{key1.text}</data>
        </mx:request>
       </mx:HTTPService>
    </fx:Declarations>
    <s:navigationContent/>
    <s:titleContent>
       <s:VGroup width="100%">
       <s:HGroup width="100%">
        <s:Label top="40" paddingTop="10" paddingRight="13" height="29" text="Employee Name:"/>
        <s:TextInput id="key" width="559"/> 
       </s:HGroup> 
       <s:HGroup width="100%">
        <s:Label height="30" paddingTop="10" text="Employee Number:"/>
        <s:TextInput id="key1" width="100%"/> 
       </s:HGroup> 
       </s:VGroup> 
    </s:titleContent>
    <s:actionContent>
       <s:Button icon="@Embed('assets/search.png')" click="sesrchEmployee()"/>  
    </s:actionContent> 
    <s:List id="list" top="0" bottom="0" left="0" right="0"  
        change="navigator.pushView(EmployeeDetails, list.selectedItem)">
       <s:itemRenderer>
        <fx:Component>
         <s:IconItemRenderer label="{data.employee_name}"
              messageField="position">
         </s:IconItemRenderer>
        </fx:Component>
       </s:itemRenderer>
    </s:List>
    </s:View>
    Please help me to resolve this issue as soon as possible. Appreciate your quick response in this regard.
    Thanks,
    Murtaza Ghodawala
    Mobile: +965 97180549
    [email protected]

    I am in the same boat, trying to get data from a site with simple Apache Basic Authentication.  I couldnt get the FB/AIR App for iPad to popup the login window. Then, I hard coded in my own login credentials as:
    URLRequestDefaults.setLoginCredentialsForHost("99.99.99.99", "alan", "1234");
    That worked to get logged in at least, and did bring back the data OK.
    Still working on the getting the popup the login window.

Maybe you are looking for