2 Replies Latest reply on Aug 13, 2007 1:04 AM by JamesWilliams

    WebService WSDL problem

      Hi all.

      I have a component that calls a WebService to populate some labels - very simple really. However I don't want to hard-code the wsdl string in the code - I want to be able to control it from an xml file in the same folder as the swf. There is no problem reading in the value from the xml file using an HTTPService (I can get it to display successfully on a label for example), but when I try to use this value for the wsdl of the WebService I get the following error: 'Cannot access a property or method of a null object reference'. Both send() functions are called on the creationComplete event of the container panel, one immediately after the other - is there something I need to do in between? I know the WebService works because I can call it from a button - but I can't put it on a button - I need it to all happen automatically.

      Below are the code snippetts in question:

      <mx:Panel xmlns:mx=" http://www.adobe.com/2006/mxml" layout="absolute"
      width="280" height="200" title="Broker Details"

      private function loadBrokerDetails(event: Event): void
      // Read in the web service location from the settings xml file
      // Call the web service to retrieve the broker details
      ws_SourceCommon.getBroker.send(); // Change the state to play the transition
      currentState = 'DisplayState';

      <!-- Application settings XML file (custom file created by us) -->
      <mx:HTTPService id="xml_Settings" url="settings_BrokerDetails.xml"/>

      <!-- Web service to retrieve the broker details -->
      <!-- I have tried setting the wsdl string here, but don't even get an error - it just doesn't work -->

      <!-- GetBroker method declaration -->
      <mx:operation name="getBroker">
        • 1. Re: WebService WSDL problem
          mitchgrrt Level 1
          You posted this a couple of months ago and probably you have solved it already. Nevertheless ...

          You are using the wsdl too early. You're loading it from a file, calling send(), but then trying to use the result immediately in the next statement before the send() has come back. You need to have a callback method, I think it would be on the RESULT event, that gets called when the send() returns. Inside that callback method use the wsdl. It should work better.
          • 2. Re: WebService WSDL problem
            JamesWilliams Level 1
            Hi there - thanks for the answer. You're absolutely right: I got there in the end on my own - I'm getting to grips with the use of events now. Should have posted the answer myself but forgot.

            Cheers anyway