Skip navigation
Anshul108
Currently Being Moderated

LifeCycle DS ES communication with Tomcat WebServer

Dec 1, 2011 5:17 AM

Hi,

    I have written a simple program to accept Name using Flex SDK 3.2 HttpService in Flex builder 3. Using LifeCycle DS ES to communicate with struts 1.2 on Web Server(Tomcat 5.0). My flex code runs and Struts code runs independently. The problem is when trying to send data from client to Server, it does not work. Below given are my client ans Server side code. Copy of services-config.xml & proxy-config.xml is same on both client side and server side. Please help me to run this code.

 

Client Side
========

 

hello.mxml
-----------------

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:Script>
<![CDATA[
  public function hello1():void{
   HelloCall.send();
  }
]]>
</mx:Script>

<mx:HTTPService id= "HelloCall" destination= "myHello">
    <mx:request xmlns= " ">
            <name>  {nameInput.text}</name>
    </mx:request>
</mx:HTTPService>

<mx:Label x= "312" y= "47" text= "Enter Name" fontSize= "20" />
<mx:TextInput id= "nameInput" x="260" y= "104" fontSize= "20" />
<mx:Button x= "301" y= "186" label= "Submit" fontSize= "20" click= "hello1();" />
<mx:Label x= "312" y= "285" text= "{HelloCall.lastResult.jlc.message}" fontSize= "20" />
</mx:Application>


Server-Side
============

proxy-config.xml
----------------

<?xml version="1.0" encoding="UTF-8"?>
<service id="proxy-service"
    class="flex.messaging.services.HTTPProxyService">

    <properties>
        <connection-manager>
            <max-total-connections>100</max-total-connections>
            <default-max-connections-per-host>2</default-max-connections-per-host >
        </connection-manager>
        <allow-lax-ssl>true</allow-lax-ssl>
    </properties>

    <adapters>
        <adapter-definition id="http-proxy" class="flex.messaging.services.http.HTTPProxyAdapter" default="true"/>
        <adapter-definition id="soap-proxy" class="flex.messaging.services.http.SOAPProxyAdapter"/>
    </adapters>

    <default-channels>
        <channel ref="my-http"/>
        <channel ref="my-amf"/>
    </default-channels>

  

<destination id="myHello">
    <properties>
         <url>/http://localhost:8000/JLCAPP/hello.jsp</url>
    </properties>
</destination>
</service>


struts-config.xml
------------------

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.2//EN" "http://struts.apache.org/dtds/struts-config_1_2.dtd">

<struts-config> 

  <form-beans>

       <form-bean name= "helloForm" type= "org.apache.struts.action.DynaActionForm">
              <form-property name= "name" type="java.lang.String" />
       </form-bean>
   </form-beans>

  <global-forwards>
  <forward name= "success" path= "/index.jsp" />
  </global-forwards>
 

<action-mappings>
    <action path= "/hello" name= "helloForm" type="com.jlcindia.struts.HelloAction" input= "/hello.html" />

</action-mappings>

  <message-resources parameter="com.jlcindia.struts.ApplicationResources" />
</struts-config>

 

services-config.xml
-----------------------------

