1 Reply Latest reply on Jun 10, 2007 10:14 PM by mxc4

    How to avoid redeclaring your web service interface?

      Hi there,

      How can one avoid having to redeclare your wsdl interface on each mxml page where it is accessed? I only want to declare the web service and the operation is has once and then just include it in the component where I use it to access/update data.

      I am new to flex so this may be obviouse to other but not me. I tried including it in its own mxml file and then using the normal component include tag to include it. I get errors about not being able to access the webservice via its id.


      Error: Access of undefined property WebService.
      [mxmlc] WebService.getSiteOptions.send();

        • 1. Re: How to avoid redeclaring your web service interface?
          mxc4 Level 1
          The solution is to place the web definition in a separate file and then use the "include" like functionality of defining your own namespace in the xml. You do the include in the main application file.

          xmlns:mx=" http://www.adobe.com/2006/mxml"
          title="Reports Menu"
          creationComplete="onInit();" >

          On the main application page to include your web service file do a

          <webservice:webservices id="services"/>

          The webservices.mxml file will contain your definitions.

          <?xml version="1.0" encoding="utf-8"?>
          <mx:Canvas xmlns:mx=" http://www.adobe.com/2006/mxml"

          import mx.rpc.soap.mxml.WebService;
          import mx.rpc.events.FaultEvent;
          import mx.controls.Alert;

          public var webServiceWSDL:String ="";
          public function onServiceFault(evt:FaultEvent):void
          var err:Error = new Error(evt.fault.faultCode + " , " + evt.fault.faultString);

          public function onSuccess(evt:Event):void


          <!-- ======================================== -->
          <!-- Remote Services -->
          <!-- ======================================== -->

          <mx:WebService id="webservice" wsdl="{this.webServiceWSDL}" service="ValueAddWebService" port="AppWebServiceHttpPort" fault="onServiceFault(event)" showBusyCursor="true" >


          In your child components you can refer to the component by doing a "parentApplication.services.webservice"