2 Replies Latest reply on Jul 26, 2006 1:07 PM by kibab

    Specifying arguments to Webservice calls

    kibab
      I have the following code:

      Sample Code is:

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="absolute">
      <mx:WebService id="wsTest" wsdl=" http://192.168.1.108:8080/stockquotes/stock_quote?wsdl" useProxy="false">
      <mx:operation name="sendStrings">
      <mx:request xmlns="">
      <arg0>One</arg0>
      <arg0>Two</arg0>
      <arg0>Three</arg0>
      </mx:request>
      </mx:operation>
      </mx:WebService>
      <mx:VBox x="38" y="10" height="287" width="297" id="btSend">
      <mx:Button label="Send Many Strings" mouseDown="wsTest.sendStrings.send()"/>
      </mx:VBox>
      </mx:Application>

      If I try to send a parameter to a web service function that takes an array of parameters (arg0 elements), than flex generates a fault (Unexpected parameter 'arg0' found in input arguments) before it even attempts to communicate with the webservice. If I try to send a single arg0 element, I still get the error.

      The specification for the input parameters is

      <xs:complexType name="sendStrings">
      <xs:sequence>
      <xs:element name="arg0" type="xs:string" maxOccurs="unbounded" minOccurs="0"/>
      </xs:sequence>
      </xs:complexType>

      So, apparently I don't know how, nor can I find in the docs, how I would specify that the input is an array. I tried wrapping my element, but that faults in the same way because it didn't recognize the parameter name. I even tried defining the xs namespace and wrapping my array in an xs:sequence element.

      Any idea how I can specify a parameter which is an array?

      Thanks.

      --Kaleb

        • 1. Re: Specifying arguments to Webservice calls
          dishmael Level 1
          Web and HTTP services can be tricky. Try adding handlers to the events so you can see what's being sent. This may not be exactly correct, going from memory here:

          <mx:Script>
          <![CDATA[

          import mx.controls.Alert;

          private function handleInvoke(event:InvokeEvent):void {
          Alert.show( event.message );
          }

          ]]>
          </mx:Script>

          <mx:WebService id="wsTest" invoke="handleInvoke(event)" ... >

          • 2. Re: Specifying arguments to Webservice calls
            kibab Level 1
            Thanks for the reply. I have been running tcpdump on the server and can see that no data has been sent to the server.

            However, I tried that anyway and found out that it doesn't make it to the invoke event when I try to send across an array. It does when I send across a single parameter, so I know it's working.

            I'm not sure what Flex thinks the name of the parameter really is. I have tried everything that I can think of and it still doesn't work.

            Any ideas?

            Thanks.

            --Kaleb