<?xml version="1.0" encoding="UTF-8"?>
<services-config>

    <services>
        <service-include file-path="remoting-config.xml" />
        <service-include file-path="proxy-config.xml" />
        <service-include file-path="messaging-config.xml" />
        <service-include file-path="data-management-config.xml" />
        <service class="fiber.data.services.ModelDeploymentService" id="model-deploy-service" />
       
        <!--
     Application level default channels. Application level default channels are
     necessary when a dynamic destination is being used by a service component
     and no ChannelSet has been defined for the service component. In that case,
     application level default channels will be used to contact the destination.
        -->  
        <default-channels>
           <channel ref="my-rtmp"/>
        </default-channels>

    </services>

    <security>
  <login-command class="flex.messaging.security.TomcatLoginCommand" server="Tomcat"/>       
        <!-- Uncomment the correct app server
        <login-command class="flex.messaging.security.JRunLoginCommand" server="JRun"/>
        <login-command class="flex.messaging.security.WeblogicLoginCommand" server="Weblogic"/>
        <login-command class="flex.messaging.security.WebSphereLoginCommand" server="WebSphere"/>
        -->
        <security-constraint id="basic-read-access">
            <auth-method>Basic</auth-method>
            <roles>
                <role>guests</role>
                <role>accountants</role>
                <role>employees</role>
                <role>managers</role>
            </roles>
        </security-constraint>
    </security>

    <!-- Socket servers that NIO endpoints all share -->
    <servers>
        <server id="my-nio-server" class="flex.messaging.socketserver.SocketServer">
        </server>
        <!--
        <server id="secure-nio-server" class="flex.messaging.socketserver.SocketServer">
            <properties>
                <keystore-file>{context.root}/WEB-INF/flex/localhost.keystore</keysto re-file>
                <keystore-password>changeit</keystore-password>
            </properties>
        </server>
        -->
    </servers>

    <channels>

        <!-- Servlet Based endpoints -->
        <channel-definition id="my-amf" class="mx.messaging.channels.AMFChannel">
            <endpoint url="http://localhost:8400/JLCAPP/messagebroker/amf" class="flex.messaging.endpoints.AMFEndpoint"/>
            <properties>
                <polling-enabled>false</polling-enabled>
            </properties>
        </channel-definition>

        <channel-definition id="my-polling-amf" class="mx.messaging.channels.AMFChannel">
            <endpoint url="http://localhost:8400/JLCAPP/messagebroker/amfpolling" class="flex.messaging.endpoints.AMFEndpoint"/>
            <properties>
                <polling-enabled>true</polling-enabled>
                <polling-interval-seconds>8</polling-interval-seconds>
            </properties>
        </channel-definition>

        <channel-definition id="my-http" class="mx.messaging.channels.HTTPChannel">
            <endpoint url="http://{server.name}:{server.port}/{context.root}/messagebroker/http" class="flex.messaging.endpoints.HTTPEndpoint"/>
        </channel-definition>

        <!-- Secure Servlet-based endpoints -->
        <channel-definition id="my-secure-amf" class="mx.messaging.channels.SecureAMFChannel">
            <endpoint url="https://{server.name}:{server.port}/{context.root}/messagebroker/amfse cure" class="flex.messaging.endpoints.SecureAMFEndpoint"/>
            <properties>
                <!--HTTPS requests on some browsers do not work when pragma "no-cache" are set-->
                <add-no-cache-headers>false</add-no-cache-headers>
            </properties>
        </channel-definition>

        <channel-definition id="my-secure-http" class="mx.messaging.channels.SecureHTTPChannel">
            <endpoint url="https://{server.name}:{server.port}/{context.root}/messagebroker/https ecure" class="flex.messaging.endpoints.SecureHTTPEndpoint"/>
            <properties>
             <!--HTTPS requests on some browsers do not work when pragma "no-cache" are set-->
                <add-no-cache-headers>false</add-no-cache-headers>
            </properties>
        </channel-definition>

        <!-- NIO based endpoints -->
        <channel-definition id="my-rtmp" class="mx.messaging.channels.RTMPChannel">
            <endpoint url="rtmp://{server.name}:2048" class="flex.messaging.endpoints.RTMPEndpoint"/>
            <properties>
                <idle-timeout-minutes>20</idle-timeout-minutes>
                <!-- for deployment on WebSphere, must be mapped to a WorkManager available in the web application's jndi context.
                <websphere-workmanager-jndi-name>java:comp/env/wm/MessagingWorkManage r</websphere-workmanager-jndi-name>
                -->
            </properties>
        </channel-definition>

        <channel-definition id="my-nio-amf" class="mx.messaging.channels.AMFChannel">
            <endpoint url="http://{server.name}:2888/nioamf" class="flex.messaging.endpoints.NIOAMFEndpoint"/>
            <server ref="my-nio-server"/>
            <properties>
                <polling-enabled>false</polling-enabled>
            </properties>
        </channel-definition>

        <channel-definition id="my-nio-amf-poll" class="mx.messaging.channels.AMFChannel">
            <endpoint url="http://{server.name}:2888/nioamfpoll" class="flex.messaging.endpoints.NIOAMFEndpoint"/>
            <server ref="my-nio-server"/>
            <properties>
                <polling-enabled>true</polling-enabled>
                <polling-interval-millis>3000</polling-interval-millis>
            </properties>
        </channel-definition>

        <channel-definition id="my-nio-http" class="mx.messaging.channels.HTTPChannel">
            <endpoint url="http://{server.name}:2888/niohttp" class="flex.messaging.endpoints.NIOHTTPEndpoint"/>
            <server ref="my-nio-server"/>
            <properties>
                <polling-enabled>false</polling-enabled>
            </properties>
        </channel-definition>

        <!-- Secure NIO based endpoints -->
        <!--
        <channel-definition id="secure-nio-amf" class="mx.messaging.channels.SecureAMFChannel">
            <endpoint url="https://{server.name}:2443/securenioamf" class="flex.messaging.endpoints.SecureNIOAMFEndpoint"/>
            <server ref="secure-nio-server"/>
            <properties>
                <polling-enabled>false</polling-enabled>
            </properties>
        </channel-definition>

        <channel-definition id="secure-nio-http" class="mx.messaging.channels.SecureHTTPChannel">
            <endpoint url="https://{server.name}:2443/secureniohttp" class="flex.messaging.endpoints.SecureNIOHTTPEndpoint"/>
            <server ref="secure-nio-server"/>
            <properties>
                <polling-enabled>false</polling-enabled>
            </properties>
        </channel-definition>
        -->
    </channels>

    <logging>
        <target class="flex.messaging.log.ConsoleTarget" level="Debug">
            <properties>
                <prefix>[LCDS] </prefix>
                <includeDate>false</includeDate>
                <includeTime>false</includeTime>
                <includeLevel>false</includeLevel>
                <includeCategory>false</includeCategory>
            </properties>
            <filters>
                <pattern>Endpoint.*</pattern>
                <pattern>Service.*</pattern>
                <pattern>Configuration</pattern>
                <pattern>SocketServer.*</pattern>
            </filters>
        </target>
    </logging>

    <system>
        <redeploy>
            <enabled>true</enabled>
            <watch-interval>20</watch-interval>
            <watch-file>{context.root}/WEB-INF/flex/services-config.xml</watch-fi le>
            <watch-file>{context.root}/WEB-INF/flex/proxy-config.xml</watch-file>
            <watch-file>{context.root}/WEB-INF/flex/remoting-config.xml</watch-fi le>
            <watch-file>{context.root}/WEB-INF/flex/messaging-config.xml</watch-f ile>
            <watch-file>{context.root}/WEB-INF/flex/data-management-config.xml</w atch-file>
            <touch-file>{context.root}/WEB-INF/web.xml</touch-file>
        </redeploy>
    </system>

