0 Replies Latest reply on Apr 18, 2008 6:25 AM by endi70

    EncodingError when Webservice and SoapHeader

    endi70
      Hi All,

      does anybody know a solution for this:

      Call a webservice works fine without identification. But to send Credentials I add a SoapHeader. Then I get an error #1009 The access to properties or methods of a null-objectreference is not allowed.
      And when I debug this it all stops in a operation.as at line 764. Here are the lines

      764 soap = encoder.encodeRequest(pc.args, pc.headers);
      }
      catch(fault:Fault)
      {
      dispatchRpcEvent(FaultEvent.createEvent(fault));
      return;
      }
      catch(error:Error)
      {
      var errorMsg:String = error.message ? error.message : "";
      var fault2:Fault = new Fault("EncodingError", errorMsg);
      var faultEvent:FaultEvent = FaultEvent.createEvent(fault2);
      dispatchRpcEvent(faultEvent);
      return;
      }

      And here is the code where I call the webservice:

      <?xml version="1.0" encoding="utf-8"?>
      <mx:WindowedApplication xmlns:mx=" http://www.adobe.com/2006/mxml" layout="vertical" height="186" width="316">

      <mx:WebService
      id="userRequest"
      wsdl=" http://mitbb01.make-it.local/mywebservice.nsf/wsecho?WSDL" load="headers();">

      <mx:operation name="ECHO" resultFormat="object"
      fault="mx.controls.Alert.show(event.fault.faultString)"
      result="showResult(event)" />
      </mx:WebService>

      <mx:Script>

      <![CDATA[
      // wsdl=" http://mitbb01.make-it.local/wsecho.WSDL" load="headers();">
      // wsdl=" http://mitbb01.make-it.local/mywebservice.nsf/wsecho?WSDL" load="headers();">
      // load="headers();"

      import mx.rpc.events.ResultEvent;
      import mx.rpc.events.FaultEvent;
      import mx.rpc.soap.*;
      import mx.rpc.soap.SOAPHeader;
      private var header1:SOAPHeader;

      public function headers():void {

      // Create QName and SOAPHeader objects.
      var q1:QName=new QName(" http://soapinterop.org/xsd", "Header1");
      header1=new SOAPHeader(q1, {userName:"admin makeit",Password:"kennwort"});

      // Add the header1 SOAP Header to all web service requests.
      userRequest.addHeader(header1);
      }


      private function showResult(e:ResultEvent):void
      {
      ti_Response.text = userRequest.ECHO.lastResult;
      }
      private function send_data(linie:String):void
      {
      userRequest.ECHO(linie);
      }
      ]]>

      </mx:Script>

      <mx:TextInput id="ti_Request" text="lalala"/>
      <mx:Button label="Send" click="send_data(ti_Request.text)" />
      <mx:TextInput id="ti_Response"/>

      </mx:WindowedApplication>

      What goes wrong. Is there a workaround. Please help. Thanx for any help in advance.

      Regards


      Andreas