3 Replies Latest reply on Jul 29, 2009 9:43 AM by Sebmex

    Noob question or bug ??

    Sebmex

      Hi,

       

      previous user of Flash MX and Xcelsius, now discovering and testing with joy Flash Catalyst and Flash Builder.

       

      I have a problem when I try to call and integrate a Webservice in Flash Builder.

       

      Here is the webservice WSDL layout :

       

      http://lullpc9999/Webservice6/Webservice6.asmx?WSDL

      <?xml version="1.0" encoding="utf-8" ?>

      - <wsdl:types>
      - <s:schema elementFormDefault="qualified" targetNamespace="http://Webservice6.internal/Webservice6">
      - <s:element name="MyQuery">
      <s:complexType />
      </s:element>
      - <s:element name="MyQueryResponse">
      - <s:complexType>
      - <s:sequence>
      <s:element minOccurs="0" maxOccurs="1" name="MyQueryResult" type="tns:ArrayOfMyQueryReturn" />
      </s:sequence>
      </s:complexType>
      </s:element>
      - <s:complexType name="ArrayOfMyQueryReturn">
      - <s:sequence>
      <s:element minOccurs="0" maxOccurs="unbounded" name="MyQueryReturn" nillable="true" type="tns:MyQueryReturn" />
      </s:sequence>
      </s:complexType>
      - <s:complexType name="MyQueryReturn">
      - <s:sequence>
      <s:element minOccurs="1" maxOccurs="1" name="Success" type="s:boolean" />
      <s:element minOccurs="0" maxOccurs="1" name="Message" type="s:string" />
      <s:element minOccurs="0" maxOccurs="1" name="Records" type="tns:ArrayOfMyQueryRow" />
      </s:sequence>
      </s:complexType>
      - <s:complexType name="ArrayOfMyQueryRow">
      - <s:sequence>
      <s:element minOccurs="0" maxOccurs="unbounded" name="MyQueryRow" nillable="true" type="tns:MyQueryRow" />
      </s:sequence>
      </s:complexType>
      - <s:complexType name="MyQueryRow">
      - <s:sequence>
      <s:element minOccurs="0" maxOccurs="1" name="Prenom" type="s:string" />
      <s:element minOccurs="1" maxOccurs="1" name="Heritage" type="s:int" />
      </s:sequence>
      </s:complexType>
      </s:schema>
      </wsdl:types>
      - <wsdl:message name="MyQuerySoapIn">
      <wsdl:part name="parameters" element="tns:MyQuery" />
      </wsdl:message>
      - <wsdl:message name="MyQuerySoapOut">
      <wsdl:part name="parameters" element="tns:MyQueryResponse" />
      </wsdl:message>
      - <wsdl:portType name="Webservice6Soap">
      - <wsdl:operation name="MyQuery">
      <wsdl:input message="tns:MyQuerySoapIn" />
      <wsdl:output message="tns:MyQuerySoapOut" />
      </wsdl:operation>
      </wsdl:portType>
      - <wsdl:binding name="Webservice6Soap" type="tns:Webservice6Soap">
      <soap:binding transport="http://schemas.xmlsoap.org/soap/http" />
      - <wsdl:operation name="MyQuery">
      <soap:operation soapAction="http://Webservice6.internal/Webservice6/MyQuery" style="document" />
      - <wsdl:input>
      <soap:body use="literal" />
      </wsdl:input>
      - <wsdl:output>
      <soap:body use="literal" />
      </wsdl:output>
      </wsdl:operation>
      </wsdl:binding>
      - <wsdl:binding name="Webservice6Soap12" type="tns:Webservice6Soap">
      <soap12:binding transport="http://schemas.xmlsoap.org/soap/http" />
      - <wsdl:operation name="MyQuery">
      <soap12:operation soapAction="http://Webservice6.internal/Webservice6/MyQuery" style="document" />
      - <wsdl:input>
      <soap12:body use="literal" />
      </wsdl:input>
      - <wsdl:output>
      <soap12:body use="literal" />
      </wsdl:output>
      </wsdl:operation>
      </wsdl:binding>
      - <wsdl:service name="Webservice6">
      - <wsdl:port name="Webservice6Soap" binding="tns:Webservice6Soap">
      </wsdl:port>
      - <wsdl:port name="Webservice6Soap12" binding="tns:Webservice6Soap12">
      <soap12:address location="http://lullpc9999/Webservice6/Webservice6.asmx" />
      </wsdl:port>
      </wsdl:service>
      </wsdl:definitions>

       


      here is the view of asmx file :

       

       

      Webservice6


      Click here for a complete list of operations.

      MyQuery

       

      Test

      The test form is only available for requests from the local machine.

      SOAP 1.1

      The following is a sample SOAP 1.1 request and response. The placeholders shown need to be replaced with actual values.

      POST /Webservice6/Webservice6.asmx HTTP/1.1
      Host: lullpc9999
      Content-Type: text/xml; charset=utf-8
      Content-Length: length
      SOAPAction: "http://Webservice6.internal/Webservice6/MyQuery"
      
      <?xml version="1.0" encoding="utf-8"?>
      <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
        <soap:Body>
          <MyQuery xmlns="http://Webservice6.internal/Webservice6" />
        </soap:Body>
      </soap:Envelope>
      HTTP/1.1 200 OK
      Content-Type: text/xml; charset=utf-8
      Content-Length: length
      
      <?xml version="1.0" encoding="utf-8"?>
      <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
        <soap:Body>
          <MyQueryResponse xmlns="http://Webservice6.internal/Webservice6">
            <MyQueryResult>
              <MyQueryReturn>
                <Success>boolean</Success>
                <Message>string</Message>
                <Records>
                  <MyQueryRow xsi:nil="true" />
                  <MyQueryRow xsi:nil="true" />
                </Records>
              </MyQueryReturn>
              <MyQueryReturn>
                <Success>boolean</Success>
                <Message>string</Message>
                <Records>
                  <MyQueryRow xsi:nil="true" />
                  <MyQueryRow xsi:nil="true" />
                </Records>
              </MyQueryReturn>
            </MyQueryResult>
          </MyQueryResponse>
        </soap:Body>
      </soap:Envelope>

      SOAP 1.2

      The following is a sample SOAP 1.2 request and response. The placeholders shown need to be replaced with actual values.

      POST /Webservice6/Webservice6.asmx HTTP/1.1
      Host: lullpc9999
      Content-Type: application/soap+xml; charset=utf-8
      Content-Length: length
      
      <?xml version="1.0" encoding="utf-8"?>
      <soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
        <soap12:Body>
          <MyQuery xmlns="http://Webservice6.internal/Webservice6" />
        </soap12:Body>
      </soap12:Envelope>
      HTTP/1.1 200 OK
      Content-Type: application/soap+xml; charset=utf-8
      Content-Length: length
      
      <?xml version="1.0" encoding="utf-8"?>
      <soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
        <soap12:Body>
          <MyQueryResponse xmlns="http://Webservice6.internal/Webservice6">
            <MyQueryResult>
              <MyQueryReturn>
                <Success>boolean</Success>
                <Message>string</Message>
                <Records>
                  <MyQueryRow xsi:nil="true" />
                  <MyQueryRow xsi:nil="true" />
                </Records>
              </MyQueryReturn>
              <MyQueryReturn>
                <Success>boolean</Success>
                <Message>string</Message>
                <Records>
                  <MyQueryRow xsi:nil="true" />
                  <MyQueryRow xsi:nil="true" />
                </Records>
              </MyQueryReturn>
            </MyQueryResult>
          </MyQueryResponse>
        </soap12:Body>
      </soap12:Envelope>

       


      now when I create a Data/Service Provider in Flash Builder, I select WDSL type, (working preview of the webservice done on the server to check that webservice is running fine) ...

       

      I type a service name, then the url to WSDL... Next

       

      I then see in a combo my webservice name (Webservice6) and in another combo a port number "Webservice6Saop", (if I choose Webservice6Soap12 i get an error message).

       

      I have one Operation to Select "MyQueryResponse". I select it and then clic on Finish...

       

      I see the wrking panel in Design mode, drag a UIComponent, bind data to the datagrid component ...

       

      and HERE is my problem : the only colums I get to choose are "Message", "Records" and "Success"... (names from WSDL structure, not my query columns: Prenom and Heritage)

       

      in the Data/Service tab, I have a MyQueryReturn[] tree with these 3 fields.

       

      If i go to Data Types tree, I see these same 3 fields in the MyQueryReturn subtree. I can find my 2 colum header in the MyQeryRow subtree but can't map them on the datagrid (only col from MyQueryReturn available.

       

      HELP ! I'am so close to getting to it.

       

      Thanks

       

      Sebmex

        • 1. Re: Noob question or bug ??
          SunilAdobe Adobe Employee

          Sebmex,

           

          You can see that Records is returning an array of type MyQueryRow.

          You can see your columns in the "DataTypes" node, with the name MyQueryRow and it shows Heritage and Prenom.

           

          Unfortunately in the beta build, you cannot bind to the sub element(which is records here in your example) of a result. You should do that manually by typing in

           

          MyQueryResult.lastResult[0].Records in the dataProvider initialization of the mx:datagrid tag.

           

          Also, the datagrid columns' datafield need to be changed manually to your requirement (Heritage and Prenom) in your case.

           

          I have filed an enhancement required for this http://bugs.adobe.com/jira/browse/FB-21662

           

          Hope this helps.

           

          Thanks

          -Sunil

          • 2. Re: Noob question or bug ??
            Sebmex Level 1

            Hi,

             

            thank you for this piece of code, it works now.

             

            glad i helped to improve this software !

            • 3. Re: Noob question or bug ??
              Sebmex Level 1

              hum ... working but just one time, after I get this warning message in front of the line where i inserted [0]. Results       :

               

              Description Resource Path Location Type
              Data binding will not be able to detect changes when using square bracket operator.  For Array, please use ArrayCollection.getItemAt() instead. Principal.mxml menu_exemple_sao_8/src line 179 Flex Problem

              what would you suggest ?

               

              thank you

               

              Sebmex