</services-config>


HelloAction.java
------------------

package com.jlcindia.struts;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.*;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.DynaActionForm;

import java.io.PrintWriter;

public class HelloAction extends Action{

 

public ActionForward execute(ActionMapping am,ActionForm af,HttpServletRequest req,HttpServletResponse res) throws Exception {

 

    System.out.println("Hi am here");
    DynaActionForm daf= (DynaActionForm)af;
    String name= daf.get("name").toString();
    String msg= "Hello!"+ name + "Welcome to JLC FLex LCDS with HttpService";
    res.setContentType("text/html");
    PrintWriter out= res.getWriter();
    out.println("<message>" + msg + "</message>");
    out.close();
    return am.findForward("success");
}
}

 

Any Help will be appriciated.


 
Replies
  • Currently Being Moderated
    Dec 1, 2011 6:26 AM   in reply to Anshul108

    What version of standalone LCDS are you using?

     

    Rohit

     
    |
    Mark as:
  • Currently Being Moderated
    Dec 1, 2011 10:52 AM   in reply to Anshul108

    The URL specified in the proxy destination is a relative URL (has an extra "/" in it). This would end up adding the LCDS server, port to the existing URL to convert it to an absolute URL e.g. http://<server.name}:{server.port}/{context.root}/<URLInDestination>

     

    Hope that helps!

    Rohit

     
    |
    Mark as:
  • Currently Being Moderated
    Dec 1, 2011 8:53 PM   in reply to Anshul108

    Is the request reaching the LCDS server? What do the LCDS debug logs say?

    What do the Flex logs say?

     

    Rohit

     
    |
    Mark as:
  • Currently Being Moderated
    Dec 2, 2011 4:28 AM   in reply to Anshul108

    [Inline]

     

    I have two doubts -

     

    1. Do I need to import rpc.swc in my Flex project lib folder?

    You need the rpc.swc in order to communicate. That said, it should automatically get included by the project when you create one.

     

    2. There are 2 tomcat servers running on my system, one by LiveCycle DS ES(port No : 8400) and second on my WebServer Tomcat(prot No : 8000).

        The url that I specify in proxy-config.xml should contain Port No of Webserver 

    i.e. http://localhost:8000/JLCAPP/hello.jsp

        or port no of LiveCycle DS ES

      i.e. http://localhost:8400/JLCAPP/hello.jsp

    Specify the URL location where hello.jsp is hosted. In this case, it seems from your desc, the file is present on the WebServer, hence specify 8000.

     

     

    I installed Windows Flash Player 11.1 ActiveX control content debugger (for IE) and got the following Debug information :-


    [RPC Fault faultString="Send failed" faultCode="Client.Error.MessageSend" faultDetail="Channel.Connect.Failed error NetConnection.Call.Failed: HTTP: Status 404: url: 'http://localhost:8400/JLCAPP/messagebroker/amf'"]
    at mx.rpc::AbstractInvoker/http://www.adobe.com/2006/flex/mx/internal::faultHandler()[C:\autobuild\3.2.0\frameworks\projects\rpc\src\mx\rpc\AbstractInvok er.as:220]
    at mx.rpc::Responder/fault()[C:\autobuild\3.2.0\frameworks\projects\rpc\ src\mx\rpc\Responder.as:53]
    at mx.rpc::AsyncRequest/fault()[C:\autobuild\3.2.0\frameworks\projects\r pc\src\mx\rpc\AsyncRequest.as:103]
    at mx.messaging::ChannelSet/faultPendingSends()[C:\autobuild\3.2.0\frame works\projects\rpc\src\mx\messaging\ChannelSet.as:1482]
    at mx.messaging::ChannelSet/channelFaultHandler()[C:\autobuild\3.2.0\fra meworks\projects\rpc\src\mx\messaging\ChannelSet.as:975]
    at flash.events::EventDispatcher/dispatchEventFunction()
    at flash.events::EventDispatcher/dispatchEvent()
    at mx.messaging::Channel/connectFailed()[C:\autobuild\3.2.0\frameworks\p rojects\rpc\src\mx\messaging\Channel.as:997]
    at mx.messaging.channels::PollingChannel/connectFailed()[C:\autobuild\3. 2.0\frameworks\projects\rpc\src\mx\messaging\channels\PollingChannel. a s:354]
    at mx.messaging.channels::AMFChannel/statusHandler()[C:\autobuild\3.2.0\ frameworks\projects\rpc\src\mx\messaging\channels\AMFChannel.as:390]

     

    From the trace, it looks like the channel connection itself failed. Either the channel declaration does not match the one given in services-config.xml, or possibly the swf is being accessed from a machine that is different from the one on which the LCDS server is running. In that case, use {server.name}, {server.port} tokens in the URL in services.config.xml.

     

    Hope that helps!

    Rohit

     
    |
    Mark as:
  • Currently Being Moderated
    Dec 2, 2011 12:07 PM   in reply to Anshul108

    Hi Anshul,

     

    As per your previous post, DS was deployed on port 8400 and web server on port 8000. Your servlet channels should have the DS port# (8400) in its URL. The channel declaration in services-config.xml has port 8000, which is clearly incorrect and that explains the error you are seeing on the client side.

     

    Also, how will the webserver tomcat log show entries from DS server. That seems an anomaly as well.

     

    Rohit

     
    |
    Mark as:
  • Currently Being Moderated
    Dec 5, 2011 10:43 PM   in reply to Anshul108

    Ensure that your LCDS webapp is deployed under JLCAPP. How are you exposing your message broker servlet in web.xml? As per your config above, message broker servlet should be exposed as /messagebroker.

     

    Rohit

     
    |
    Mark as:
  • Currently Being Moderated
    Dec 6, 2011 5:00 AM   in reply to Anshul108

    At this point, it's best to contact support team in order to debug/resolve your particular scenario.

     

    Rohit

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points