3 Replies Latest reply on Oct 25, 2006 1:41 AM by tinybloke

    WebServices and XMLDocuments

    tinybloke
      I have a .NET webservice that returns an XMLDocument

      [WebMethod]
      public XmlDocument PriceGet()
      {
      string sDoc = "<testXML><User FName='Bingo' SName='Little' /></testXML>";
      XmlDocument oDoc = new XmlDocument();
      oDoc.LoadXml(sDoc);
      return oDoc;
      }

      I have created the following WebService in Flex Builder


      <mx:WebService id="Dashboardws1"
      wsdl=" http://localhost/Dashboardws/dashboardservices.asmx?wsdl"
      useProxy="false"
      showBusyCursor="true"
      fault="Alert.show(event.message.toString())"
      result="PriceGetHandler(event)">
      <mx:operation name="PriceGet">
      <mx:request/>
      </mx:operation>
      </mx:WebService>
        • 1. Re: WebServices and XMLDocuments
          tinybloke Level 1
          Apologies...first post and it went out half-cocked

          Here is the full post

          I have a .NET webservice that returns an XMLDocument

          [WebMethod]
          public XmlDocument PriceGet()
          {
          string sDoc = "<testXML><User FName='Bingo' SName='Little' /></testXML>";
          XmlDocument oDoc = new XmlDocument();
          oDoc.LoadXml(sDoc);
          return oDoc;
          }

          I have created the following WebService in Flex Builder

          <mx:WebService id="Dashboardws1"
          wsdl=" http://localhost/Dashboardws/dashboardservices.asmx?wsdl"
          useProxy="false"
          showBusyCursor="true"
          fault="Alert.show(event.message.toString())"
          result="PriceGetHandler(event)">
          <mx:operation name="PriceGet">
          <mx:request/>
          </mx:operation>
          </mx:WebService>

          I have checked the message that is coming back

          (mx.messaging.messages::AcknowledgeMessage)#0
          body = "<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap=" http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi=" http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd=" http://www.w3.org/2001/XMLSchema"><soap:Body><PriceGetResponse><PriceGetResult><testXML xmlns=""><User FName="Bingo" SName="Little" /></testXML></PriceGetResult></PriceGetResponse></soap:Body></soap:Envelope>"
          clientId = "DirectHTTPChannel0"
          correlationId = "56648983-5FBD-C1C2-37CF-75F0BB1D927A"
          destination = ""
          headers = (Object)#1
          messageId = "F5D83181-12DD-67E4-7E41-75F0BC07890C"
          timestamp = 0
          timeToLive = 0

          but for the life of me I can't get to the data that the message contains.

          Referencing Dashboardws.PriceGet.lastResult give me a null as do all other combinations I can think of

          Has anybody got any thoughts? My remaining hair is in some danger here
          • 2. Re: WebServices and XMLDocuments
            aglosband
            Hi. What does your code look like where you handle the result from the web service? Do you have a result handler, ie. PriceGetHandler(event), or are you trying to databind to the result?
            • 3. Re: WebServices and XMLDocuments
              tinybloke Level 1
              Thanks for the response

              I do have an event handler. Since the original post I have made the following progress.

              If I alter the return type to e4x and create a local namespace like this

              private namespace utx = " http://www.xxxxxx.net/";
              use namespace utx;

              I can access the data as an XMLListCollection in the event handler

              colPriceXML = new XMLListCollection(event.result.PriceGetResult.root.children());

              Whilst this works I am still interested as to how I can access this data in other ways (e.g. as an ArrayCollection which is what I have been doing with HTTPServices.) I have seen plenty of example code where returning a XMLDocument from a C# webservice seems routine but not many of these seem to work in practice