1 Reply Latest reply on Feb 8, 2011 9:37 PM by da-juice

    Drupal SOAP and Flashbuilder 4

    da-juice Level 1

      I've been hitting a brick wall of being able to easily access services for drupal from flash builder 4.  At first i figured AMFPHP is the way to go, but with the release of Drupal 7 the support for AMF is seriously outdated.  Next XMLRPC.  I tried the DCD wizard in Flex to connect to XMLRPC but then realized i would need a seperate library to make it work.  Next SOAP.  Soap server is running and i can connect with drupalsite/services/soap?wsdl.  However using the DCD wizard with WSDL connection also doesnt work, it doesnt give any errors but also doesnt go to the next screen of the wizard to bring up the operations.

       

      I think the issue is that the operations names in Drupal SOAP server all have a "." in the name, ie node.get is an operation.  So I started to see how to manually connect to it.  I am able to connect via PHP and get a use the node.get method and get a result using this:

       

      ------------

      $wsdl = "http://localhost/mysite/services/soap?wsdl";
      $client = new SoapClient($wsdl)
      $client->debug_flag=true;
      $nid = 4;
      $param1['nid'] = $nid; //Set nid

      $result = $client->__soapCall('node.get', $param1);

      ----------

       

      Now when i try this in actionscript i have 2 issues.

      1 - the operation name has a "." in the name so i cannot use the <mx:operator name="node.get"> to access the method, instead i am using the getOperation('node.get').send in order to access

      2 - i cannot figure out why i cannot pass the parameters to the function.  When i try this I always get the error "Array of input arguments did not contain a required parameter at position 1"

       

      Here is my actionscript code.  Any assistance would be greatly appreciated!  Im pretty new to actionscript so maybe im missing something.

      I have also tried to load the parameters with:

      var oRequest:Object = {nid:4};  

       

      var oRequest:Object = {'nid':4};  

       

      var oRequest:Object = new Object;

           oRequest.nid = 4;

       

      all of which resulted in the same error.

       

      <?xml version="1.0" encoding="utf-8"?>
      <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
                     xmlns:s="library://ns.adobe.com/flex/spark"
                     xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600">

       

          <fx:Script>
              <![CDATA[
                  import mx.controls.Alert;
                  import mx.rpc.AsyncToken;
                  import mx.rpc.Fault;
                  import mx.rpc.events.FaultEvent;
                  import mx.rpc.events.ResultEvent;
                  import mx.rpc.soap.WebService;
                             
                  private function getinfo_clickHandler(event:MouseEvent):void
                  {
                      var oRequest:Object = {'nid':'4'};               
                      drupalServices.getOperation('node.get').send(oRequest);   
                  }
                  private function onResult(event:ResultEvent):void
                  {
                      Alert.show('Success');
                  }
                  private function onFault(event:FaultEvent):void
                  {
                      Alert.show(event.fault.faultString, 'Error');
                  }
              ]]>
          </fx:Script>

       

          <fx:Declarations>
              <s:WebService id="drupalServices" wsdl="http://localhost/mysite/services/soap?wsdl"
                            fault="onFault(event)"                       
                            result="onResult(event)">
              </s:WebService>
             
          </fx:Declarations>
              <s:Button x="323" y="-29" label="Get Info" width="111" id="getinfo" click="getinfo_clickHandler(event)"/>
      </s:Application>