3 Replies Latest reply on Sep 12, 2007 6:26 PM by LJ6m3gu9

    SOAP, Web Service Interaction using Flex 2

    LJ6m3gu9 Level 1
      A Web Service exists on the local computer. It is a .NET Framework web service (SOAP) running under IIS. It commences with a demand for three parameters. One fills in the form and presses a button on the form and is returned an XML file with vital data necessary for future web service transactions that will involve SQL-form queries and XML responses. Actions that Flex 2 is required to perform: 1) submit a URI and receive a form, 2) POST a response to the form and receive an XML file, 3) submit a query, 4) reformat an XML file to remove irrelevant data and to make a Flex 2 data provider happy so that a chart can be displayed. I assume Flex 2 can do all these things and it is just a matter of knowing how.
        • 1. Re: SOAP, Web Service Interaction using Flex 2
          ProfessorC Level 1
          Your description is a bit confusing. The webservice in question has a single method that takes three parameters, and returns a FORM? What are the three parameters, and what, exactly, do you mean by "form".

          When I hear "form", I usually think of an HTML form with text input fields, comboboxes, radio buttons, etc. But, in general, properly developed webservices do not return UI elements (such as text input fields, comboboxes, and radio buttons). They are typically only used as a communication method in the model layer, where they return datasets or process responses. And the view layer (in this case, Flex) is responsible for building any UI elements that collect data for the interaction with the webservice.

          But, okay, let's say, for some odd reason, this webservice returns a form (as I am thinking of the term). What format is this form in? I personally can't think of a readily available method that could display this form with a Flex app, but maybe I'm missing something. Or is it that, by "form", you mean something completely different, like a second method in the webservice that receives posted data? What is actually returned in your step #1?

          Step #2 is a cinch. Simply create an HTTPService tag (or in script, create URLLoader and URLRequest objects) in your app that posts the appropriate data to the appropriate webservice URL with the appropriate method. In the callback handler function for that webservice call, a (properly formatted) XML response will be converted automatically to a "Flex-friendly" data object, which you can easily parse apart to build your SQL as necessary.

          Step #3, again, where do you submit the query to? A third method in the webservice? If so, it would be just like #2 above. And the response data would, again, be automatically converted into a Flex data object.

          Step #4 would probably be accomplished more by manipulating the Flex data object rather than any reformatting of the XML. Simply loop through the object and remove irrelevant children/data. Then set a bindable variable to the cleaned data object, and have your chart bound to that variable.

          There are many many examples on the web. Just search for 'flex "mx:HTTPService"' or similar. And take a look through LiveDocs for [Bindable] for step #4.
          • 2. Re: SOAP, Web Service Interaction using Flex 2
            LJ6m3gu9 Level 1
            I apologize for the confusion and thank you for your reply. My task is to perform from inside Flex. the functions of a human user of a non-Flex web application that fronts a non-Flex web service. These are preliminary steps to gaining access to a similar non-Flex web application fronting a non-Flex web service. I have put screen shots at http://www.mdrsesco.biz/Exhibit-1.jpg, http://www.mdrsesco.biz/Exhibit-2.jpg, and http://www.mdrsesco.biz/Exhibit-2.jpg. I have used the HTTPService successfully to turn XML into, for example, a column chart. But I am under the apparently incorrect impression that the XML must pair labels and their associated data, whereas my resource first lists the data in one section of XML, then it lists the labels. I will look into the ease with which Flex allows me to traverse an XML tree, perhaps reorder the elements, and feed a new XML tree to a chart. I appreciate any further assistance that you may provide.
            • 3. Re: SOAP, Web Service Interaction using Flex 2
              LJ6m3gu9 Level 1
              I see E4X, otherwise known as the ECMAScript extension for XML processing. This is a Flex 3 thingy? Or may I expect to find it in Flex 2? And if not in Flex 2, then I use the Document Object Model (DOM), which limits me to leaf nodes, or something? I find this quite confusing...