Hi,

I am developing an application which needs to have a separate
installation for each client (i.e. Client1 will access the app via
www.mycomp.com/myapp/client1, Client2 will access the app via
www.mycomp.com/myapp/client2, etc). 

However, as I understand things from the documentation for
mx:RemoteObject and LCDS, the mxmlc compiler uses context-root
property (and other properties) in conjunction with the
remoting-config.xml and services-config.xml to build your swf file,
and basically hard-codes the context root into this file. This means
that I would have to recompile the app for each client - obviously far
from ideal.

Having googled extensively, I have amended my flex code as follows to
try and get around the above issue:

<code>
  ...

  public function init():void {
    var amfChannel:AMFChannel
        = new AMFChannel("my-amf", getContextRootUrl()
        + "/messagebroker/amf");
    amfChannel.pollingEnabled = false;
    var myChannelSet:ChannelSet = new ChannelSet();
    myChannelSet.addChannel(amfChannel);
    myService.channelSet = myChannelSet;
  }

  private function getContextRootUrl():String {
    var i:int = Application.application.url.lastIndexOf("/");
    var contextRootUrl:String
        = Application.application.url.substring(0, i);
    return contextRootUrl;
  }

  ...

  <mx:RemoteObject 
    id="myService"
    destination="MyService"
    endpoint="{getEndpointUrl()}/messagebroker/amf"
    showBusyCursor="true"
    result="event.token.resultHandler( event )"
    fault="event.token.faultHandler( event )"
    requestTimeout="30"/>

  ...
</code>

I have left my services-config.xml and remoting-config.xml files
unchanged:

services-config.xml:
<code>
  ...  

  <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"/>
    <properties>
      <polling-enabled>false</polling-enabled>
    </properties>
  </channel-definition>

  ...
</code>

remoting-config.xml:
<code>
  <?xml version="1.0" encoding="UTF-8"?>
  <service id="remoting-service" 
    class="flex.messaging.services.RemotingService" 
    messageTypes="flex.messaging.messages.RemotingMessage">

    <adapters>
      <adapter-definition id="java-object"
        class="flex.messaging.services.remoting.adapters.JavaAdapter"
        default="true"/>
    </adapters>

    <default-channels>
      <channel ref="my-amf"/>
    </default-channels>
    
    <destination id="MyService">
      <properties>
        <source>greetingService</source>
        <factory>spring</factory>
      </properties>
    </destination>

    ...  

  </service>
</code>

But when I run this my application just sits there with the message
"transferring data from localhost" in the browser statusbar, and I
just get the following in the server log:

<code>
[Flex] FlexSession created with id 'BA4C42E6D831EB63DE0D1434F2FE18F8'
for an Http-based client connection.
[Flex] Channel endpoint my-amf received request.
[Flex] Deserializing AMF/HTTP request
Version: 3
  (Message #0 targetURI=null, responseURI=/1)
    (Array #0)
      [0] = (Typed Object #0 'flex.messaging.messages.CommandMessage')
        operation = 5
        correlationId = ""
        timeToLive = 0
        messageId = "2E92B241-911C-415A-43CB-572AE0D5C7C9"
        timestamp = 0
        headers = (Object #1)
          DSId = "nil"
        body = (Object #2)
        clientId = null
        destination = ""

[Flex] Serializing AMF/HTTP response
Version: 3
  (Message #0 targetURI=/1/onResult, responseURI=)
    (Typed Object #0 'flex.messaging.messages.AcknowledgeMessage')
      timestamp = 1.195463337201E12
      headers = (Object #1)
        DSId = "8ACFB8D7-F70F-8E40-4804-8C86D86721EE"
      body = null
      correlationId = "2E92B241-911C-415A-43CB-572AE0D5C7C9"
      messageId = "8ACFB8F0-611A-3D28-E76F-46B3AAAFAB6E"
      timeToLive = 0.0
      clientId = "8ACFB8F0-610B-CE71-3071-807D68A228AF"
      destination = null
</code>

flashlog.txt:
<code>
11/19/2007 12:53:04.184 [INFO] mx.messaging.Producer
'E5FB0ACC-815D-67DA-FA20-57F8143815C0' producer set destination to
'MyService'.
authenticationWorkflowState: Dispatching Apply Permissions
11/19/2007 12:53:05.546 [INFO] mx.messaging.Producer
'E5FB0ACC-815D-67DA-FA20-57F8143815C0' producer sending message
'DB177CC3-9C87-B12D-2673-57F81980DBE7'
11/19/2007 12:53:05.556 [INFO] mx.messaging.Channel 'my-amf' channel
endpoint set to http://localhost:8080/myapp/messagebroker/amf
11/19/2007 12:53:05.556 [INFO] mx.messaging.Channel 'my-amf' channel
settings are:
<channel id="my-amf" type="mx.messaging.channels.AMFChannel">
  <endpoint
uri="http://{server.name}:{server.port}/myapp/messagebroker/amf"/>
  <properties>
    <polling-enabled>false</polling-enabled>
  </properties>
</channel>
11/19/2007 12:53:05.606 [INFO] mx.messaging.Producer
'E5FB0ACC-815D-67DA-FA20-57F8143815C0' producer sending message
'59988D12-B086-73BA-EFC8-57F819C635D4'
started
11/19/2007 12:53:05.616 [INFO] mx.messaging.Channel 'my-amf' channel
endpoint set to http://localhost:8080/myapp/messagebroker/amf
11/19/2007 12:53:05.656 [DEBUG] mx.messaging.Channel 'my-amf' pinging
endpoint.
11/19/2007 12:53:07.188 [INFO] mx.messaging.Channel 'my-amf' channel
is connected.
authenticationWorkflowState: Dispatching Apply Permissions
</code>  


I'm now completely confused - I don't know where I'm going wrong or
what to try next. Do I need to make changes to my services-config.xml
configuration? Do I still want to compile my app with -compiler option?

Perhaps I'm missing something obvious, or perhaps there is an easier
way to achieve what I'm trying to do?

Any help would be very much appreciated...

Thanks,

Lawrie.

Reply via email to