1 Reply Latest reply on Mar 24, 2011 8:57 AM by injpix

    BlazeDS Service creation

    RafaelViana_

      Hi,

       

      Which class does BlazeDS use to create the remote service object?

       

      e.g: I say to the BlazeDS the destination. (e.g = "helloWorldService"). So, where this destination is turned into a concrete class?

        • 1. Re: BlazeDS Service creation
          injpix Level 3

          I am fairly new to BlazeDS, but from my understanding is that, the remote objects are created by hand.  They're Java objects, POJOs.  Then on the server, in the services-config.xml, you would create your end-point.

           

          <!-- services-config.xml -->
          ...
          <channels>
               <channel-definition id="my-amf" class="mx.messaging.channels.AMFChannel">
                    <endpoint url="http://{server.name}:{server.port}/{context.root}/messagebroker/amf" class="flex.messaging.endpoints.AMFEndpoint"/>
               </channel-definition>
          </channels>
          ...
          

           

          You will then need to config the web.xml to handle the servlets...

          <!-- web.xml -->
          ...
          <servlet>
              <servlet-name>dispatcherServlet</servlet-name>
              <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
              <load-on-startup>1</load-on-startup>
          </servlet>
           <servlet-mapping>
              <servlet-name>dispatcherServlet</servlet-name>
              <url-pattern>/messagebroker/*</url-pattern>
          </servlet-mapping>
          
          <servlet>
              <servlet-name>RDSDispatchServlet</servlet-name>
              <display-name>RDSDispatchServlet</display-name>
              <servlet-class>flex.rds.server.servlet.FrontEndServlet</servlet-class>
              <init-param>
                   <param-name>messageBrokerId</param-name>
                   <param-value>_messageBroker</param-value>
              </init-param>
              <init-param>
                   <param-name>useAppserverSecurity</param-name>
                   <param-value>false</param-value>
              </init-param>
              <load-on-startup>10</load-on-startup>
          </servlet>
          <servlet-mapping id="RDS_DISPATCH_MAPPING">
              <servlet-name>RDSDispatchServlet</servlet-name>
              <url-pattern>/CFIDE/main/ide.cfm</url-pattern>
          </servlet-mapping>
          ...
          

           

          If you are asking about what remote class is mirrored for the Flex application, the data wizard in Flash Builder generated a com.adobe.fiber.services.wrapper.RemoteObjectServiceWrapper  sub-class for my remote service.  In the construct of this sub-class, it has the following:

           

              public function _Super_Foo()
              {
                  // initialize service control
                  _serviceControl = new mx.rpc.remoting.RemoteObject();
          
                  // initialize RemoteClass alias for all entities returned by functions of this service
                  valueObjects.Bar._initRemoteClassAlias();
          
                  var operations:Object = new Object();
                  var operation:mx.rpc.remoting.Operation;
          
                  operation = new mx.rpc.remoting.Operation(null, "getBars");
                   operation.resultElementType = valueObjects.Bar;
                  operations["getBars"] = operation;
                  operation = new mx.rpc.remoting.Operation(null, "addBar");
                  operations["addBar"] = operation;
                  operation = new mx.rpc.remoting.Operation(null, "removeBar");
                  operations["removeBar"] = operation;
          
                  _serviceControl.operations = operations;
                  _serviceControl.convertResultHandler = com.adobe.serializers.utility.TypeUtility.convertResultHandler;
                  _serviceControl.endpoint = "http://localhost:8080//messagebroker/amf";
                  destination = "foo";
          
          
          
                   model_internal::initialize();
              }
          

           

          The remote service that I have is a Java class named 'Foo'.  Notice the destination is 'foo'.

           

          I'm using Spring BlazeDS with Hibernate, so there my be some differences.  The only references that I have used to grasp Spring BlazeDS is from James Ward.  All of the code above, is mostly explained by him in the following references.