Hello,

If you would be more explicit...

1. Copy your EJB Remote interface to extend Remote instead. That's all you have 
to change. It's my com.irisel.oms.ws.OMBrowserEndpoint interface.

2. Modify your ejb-jar.xml to include <service-endpoint> like in my file, 
referencing the new interface we created in step 1.

3. Generate mappings, wsdl, etc. by running ant task (my ws_compile task). 
Delete the rest of the classes, we don't need them for the server, as it is the 
EJB which will serve the requests.

4. Write webservices.xml to associate mappings, wsdl, interface and EJB 
servant. This is the glue that make things work.

5. Packaging: Now include in the EJB Jar the ejb-jar.xml, mappings, wsdl 
description under META-INF/wsdl, jboss.xml and webservices.xml. I modified the 
packaging configuration that is explained in the JBoss tutorial for this 
purpose. You can derive my folder structure from my packaging-build.xml below.

At this point, install your EJB and make sure it is running by going to 
http://localhost:8080/ws4ee. View services and click on the wsdl link. It 
should show the wsdl description of your service.

5. Run ant task to generate client stubs. The web service must be up and 
running for it to retrieve the wsdl description. To create the task follow my 
target_wscompile_client. Some, if not all, of the generated classes are 
identical to those we deleted in step 3, but I change the destination package 
to ...ws.client for clarity. In the server package I only have the interface 
created in step 1.

6. Test the web service using the stubs generated. My test program is below. 
(My OMBrowserWebServiceLocator class extends the "Impl" class to be able to set 
the destination URL, which is hardcoded in the "Stub" class).

For me the most difficult part was to solve the references between the beans, 
the web app and the web service. It helped me very much the tips of the xml 
editor of JBoss IDE.

Hope it helps. If it works, tell us so !

Regards,
Jose.

packaging-build.xml:

<?xml version="1.0" encoding="UTF-8"?>
  | <project default="_packaging_generation_" name="Packaging Generator">
  | <target name="_packaging_generation_" 
depends="N400004,N40004F,N40007A,deploy"/>
  | <target name="N400004" description="OMBrowserEJB.jar">
  | <jar destfile="OMBrowserEJB.jar">
  | <zipfileset dir="src/META-INF" prefix="META-INF">
  | <include name="ejb-jar.xml"/>
  | </zipfileset>
  | <zipfileset dir="src/META-INF" prefix="META-INF">
  | <include name="jboss.xml"/>
  | </zipfileset>
  | <zipfileset dir="C:/IRISEL/eclipse/oms/ext/lib" prefix="lib">
  | <include name="mysql-connector.jar"/>
  | </zipfileset>
  | <zipfileset dir="src/META-INF/wsdl" prefix="META-INF/wsdl">
  | <include name="OMBrowserWebService.wsdl"/>
  | </zipfileset>
  | <zipfileset dir="src/META-INF" prefix="META-INF">
  | <include name="jaxrpc-mapping.xml"/>
  | </zipfileset>
  | <zipfileset dir="src/META-INF" prefix="META-INF">
  | <include name="webservices.xml"/>
  | </zipfileset>
  | <zipfileset dir="build" includes="com/**/*.class, com/**/*.properties"/>
  | <zipfileset dir="C:/IRISEL/eclipse/oms/build" includes="com/**/*.class, 
**/*.properties"/>
  | </jar>
  | </target>
  | <target name="N40004F" description="OMBrowser.war">
  | <jar destfile="OMBrowser.war">
  | <zipfileset dir="src/WEB-INF" prefix="WEB-INF">
  | <include name="web.xml"/>
  | </zipfileset>
  | <zipfileset dir="src/WEB-INF" prefix="WEB-INF">
  | <include name="jboss-web.xml"/>
  | </zipfileset>
  | <zipfileset dir="build" prefix="WEB-INF/classes" 
includes="com/irisel/oms/servlet/*.class"/>
  | <zipfileset dir="html"/>
  | </jar>
  | </target>
  | <target name="N40007A" description="OMBrowser.ear">
  | <jar destfile="OMBrowser.ear">
  | <zipfileset dir="src/META-INF" prefix="META-INF">
  | <include name="application.xml"/>
  | </zipfileset>
  | <zipfileset dir=".">
  | <include name="OMBrowserEJB.jar"/>
  | </zipfileset>
  | <zipfileset dir=".">
  | <include name="OMBrowser.war"/>
  | </zipfileset>
  | </jar>
  | </target>
  | <target name="deploy">
  |     <!--<property name="jboss.deploy" value="C:\Program 
Files\JBoss-4.0.4RC1\server\default\deploy" />-->
  |     <copy overwrite="true" file="OMBrowser.ear" tofile="C:\Program 
Files\JBoss-4.0.4RC1\server\default\deploy\OMBrowser.ear" >
  |     </copy> 
  | </target>
  | </project>
  | 

Test program:


  | 
  | package com.irisel.oms.ws.client;
  | 
  | import org.apache.log4j.Logger;
  | 
  | import com.irisel.oms.olapi.beans.AppVO;
  | import com.irisel.oms.olapi.beans.XMLBean;
  | 
  | import junit.framework.*;
  | 
  | public class OMBrowserWebServiceTest extends TestCase {
  | 
  |     public static final String KEY_WS_PORT = "wsPort";
  | 
  |     OMBrowserWebServiceLocator locator;
  |     com.irisel.oms.ws.client.OMBrowserEndpoint svc; 
  |     com.irisel.modules.PackageConfiguration config;
  |     Logger log4j;
  |     
  |     public static Test suite() {
  |             return new TestSuite(OMBrowserWebServiceTest.class);
  |     }
  |     
  |     protected void setUp() {
  |         try {               
  |             log4j = Logger.getLogger(this.getClass());
  |             
  |                     // Load Configuration
  |                     final java.io.InputStream in = 
getClass().getResourceAsStream(
  |                                     "/config.properties");
  | 
  |                     this.config = 
com.irisel.modules.PackageManager.getInstance()
  |                                     .getPackageConfiguration();
  |             
  |                     locator = new OMBrowserWebServiceLocator();
  |                     this.config.load(in);
  |                     String wsPort = config.getConfigProperty(KEY_WS_PORT);
  |                     log4j.info("Web Service Port: "+wsPort);
  |                     svc = locator.getOMBrowserEndpointPort(wsPort); 
  |         }
  |         catch (Exception e) {
  |             e.printStackTrace();
  |         }
  |     }
  |     
  |     public void testEcho() {
  |             try {
  |                     assertEquals(svc.echo("hola!"),"HOLA!");
  |             } catch (Throwable e) {
  |                     fail(e.getMessage());
  |             }
  |     }
  | 
  | 
  |     /**
  |      * @param args
  |      */
  |     public static void main(String[] args) {
  |             junit.textui.TestRunner.run(suite());
  |     }
  |     
  | }
  | 

View the original post : 
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3934044#3934044

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3934044


-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
JBoss-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to