[jboss-cvs] JBoss Messaging SVN: r2703 - in trunk/docs/examples/web-services: src-client/org/jboss/example/jms/webservices/client and 1 other directory.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu May 17 14:14:07 EDT 2007
Author: clebert.suconic at jboss.com
Date: 2007-05-17 14:14:07 -0400 (Thu, 17 May 2007)
New Revision: 2703
Modified:
trunk/docs/examples/web-services/README.html
trunk/docs/examples/web-services/build.xml
trunk/docs/examples/web-services/src-client/org/jboss/example/jms/webservices/client/Client.java
Log:
http://jira.jboss.org/jira/browse/JBMESSAGING-961
Modified: trunk/docs/examples/web-services/README.html
===================================================================
--- trunk/docs/examples/web-services/README.html 2007-05-17 16:32:40 UTC (rev 2702)
+++ trunk/docs/examples/web-services/README.html 2007-05-17 18:14:07 UTC (rev 2703)
@@ -1 +1,189 @@
-TODO!
\ No newline at end of file
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+<head>
+ <meta content="text/html; charset=ISO-8859-1"
+ http-equiv="content-type">
+ <title>JBoss Messaging Example - WebSerivce Environment</title>
+</head>
+<body>
+<br>
+<h1>Sending JMS messages from a WebService<br>
+</h1>
+<h2>Overview</h2>
+<br>
+This example deploys a WebServices that sends messages to a queue.
+The same client will then read the message from the queue, validating
+if the WebService could complete the message send.
+<br>
+This example relies on having access to a running JBoss Messaging
+instance.
+The JBoss Messaging instance must be installed and started according to
+the
+"Installation" paragraph from the release documentation. However,
+the example will automatically deploy its own queue, unless a queue
+with the same name is already deployed. <br>
+<br>
+This example also relies on having access to <span
+ style="font-family: monospace;">jboss-messaging-client.jar</span>
+archive that comes with the release bundle. If you run this example
+from
+an unzipped installation bundle, the example run script is correctly
+configured to find the client jar. Otherwise, you must modify example's
+<span style="font-family: monospace;">build.xml</span>
+accordingly. <br>
+<br>
+This example will also generate client classes using wsdltools from
+JBoss Web Services.<br>
+<br>
+<span style="font-style: italic;">The example was designed to deploy
+its server-side artifacts under a JBoss' messaging
+configuration. If you intend to use the script with a JBoss
+configuration that is named differently, please modify the
+example's build.xml accordingly.<br>
+<span style="font-style: italic;"></span><br>
+<span style="font-style: italic;"></span><br>
+<br>
+<h2>Running the example</h2>
+1. Set up the JBOSS_HOME environment variable to point to the JBoss
+instance you deployed JBoss Messaging into. For example, if you
+deployed JBoss Messaging in <span style="font-family: monospace;">C:\jboss-4.2.0.GA\server\messaging\deploy,</span>
+then your JBOSS_HOME value should be <span
+ style="font-family: monospace;">C:\</span><span
+ style="font-family: monospace;">jboss-4.2.0.GA</span><br>
+<span style="font-family: monospace;"></span><br>
+2. Go to the example's home directory<br>
+<br>
+<div style="margin-left: 40px;"><span style="font-family: monospace;">cd
+...\examples\web-services</span><br>
+</div>
+<br>
+3. Run the example:<br>
+<br>
+<div style="margin-left: 40px;"><span style="font-family: monospace;">ant</span>
+<br>
+<br>
+<br>
+</div>
+The output of a successful run should be similar to:<br>
+<div style="margin-left: 40px;"><br>
+</div>
+<table
+ style="width: 90%; text-align: left; font-family: monospace; background-color: rgb(204, 204, 204); margin-left: 40px;"
+ border="1" cellpadding="2" cellspacing="2">
+ <tbody>
+ <tr>
+ <td style="vertical-align: top;">
+ <div style="margin-left: 40px;"><br>
+ </div>
+example at example:/workspace/jboss-messaging-1.2.0.SP2/examples/web-services$
+ant<br>
+Buildfile: build.xml<br>
+ <br>
+identify:<br>
+ [echo]
+###########################################################################<br>
+ [echo]
+#
+Running the WebServices
+example
+#<br>
+ [echo]
+###########################################################################<br>
+ [echo] The
+queue: testQueue<br>
+ [echo] The client jar:
+../..//jboss-messaging-client.jar<br>
+ <br>
+sanity-check:<br>
+ <br>
+init:<br>
+ <br>
+compile:<br>
+ <br>
+war:<br>
+ [jar] Building jar:
+/workspace/jboss-messaging-1.2.0.SP2/examples/web-services/output/lib/jms-web-service.war<br>
+ <br>
+deploy:<br>
+ [copy] Copying 1 file to
+/jboss-4.2.0.GA/server/messaging/deploy<br>
+ <br>
+sleep:<br>
+ [echo] Sleeping for 5 seconds ...<br>
+ <br>
+run-wsdl-client:<br>
+ [get] Getting:
+http://127.0.0.1:8080/jms-web-service/JMSWebServiceExample?wsdl<br>
+ [get] To:
+/workspace/jboss-messaging-1.2.0.SP2/examples/web-services/output/service.wsdl<br>
+ [wstools] log4j:WARN No appenders could be found for logger
+(org.jboss.ws.tools.wsdl.WSDLDefinitionsFactory).<br>
+ [wstools] log4j:WARN Please initialize the log4j system properly.<br>
+ <br>
+compile-client:<br>
+ [mkdir] Created dir:
+/workspace/jboss-messaging-1.2.0.SP2/examples/web-services/output/client-classes<br>
+ [javac] Compiling 5 source files to
+/workspace/jboss-messaging-1.2.0.SP2/examples/web-services/output/client-classes<br>
+ <br>
+run:<br>
+ <br>
+send-and-receive:<br>
+ [java] log4j:WARN No appenders could be found
+for logger
+(org.jboss.ws.metadata.builder.jaxrpc.JAXRPCClientMetaDataBuilder).<br>
+ [java] log4j:WARN Please initialize the log4j
+system properly.<br>
+ [java] Message was received ok!<br>
+ [java]<br>
+ [java] #####################<br>
+ [java] ###
+SUCCESS! ###<br>
+ [java] #####################<br>
+ <br>
+undeploy:<br>
+ [delete] Deleting:
+/jboss-4.2.0.GA/server/messaging/deploy/jms-web-service.war<br>
+ <br>
+BUILD SUCCESSFUL<br>
+Total time: 12 seconds<br>
+ <br>
+ <br>
+ </td>
+ </tr>
+ </tbody>
+</table>
+<br>
+<h2>Troublesooting</h2>
+<h3>1. I get <span style="font-family: monospace;">"javax.jms.JMSSecurityException:
+User null is NOT authenticated" <br>
+</span></h3>
+You probably didn't install JBoss Messaging correctly. A fresh JBoss
+Messaging installation requires changes in the security configuration
+of a <span style="font-family: monospace;">default </span>JBoss
+instance, specifically a properly configured "<small><span
+ style="font-family: courier new,courier,monospace;">messaging</span></small>"
+security domain. Follow the instructions from the "Installation"
+paragraph of the release documentation. <br>
+<h3>2. <span style="font-family: monospace;">wstools doesn't work</span></h3>
+You could aways using "ant -debug" to verify what Exceptions wstools is
+generating. A common error is a NullPointerException due to a xerces
+update required by JBoss Web Services. You could have more information
+at this <a
+ href="http://wiki.jboss.org/wiki/Wiki.jsp?page=JBWSFAQXercesNPE">page</a>:<br>
+<br>
+<a href="http://wiki.jboss.org/wiki/Wiki.jsp?page=JBWSFAQXercesNPE">http://wiki.jboss.org/wiki/Wiki.jsp?page=JBWSFAQXercesNPE</a><br>
+<br>
+<br>
+<br>
+<br>
+<hr style="width: 100%; height: 2px;"><br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+</span>
+</body>
+</html>
Modified: trunk/docs/examples/web-services/build.xml
===================================================================
--- trunk/docs/examples/web-services/build.xml 2007-05-17 16:32:40 UTC (rev 2702)
+++ trunk/docs/examples/web-services/build.xml 2007-05-17 18:14:07 UTC (rev 2703)
@@ -32,6 +32,9 @@
<pathelement path="../common/output/classes"/>
<pathelement path="./output/classes"/>
<pathelement location="${messaging.client.jar.path}/${messaging.client.jar.name}"/>
+
+ <!-- all this stuff for WebServices -->
+ <pathelement location="${jboss.home}/lib/endorsed/xercesImpl.jar"/>
<pathelement location="${jboss.client}/activation.jar"/>
<pathelement location="${jboss.client}/commons-logging.jar"/>
<pathelement location="${jboss.client}/javassist.jar"/>
@@ -54,7 +57,6 @@
<pathelement path="./output/client-classes"/>
<!-- all this stuff for WebServices -->
- <pathelement location="${messaging.client.jar.path}/${messaging.client.jar.name}"/>
<pathelement location="${jboss.client}/activation.jar"/>
<pathelement location="${jboss.client}/commons-logging.jar"/>
<pathelement location="${jboss.client}/javassist.jar"/>
@@ -68,9 +70,10 @@
<pathelement location="${jboss.client}/jboss-saaj.jar"/>
<pathelement location="${jboss.client}/wsdl4j.jar"/>
<pathelement location="${jboss.client}/jaxb-api.jar"/>
- <pathelement location="${jboss.home}//lib/endorsed/xercesImpl.jar"/>
+ <pathelement location="${jboss.home}/lib/endorsed/xercesImpl.jar"/>
+ <pathelement location="${messaging.client.jar.path}/${messaging.client.jar.name}"/>
<pathelement location="${jboss.home}/client/jbossall-client.jar"/>
<pathelement location="${jboss.home}/server/${jboss.configuration}/lib/log4j.jar"/>
<pathelement location="${jboss.home}/server/${jboss.configuration}/lib/javassist.jar"/>
Modified: trunk/docs/examples/web-services/src-client/org/jboss/example/jms/webservices/client/Client.java
===================================================================
--- trunk/docs/examples/web-services/src-client/org/jboss/example/jms/webservices/client/Client.java 2007-05-17 16:32:40 UTC (rev 2702)
+++ trunk/docs/examples/web-services/src-client/org/jboss/example/jms/webservices/client/Client.java 2007-05-17 18:14:07 UTC (rev 2703)
@@ -27,13 +27,17 @@
import org.jboss.ws.core.jaxrpc.client.ServiceFactoryImpl;
import org.jboss.ws.core.jaxrpc.client.ServiceImpl;
import javax.xml.rpc.ServiceFactory;
+import javax.xml.rpc.ServiceException;
import javax.xml.namespace.QName;
import javax.naming.InitialContext;
+import javax.naming.NamingException;
import javax.jms.Destination;
import javax.jms.ConnectionFactory;
import javax.jms.Session;
import java.net.URL;
+import java.net.MalformedURLException;
import java.io.File;
+import java.rmi.RemoteException;
import javax.jms.*;
import javax.jms.IllegalStateException;
@@ -47,10 +51,22 @@
*/
public class Client extends ExampleSupport
{
+ private static final String MESSAGE_TEXT = "Hello from a WebService!";
+
public void example() throws Exception
{
- ServiceFactoryImpl factory = (ServiceFactoryImpl)ServiceFactory.newInstance();
+ sendMessage();
+ receiveMessage();
+
+ System.out.println("Message was received ok!");
+ }
+
+ private void sendMessage()
+ throws ServiceException, MalformedURLException, RemoteException
+ {
+ ServiceFactoryImpl factory = (ServiceFactoryImpl) ServiceFactory.newInstance();
+
URL wsdlLocation = new URL("http://127.0.0.1:8080/jms-web-service/JMSWebServiceExample?wsdl");
QName serviceName = new QName("http://endpoint.webservices.jms.example.jboss.org/", "JMSSampleService");
@@ -58,14 +74,16 @@
ServiceImpl service = (ServiceImpl)factory.createService(wsdlLocation, serviceName, fileMapping.toURL());
- JMSSample sample = (JMSSample)service.getPort(JMSSample.class);
+ JMSSample proxy = (JMSSample)service.getPort(JMSSample.class);
- sample.sendMessage("queue/testQueue","Hello from a WebService!");
+ proxy.sendMessage(getDestinationJNDIName(), MESSAGE_TEXT);
+ }
-
-
+ private void receiveMessage()
+ throws NamingException, JMSException
+ {
InitialContext ctx = new InitialContext();
- Destination dest = (Destination)ctx.lookup("queue/testQueue");
+ Destination dest = (Destination)ctx.lookup(getDestinationJNDIName());
ConnectionFactory cf = (ConnectionFactory)ctx.lookup("/ConnectionFactory");
Connection conn = cf.createConnection();
@@ -83,12 +101,10 @@
throw new IllegalStateException("Couldn't receive message");
}
- if (!msg.getText().equals("Hello from a WebService!"))
+ if (!msg.getText().equals(MESSAGE_TEXT))
{
throw new IllegalStateException("Couldn't receive message");
}
-
- System.out.println("Received message ok!");
}
protected boolean isQueueExample()
@@ -98,6 +114,6 @@
public static void main(String[] args) throws Exception
{
- new Client().example();
+ new Client().run();
}
}
\ No newline at end of file
More information about the jboss-cvs-commits
mailing list