7 Replies Latest reply on Sep 7, 2006 9:01 AM by RafeFlex

    Problem with webservice AXIS

    RafeFlex
      Hi ,
      I have a webservice created with AXIS Java, and I try to get the result .
      The result of the webservice is a XML Document.
      I have an Object wsQryProgress that is my webservice
      wsQryProgress.doQueryWS is the only method in my webservice , and too I have a datagrid and binding with dataProvider="{wsQryProgress.doQueryWS.lastResult}"

      I don't know why the datagrid is empty

      Here is my code I hope you can help me
      quote:


      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="absolute" >
      <mx:WebService id="wsQryProgress"
      wsdl=" http://localhost/axis/services/QryProgress?wsdl"
      useProxy="false" result="fin(event);"
      fault="falla(event);">
      <mx:operation name="doQueryWS">
      <mx:request>
      <in0>for each tblcredencial where chrusername = 'jlrueda@todito.com' no-lock</in0>
      <in1>Credenciales</in1>
      <in2>Credencial</in2>
      <in3>idcredencial,chrusername</in3>
      <in4> http://www.toditocard.com/cgi-bin/tcardB/util/XML/wGenXml.p</in4>
      </mx:request>
      </mx:operation>


      </mx:WebService>
      <mx:Panel x="10" y="10" width="400" height="300" layout="absolute" title="Usuarios tcard">
      <mx:TextInput x="10" y="23" id="txtUser"/>
      <mx:Button x="198" y="23" label="Enviar" id="btnSend" click="SendUser();"/>
      <mx:DataGrid x="10" y="70" id="dgUsuario" dataProvider="{wsQryProgress.doQueryWS.lastResult}">
      <mx:columns>
      <mx:DataGridColumn headerText="idCredencial" dataField="idcredencial"/>
      <mx:DataGridColumn headerText="Username" dataField="chrusername"/>
      </mx:columns>

      </mx:DataGrid>
      <mx:Label x="10" y="229" text="&quot; &quot;" id="lblqry"/>
      </mx:Panel>
      <mx:Script>
      <![CDATA[
      import mx.utils.ArrayUtil;
      import mx.controls.Alert;

      public var strQry:String;
      public var strUrl:String = " http://www.toditocard.com/cgi-bin/tcardB/util/XML/wGenXml.p";
      public var strRoot:String = "Credenciales";
      public var strRow:String = "Credencial";
      public var strCampos:String = "chrusername,idcredencial";
      [Bindable]
      public var credenciales:Array;
      public function EnviaQry(strUser:String):void
      {
      strQry = "for each tblcredencial where chrusername = '" + strUser + "' no-lock:";
      wsQryProgress.doQueryWS.send();

      }
      public function SendUser():void
      {
      EnviaQry(txtUser.text);
      }

      public function fin(e:Object):void{
      Alert.show(e.result,"Result XML",Alert.OK,this,null,null,Alert.OK);

      }
      public function falla(e:Event):void
      {
      txtUser.text=e.toString();
      }

      ]]>
      </mx:Script>
      </mx:Application>


        • 1. Re: Problem with webservice AXIS
          RafeFlex Level 1

          the result of the webservice is
          <Credenciales>
          <Credencial>
          <idcredencial>934847</idcredencial>
          <chrUsername>jlrueda@todito.com</chrUsername>
          <Credencial>
          </Credenciales>
          • 2. Re: Problem with webservice AXIS
            Mete Atamel Level 1
            Could there be something wrong here?

            <mx:request>
            <in0>for each tblcredencial where chrusername = 'jlrueda@todito.com' no-lock</in0>
            <in1>Credenciales</in1>
            <in2>Credencial</in2>
            <in3>idcredencial,chrusername</in3>
            <in4> http://www.toditocard.com/cgi-bin/tcardB/util/XML/wGenXml.p</in4>
            </mx:request>
            • 3. Re: Problem with webservice AXIS
              RafeFlex Level 1
              like what??
              I test the service with these params and I got this:


              <soapenv:Envelope>

              <soapenv:Body>

              <doQueryWSResponse soapenv:encodingStyle=" http://schemas.xmlsoap.org/soap/encoding/">
              <doQueryWSReturn href="#id0"/>
              </doQueryWSResponse>

              <multiRef id="id0" soapenc:root="0" soapenv:encodingStyle=" http://schemas.xmlsoap.org/soap/encoding/" xsi:type="ns1:Document">

              <Credenciales>

              <Credencial>
              <idCredencial>934847</idCredencial>
              <chrUsername>jlrueda@todito.com</chrUsername>
              </Credencial>
              </Credenciales>
              </multiRef>
              </soapenv:Body>
              </soapenv:Envelope>
              • 4. Re: Problem with webservice AXIS
                Mete Atamel Level 1
                This is a guess but maybe you need to define your dataProvider like this?

                dataProvider="{wsQryProgress.doQueryWS.lastResult.Credenciales}">

                or

                dataProvider="{wsQryProgress.doQueryWS.lastResult.Credenciales.Credencial}">
                • 5. Re: Problem with webservice AXIS
                  RafeFlex Level 1
                  I tried it, but when I debug it , I got this message:

                  warning: unable to bind to property 'Credenciales' on class 'flash.xml::XMLNode' (class is not an IEventDispatcher)

                  What should I do?
                  • 6. Re: Problem with webservice AXIS
                    seth_hodgson Level 1
                    Hi RafeFlex,

                    I think the problem is that your webservice is not returning an Array or a collection (i.e. ArrayCollection). A SOAP response of:

                    <Credenciales>
                    <Credencial>
                    <idcredencial>934847</idcredencial>
                    <chrUsername>jlrueda@todito.com</chrUsername>
                    <Credencial>
                    </Credenciales>

                    would be deserialized into an Object graph similar to this:

                    var o:Object = {Credencial: {idcredencial:"934847", chrUsername:"jlrueda@todito.com"}};

                    The problem with this is that the dataProvider property on a DataGrid expects you to assign an Array or ArrayCollection to it. If you pass an Object, it puts it into the first position in a new array it creates internally. It then looks for idcredencial and chrusername properties (based on your DataGridColumn dataFields) on this object and it won't find them because the object has only one property on it: Credencial (which is the object you're trying to display in the grid).

                    You should either update the web service to return an array, or process the result yourself moving any nested <Credencial>s into an Array to assign as the grid's dataProvider. Or if you only ever get a single Credencial back in your result, update your binding to: dataProvider="{wsQryProgress.doQueryWS.lastResult.Credencial}".

                    I think you also need to change your second DataGridColumn's dataField from "chrusername" to "chrUsername" to match the returned value.

                    Best,
                    Seth
                    • 7. Re: Problem with webservice AXIS
                      RafeFlex Level 1
                      It seems the better is to change the webservice, just I don't know how should be the result if it returns an array instead an Document