10 Replies Latest reply on Aug 12, 2006 6:46 PM by ekuzmack

    Can't get data out of SOAP document

    ekuzmack
      I'm hoping someone can help - I'm new to Flex. I'm trying to display data from a webservice call and can't figure out the right datagrid dataprovider string. I've posted the SOAP response at the end of this note. The snippit of the dataprovider string I have is:

      dataProvider="{WSName.lastResult.GetPersonResponse.GetPersonResult.SqlRowSet.diffgram.SqlR owSet1.row}"

      This seems to be right based on the tree structure, but it doesn't work. The rest of the project is pretty much a basic copy of the webservices example in the help file. Also - the webservice is a MS SQL2005 native XML service. What am I missing?

      thanks!

      Eric

      Here's the SOAP response from the query:

      <?xml version="1.0" encoding="utf-8"?>
      <SOAP-ENV:Envelope xml:space="preserve" xmlns:xsd=" http://www.w3.org/2001/XMLSchema" xmlns:xsi=" http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENV=" http://schemas.xmlsoap.org/soap/envelope/" xmlns:sql=" http://schemas.microsoft.com/sqlserver/2004/SOAP" xmlns:sqlsoaptypes=" http://schemas.microsoft.com/sqlserver/2004/SOAP/types" xmlns:sqlrowcount=" http://schemas.microsoft.com/sqlserver/2004/SOAP/types/SqlRowCount" xmlns:sqlmessage=" http://schemas.microsoft.com/sqlserver/2004/SOAP/types/SqlMessage" xmlns:sqlresultstream=" http://schemas.microsoft.com/sqlserver/2004/SOAP/types/SqlResultStream" xmlns:sqltransaction=" http://schemas.microsoft.com/sqlserver/2004/SOAP/types/SqlTransaction" xmlns:sqltypes=" http://schemas.microsoft.com/sqlserver/2004/sqltypes" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:method=" http://tempUri.org/">
      <SOAP-ENV:Body>
      <method:GetPersonResponse>
      <method:GetPersonResult xmlns="">
      <sqlresultstream:SqlRowSet xsi:type="sqlsoaptypes:SqlRowSet" msdata:UseDataSetSchemaOnly="true" msdata:UDTColumnValueWrapped="true">
      <xsd:schema xmlns:xsd=" http://www.w3.org/2001/XMLSchema" targetNamespace=" http://schemas.microsoft.com/sqlserver/2004/sqltypes">
      <xsd:simpleType name="uniqueidentifier">
      <xsd:restriction base="xsd:string">
      <xsd:pattern value="([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})|(\{[ 0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}\})" />
      </xsd:restriction>
      </xsd:simpleType>
      <xsd:simpleType name="varchar">
      <xsd:restriction base="xsd:string" />
      </xsd:simpleType>
      </xsd:schema>
      <xsd:schema targetNamespace="urn:schemas-microsoft-com:sql:SqlRowSet1" xmlns="" xmlns:xsd=" http://www.w3.org/2001/XMLSchema" xmlns:sqltypes=" http://schemas.microsoft.com/sqlserver/2004/sqltypes" elementFormDefault="qualified">
      <xsd:import namespace=" http://schemas.microsoft.com/sqlserver/2004/sqltypes" />
      <xsd:element name="SqlRowSet1" msdata:IsDataSet="true" msdata:DataSetNamespace="urn:schemas-microsoft-com:sql:SqlDataSet" msdata:DataSetName="SqlDataSet">
      <xsd:complexType>
      <xsd:sequence>
      <xsd:element name="row" minOccurs="0" maxOccurs="unbounded">
      <xsd:complexType>
      <xsd:sequence>
      <xsd:element name="PersonGUID" type="sqltypes:uniqueidentifier" />
      <xsd:element name="FirstName" minOccurs="0">
      <xsd:simpleType>
      <xsd:restriction base="sqltypes:varchar" sqltypes:localeId="1033" sqltypes:sqlCompareOptions="IgnoreCase IgnoreKanaType IgnoreWidth" sqltypes:sqlSortId="52">
      <xsd:maxLength value="255" />
      </xsd:restriction>
      </xsd:simpleType>
      </xsd:element>
      <xsd:element name="LastName" minOccurs="0">
      <xsd:simpleType>
      <xsd:restriction base="sqltypes:varchar" sqltypes:localeId="1033" sqltypes:sqlCompareOptions="IgnoreCase IgnoreKanaType IgnoreWidth" sqltypes:sqlSortId="52">
      <xsd:maxLength value="255" />
      </xsd:restriction>
      </xsd:simpleType>
      </xsd:element>
      <xsd:element name="telephoneNumber" minOccurs="0">
      <xsd:simpleType>
      <xsd:restriction base="sqltypes:varchar" sqltypes:localeId="1033" sqltypes:sqlCompareOptions="IgnoreCase IgnoreKanaType IgnoreWidth" sqltypes:sqlSortId="52">
      <xsd:maxLength value="10" />
      </xsd:restriction>
      </xsd:simpleType>
      </xsd:element>
      <xsd:element name="emailAddress" minOccurs="0">
      <xsd:simpleType>
      <xsd:restriction base="sqltypes:varchar" sqltypes:localeId="1033" sqltypes:sqlCompareOptions="IgnoreCase IgnoreKanaType IgnoreWidth" sqltypes:sqlSortId="52">
      <xsd:maxLength value="255" />
      </xsd:restriction>
      </xsd:simpleType>
      </xsd:element>
      </xsd:sequence>
      </xsd:complexType>
      </xsd:element>
      </xsd:sequence>
      </xsd:complexType>
      </xsd:element>
      </xsd:schema>
      <diffgr:diffgram xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1">
      <SqlRowSet1 xmlns="urn:schemas-microsoft-com:sql:SqlRowSet1">
      <row>
      <PersonGUID>606EC0C5-748F-4E93-B167-00000C725956</PersonGUID>
      <FirstName>JERROLD</FirstName>
      <LastName>LLEWELLYN</LastName>
      <telephoneNumber>3192666187</telephoneNumber>
      <emailAddress>jllewellyn@gmail.com</emailAddress>
      </row>
      </SqlRowSet1>
      </diffgr:diffgram>
      </sqlresultstream:SqlRowSet>
      <sqlresultstream:SqlResultCode xsi:type="sqlsoaptypes:SqlResultCode">0</sqlresultstream:SqlResultCode>
      </method:GetPersonResult>
      </method:GetPersonResponse>
      </SOAP-ENV:Body>
      </SOAP-ENV:Envelope>
        • 1. Re: Can't get data out of SOAP document
          dishmael Level 1
          Two quick assumptions:

          1.) The WebService component id is WSName
          2.) The operation for the WebService has a name of GetPerson

          If those assumptions are true, you should be able to set the dataProvider to:

          dataProvider="{WSName.GetPerson.lastResult}"

          You may also want to setup your operation to alert or trace the results and faults to make sure things are working correctly. Try that and see what happens. If it still doesn't work, post your MXML or AS code so we can help more.
          • 2. Re: Can't get data out of SOAP document
            ekuzmack Level 1
            Thanks for the quick response - a little more detail:

            I've put the MSXML code at the bottom of this note - I had sterlized my post a little bit.

            I know the SOAP call is suceeding, because in debug mode, I can view the lastresult variable and move through the tree and see my data. The problem I'm having is basically that I just can't figure out how to get the actual data to show up in the text and datagrid components. When I tested this with a very plain XML document without schema, etc... it worked just like the documentation said. But I think that I need to specifiy something more than just the field names at this point, since I'm now dealing with a more complex SOAP document.

            thanks!!

            Eric

            Here's the actual code:

            <?xml version="1.0" encoding="utf-8"?>
            <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml"
            layout="absolute"
            height="580" width="779">

            <mx:TextInput x="196" y="38" id="txtPhone" text="3192666187"/>
            <mx:FormHeading x="4" y="38" label="Home Phone Number:" textAlign="right" width="178"/>

            <mx:WebService id="customerRequest"
            wsdl="https://SERVERNAME/cim?wsdl"
            useProxy="false"
            showBusyCursor="true" >

            <mx:operation name="GetPerson" resultFormat="e4x">
            <mx:request>
            <phone>{txtPhone.text}</phone>
            </mx:request>
            </mx:operation>
            </mx:WebService>

            <mx:Button x="364" y="38" label="Get Customer" id="btnGetPerson" click="customerRequest.GetPerson.send()"/>

            <mx:Panel x="10" y="81" width="716" height="415" layout="absolute"
            title="Customer Number:">
            <mx:Text x="1" y="1" text="{customerRequest.GetPerson.lastResult.row.PersonGUID}" width="385" height="23"/>

            <mx:DataGrid x="30" y="75" id="dgCustomerData" dataProvider="{customerRequest.GetPerson.lastResult}" width="400">
            <mx:columns>
            <mx:DataGridColumn headerText="FirstName" dataField="FirstName"/>
            <mx:DataGridColumn headerText="LastName" dataField="LastName"/>
            <mx:DataGridColumn headerText="Email Address" dataField="emailAddress"/>
            </mx:columns>
            </mx:DataGrid>
            </mx:Panel>

            <mx:FormHeading x="149" y="10" label="Customer Information Portal" textAlign="left" width="214"/>

            </mx:Application>

            • 3. Re: Can't get data out of SOAP document
              ekuzmack Level 1
              Hello - is there someone who can help me on this thread?

              thanks!

              Eric
              • 4. Re: Can't get data out of SOAP document
                ntsiii Level 3
                You may need to use a labelFunction()

                Also, binding is very hard to debug. Instead, use a result handler function. There you can trace or alert the result object to detemine how you should write the dataProvider expression.

                Tracy
                • 5. Re: Can't get data out of SOAP document
                  krrobert
                  I had a similar problem; I tracked it down to the presence of XML namespaces in the data preventing the grid from recognizing the fields.

                  The suggestion above of using a labelFunction worked for me. I made my labelFunction find the proper field via QName, which works with the namespaces.

                  Something like:

                  internal function myLabelFunction(item:Object, column:DataGridColumn) : String
                  {
                  var itemXML:XML = item as XML;
                  var idQName:QName = new QName(" http://www.w3.org/2001/XMLSchema" "simpleType");
                  if(itemXML.descendants(idQName).length() > 0)
                  return itemXML.descendants(idQName)[0].@name;
                  else
                  return "foo";
                  }
                  • 6. Re: Can't get data out of SOAP document
                    ekuzmack Level 1
                    Thanks for the responses - please forgive me, I'm very new to development - I'm an infrastucture guy. How do I actually call the fuction (I've figured out how to add it to the app), and how do I bind the grid to the object that is returned?

                    thanks!

                    Eric
                    • 7. Re: Can't get data out of SOAP document
                      amers
                      If you're returning XML, you may want to try this:

                      WebService.Method.lastResult.MethodResult.<top XML>.<XML of children>

                      I did it this way and it was quite simple to have it show the grid afterwards.

                      • 8. Re: Can't get data out of SOAP document
                        ekuzmack Level 1
                        OK - I'm getting closer - using the namespace I've focused the response document a little closer, but I'm not sure how to use the methodResult function. Below is the document that I'm using now. I've tried dozens of variations of your MethodResult option without sucess, such as:

                        wsCIM.GetPerson.lastResult.MethodResult.GetPersonResponse.GetPersonResult

                        Any ideas?

                        Here's the response document:


                        <method:GetPersonResponse xmlns:method=" http://tempuri.org" xmlns:sqlsoaptypes=" http://schemas.microsoft.com/sqlserver/2004/SOAP/types" xmlns:xsd=" http://www.w3.org/2001/XMLSchema" xmlns:sqltypes=" http://schemas.microsoft.com/sqlserver/2004/sqltypes" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:sqlrowcount=" http://schemas.microsoft.com/sqlserver/2004/SOAP/types/SqlRowCount" xmlns:sqltransaction=" http://schemas.microsoft.com/sqlserver/2004/SOAP/types/SqlTransaction" xmlns:SOAP-ENV=" http://schemas.xmlsoap.org/soap/envelope/" xmlns:sqlmessage=" http://schemas.microsoft.com/sqlserver/2004/SOAP/types/SqlMessage" xmlns:xsi=" http://www.w3.org/2001/XMLSchema-instance" xmlns:sql=" http://schemas.microsoft.com/sqlserver/2004/SOAP" xmlns:sqlresultstream=" http://schemas.microsoft.com/sqlserver/2004/SOAP/types/SqlResultStream">
                        <method:GetPersonResult msdata:UDTColumnValueWrapped="true" msdata:UseDataSetSchemaOnly="true">
                        <xsd:schema targetNamespace=" http://schemas.microsoft.com/sqlserver/2004/sqltypes">
                        <xsd:simpleType name="uniqueidentifier">
                        <xsd:restriction base="xsd:string">
                        <xsd:pattern value="([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})|(\{[ 0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}\})"/>
                        </xsd:restriction>
                        </xsd:simpleType>
                        <xsd:simpleType name="varchar">
                        <xsd:restriction base="xsd:string"/>
                        </xsd:simpleType>
                        </xsd:schema>
                        <xsd:schema targetNamespace="urn:schemas-microsoft-com:sql:SqlRowSet1" elementFormDefault="qualified">
                        <xsd:import namespace=" http://schemas.microsoft.com/sqlserver/2004/sqltypes"/>
                        <xsd:element name="SqlRowSet1" msdata:DataSetName="SqlDataSet" msdata:IsDataSet="true" msdata:DataSetNamespace="urn:schemas-microsoft-com:sql:SqlDataSet">
                        <xsd:complexType>
                        <xsd:sequence>
                        <xsd:element name="row1" minOccurs="0" maxOccurs="unbounded">
                        <xsd:complexType>
                        <xsd:sequence>
                        <xsd:element name="PersonGUID" type="sqltypes:uniqueidentifier"/>
                        <xsd:element name="FirstName" minOccurs="0">
                        <xsd:simpleType>
                        <xsd:restriction sqltypes:sqlSortId="52" base="sqltypes:varchar" sqltypes:localeId="1033" sqltypes:sqlCompareOptions="IgnoreCase IgnoreKanaType IgnoreWidth">
                        <xsd:maxLength value="255"/>
                        </xsd:restriction>
                        </xsd:simpleType>
                        </xsd:element>
                        <xsd:element name="LastName" minOccurs="0">
                        <xsd:simpleType>
                        <xsd:restriction sqltypes:sqlSortId="52" base="sqltypes:varchar" sqltypes:localeId="1033" sqltypes:sqlCompareOptions="IgnoreCase IgnoreKanaType IgnoreWidth">
                        <xsd:maxLength value="255"/>
                        </xsd:restriction>
                        </xsd:simpleType>
                        </xsd:element>
                        <xsd:element name="telephoneNumber" minOccurs="0">
                        <xsd:simpleType>
                        <xsd:restriction sqltypes:sqlSortId="52" base="sqltypes:varchar" sqltypes:localeId="1033" sqltypes:sqlCompareOptions="IgnoreCase IgnoreKanaType IgnoreWidth">
                        <xsd:maxLength value="10"/>
                        </xsd:restriction>
                        </xsd:simpleType>
                        </xsd:element>
                        <xsd:element name="emailAddress" minOccurs="0">
                        <xsd:simpleType>
                        <xsd:restriction sqltypes:sqlSortId="52" base="sqltypes:varchar" sqltypes:localeId="1033" sqltypes:sqlCompareOptions="IgnoreCase IgnoreKanaType IgnoreWidth">
                        <xsd:maxLength value="255"/>
                        </xsd:restriction>
                        </xsd:simpleType>
                        </xsd:element>
                        </xsd:sequence>
                        </xsd:complexType>
                        </xsd:element>
                        </xsd:sequence>
                        </xsd:complexType>
                        </xsd:element>
                        </xsd:schema>
                        <diffgr:diffgram xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1">
                        <SqlRowSet1 xmlns="urn:schemas-microsoft-com:sql:SqlRowSet1">
                        <row1>
                        <PersonGUID>606EC0C5-748F-4E93-B167-00000C725956</PersonGUID>
                        <FirstName>JERROLD</FirstName>
                        <LastName>LLEWELLYN</LastName>
                        <telephoneNumber>3192666187</telephoneNumber>
                        <emailAddress>jllewellyn@gmail.com</emailAddress>
                        </row1>
                        </SqlRowSet1>
                        </diffgr:diffgram>
                        </method:GetPersonResult>
                        </method:GetPersonResponse>


                        thanks!!

                        Eric
                        • 9. Re: Can't get data out of SOAP document
                          amers Level 1
                          Let me re-phrase this, sorry about the mixup..

                          WebService.<Method Name>.lastResult.<Method Name>Result.<top XML>.<XML of children>
                          • 10. Re: Can't get data out of SOAP document
                            ekuzmack Level 1
                            Sucess!!!

                            I used:

                            wsCIM.GetPerson.lastResult.diffgram.SqlRowSet1.row1

                            thanks everyone!!!