1 Reply Latest reply on Jan 7, 2008 7:37 AM by enzo1020vienna

    sending xml to webservice

    kittuokkade Level 1
      hi ,

      i want to send xml string as input to a webservice .i had a problem with this. iam pasting the code iam using.

      public var sResult:String="<?xml version='1.0' encoding='UTF-8' ?>
      <root><sample><id>8098</id><type>CD</type><unit>nm</unit></sample></root>";
      <mx:WebService id="myws"
      wsdl=" http://localhost:8080/myws/method?wsdl"
      useProxy="false">
      <mx:operation name="getCD" result="resultHandler(event)" fault="Alert.show(event.fault.message)">
      <mx:request>
      <String_1> {sResult} </String_1>
      </mx:request>
      </mx:operation>
      </mx:WebService>
      <mx:Panel width="652" height="408">
      <mx:Button x="368" y="2" label="Lot_id" id="mybutton" click="myws.getCD.send()"/>
      </mx:Panel>

      when i use any string for sResult .it is working fine.but when i use xml string it is giving the error SOAP request error.
      i need ur help.
        • 1. Re: sending xml to webservice
          enzo1020vienna
          So i didn't know, if your question is still valid - but I had exactly the same problem and sovled it, using actionscript.
          The webservice operation has a request attribute, which accepts XML without problems. Short Example:
          <mx:WebService id="myWebService"
          wsdl="mywsdl"
          useProxy="false" showBusyCursor="true" load="wsLoad(event)">
          <mx:operation name="calculate" fault="wsFault(event)"
          result="wsResult(event)" />
          </mx:WebService>
          <mx:Script> /* ... */
          private function calculate():void {
          myRequestParameter:XML = <myXml/>;
          myWebService.calculate.request = myRequestParameter;
          myWebService.calculate.send();
          }
          /* ...... */
          </mx;Script>
          <mx:button click="calculate()" />