Expand my Community achievements bar.

LifeCycle DS ES communication with Web Server

Avatar

Level 2

Hi,

    I have written a simple Flex 3.2 code that accepts Name, uses Flext HttpService via LifeCycle DS ES 3.0. At the Server Side I am using Struts1.2 on Tomcat 5.0. My Flex code is running and Server side Struts code is running. The problem is the Name accepted on Client Side is not displaying on Server side JSP page. Below is the Client Side & Server Side code.

Client Side

=========

hello.mxml

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

<?xml version="1.0" encoding="utf-8"?>

<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">

<![CDATA[

public function hello1():void{

HelloCall.send();

}

]]>

 

</mx:Script>

<mx:HTTPService id= "HelloCall" destination= "myHello">

      <mx:request  xmlns= " " >

<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>

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">
    </destination>

</service>

           <name>     {nameInput.text}</name>

      </mx:request>

  </mx:HTTPService>

<mx:Label  x= "312" y= "47" text= "Enter Name" fontSize= "20" />

5 Replies

Avatar

Employee

I believe JEE LCDS 3.0  is not supported on Tomcat 5. Also the MXML snippet put forth is malformed.

Rohit

Avatar

Level 2

Hi Rohit,

     Yes, that seems to be one problem. Will switch to Tomcat 6.0 on web server.

Thank You.

Anshul.

Avatar

Employee

Ok good.

While we are at:

[1] You haven't specified the URL for the server side JSP. E.g. The destination decl in proxy-config.xml can specify the URL as follows:

<destination id="myHello">

     <properties>

          <url>/{context.root}/testdrive-httpservice/catalog.jsp</url>

     </properties>

</destination>

Rohit

[2] The HTTPService declartion and request structures should be declared together:

<mx:HTTPService id= "HelloCall" destination= "myHello">

      <mx:request  xmlns= " " >

           <name>{nameInput.text}</name>

      </mx:request>

</mx:HTTPService>

Avatar

Level 2

Alright Rohit,  Here is the complete snippet, both client side & server side.

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</keystore-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/amfsecure" 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/httpsecure" 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/MessagingWorkManager</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-file>
            <watch-file>{context.root}/WEB-INF/flex/proxy-config.xml</watch-file>
            <watch-file>{context.root}/WEB-INF/flex/remoting-config.xml</watch-file>
            <watch-file>{context.root}/WEB-INF/flex/messaging-config.xml</watch-file>
            <watch-file>{context.root}/WEB-INF/flex/data-management-config.xml</watch-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");
}
}

It seems that the WebServer is not receiving the message from LCDS ES Server. As I have used println statement in Action Class but noting gets printed. 

Avatar

Employee

Anshul, use one forum thread to track the issue. So, choose one, either this or the other one

Rohit