JBoss-Net Hello World Examples Builds A Simple Example Showing What Can Be Done with Jboss-Net Which Integrates Apache Axis.Updated 29 August 2004
This example works with the newest builds of JBoss.NET that use Apache axis 1_1 for its core. Therefore you may need to change the code to work with the correct API, if you have an earlier version. In any case you need to download the Axis Version So That You Can Code To The Correct API, And Have The Axis Docs for Details About The Utilities, Which com with axis. This Assumes a Number of Things Aready Set Up on your machine.
That you have a running version of JBoss with JBoss-Net installed. It should not matter if you have the Jetty or Tomcat version. If not then you first need to go here to get the distribution. That you have Jakarta Ant installed and ready to use, as discussed here That you have added the axis.jar from the relevant axis distro to your classpath you need this for two things:.. to use the tcpmon for debugging to have the documentation and AP If you are doing this exercise with A JBoss-3.0.x Distro, Then You Will Need To Make A Few Changes To The Code As We Go Along in Order for It To Work for You. Before You Go Any Further, Make Sure That You'Ve Made The change jboss-net.sar file discussed under the general jboss-net Guide page. Once you've done that, ie turned the jboss-net.sar file into a directory, then come back here. This exercise assumes that you are using jBoss- 3.2.x Versions. This Has Jboss.Net Under The 'All' Servewr Option. But if you first want to get your head around w EB Services, THIS WILL GET You Going ON A Smaller Scale. in Any Case The Principles Are The Same:
create a Java class write a web-service.xml file put these into a wsr archive deploy on JBoss access the service via a client application. If you've looked over the Axis docs, then you'll have come across 'jws' files (ie 'java web service'), which are uncompiled Java source code, that is compiled on the fly by the Axis engine in the same way that jsp pages are compiled into servlets by Catalina.JWS files do not seem to work in JBoss -Net. But that's not a big problem anyway. JBoss-Net remember is about integrating Axis into a J2EE server, and simple web services are unlikely to be deployed on it in anything other than testing and learning scenarios.
INSTEAD, JBOSS-NET Needs to Have A Compiled Class File Deployed Along With A Deployment Descriptor File bundled Into an archive, which is the jboss server.
Axis by Default Uses A Web Services Deployment Descriptor (WSDD) for the Configuration Of Web Services. Under Jboss-Net This Is A Web-Service.xml File.
JBoss-Net needs to have this web-service.xml file and put into a Web Service aRchive (WSR) along with the Java classes for the service. This lets you drop the wsr file into the running JBoss server where it will hot deploy.
However, IT Does Not Seem to Update Itself if you change the class file, rebundle it, and then sort of change on the Fly Works with War Files, But not at present with wsr files. If you want to make changes, then you will need to first undeploy the service. I've experimented with the
You can Download The Code and Build Files in A Zip File from Here
THE DIRECTORY STRUCTURE THAT You NEED TO CREATE LOOKS LIKE THIS:
JBoss-Axis
main
SRC
Client
META-INF
Web
WEB-INF
Build.xml sit under jboss-axis (or wherever you want to call the directory).
Web-Services.xml Sits Under Meta-INF
TesthelloWorld.java Sits Under Main / SRC
TestClient.java Sits Under Main / Client
Nothing actually goes into the web or WEB-INF directories, but are there for later use when you tie your application into web resources. If you want to, then you can put a placeholder index.html page under web. First, the build. XML Script, Which IS Simple and Short. You will need to make su consisting you have jboss_dist set in your environment.
target>
target>
->
target>
project> Second, The Web-Service.xml File, Which Goes Under The Meta-Inf Directory.
deployment> Third, The Java Source Class, Which Goes Under Main / src. Public Class Testhelloworld {Public TestHelloWorld () {}
public String getHelloWorldMessage (String name) {return "Hello world to" name;}} Fourth, the client to test the application, which goes under main / client import org.apache.axis.client.Call;. import org.apache .axis.client.service; import org.apache.axis.encoding.xmltype; import javax.xml.rpc.parametermode;
public class testClient {public static void main (String [] args) {try {String endpoint = "http: // localhost: 8070 / jboss-net / services / testHelloWorld"; String methodName = "getHelloWorldMessage";
Service service = new service (); call call = (call) service.createcall ();
Call.SettargetendPointdaddress (New Java.net.URL (Endpoint)); Call.SetoperationName (MethodName);
Call.addparameter ("name", org.apache.axis.constants.xsd_string, parametermode.in); call.setreturntype (org.apache.axis.constants.xsd_string);
String Ret = (string) Call.invoke (new object [] {"axis!"});
System.out.println (RET); Catch (Exception E) {system.err.println (e.tostring ());}}} fiffh Classpath for you to run the client. You can the jar file in the first battle. Indeed, you may find problem. @echo offmatch. @echo offmatch. @echo offmatch. @echor
SET TEMP_CP =% TEMP_CP%
Set jboss = C: / Java / JBoss-Tomcat / JBoss Rem Now Add Client Jars to Classpath Which Jboss Needs to Run
Set temp_cp =.;% jboss% / catalina / common / lib / servlet.jar;% jboss% / client / concurrent.jar;% jboss% / client / jboss-common-client.jar;% jboss% / client / jboss -Client.jar;% jboss% / client / jboss-j2ee.jar;% jboss% / client / jaas.jar;% jboss% / client / jboss-jsr77.jar;% jboss% / client / jcert.jar;% JBoss% / Client / JBoss-Net-Client.jar;% JBoss% / Client / gnu-regexp.jar;% jboss% / client / jbossx-client.jar;% jboss% / client / log4j.jar;% JBOSS% /client/jnet.jar;%jboss%/client/jnp-client.jar;%jboss%/client/jsse.jar;%jboss%/client/jacorb.jar;%jboss%/client/jbossmq-client.jar ;% Jboss% / client / getopt.jar;% jboss% / client / jboss-iiop-client.jar;% jboss% / client / jbossmx-ant.jar;% JBoss% / client / jboss-system-client.jar ;% Jboss% / client / jboss-transaction-client.jar
Rem add in the classpath to the axis required jar files
Set temp_cp =% temp_cp%;% jboss% / server / all / deploy / jboss-net.sar / axis.jar;% jboss% / server / all / deploy / jboss-net.sar / jaxrpc.jar;% JBOSS% /server/all/deploy/jboss-net.sar/saaj.jar;%% j%%% / / / al d d / / / / / / / / / j l j. l l j . SAR / Commons-logging.jar;% jboss% / server / all / deploy / jboss-net.sar / commons-discovery.jar
SET TEMP_CP =% TEMP_CP%;% ClassPath%
java -classpath% TEMP_CP% testClient% 1% 2% 3% 4% 5 With all of the files in their right spot, open a console in the same directory as the build.xml file and enter this command: buildThis will process the main target, which will compile the class files, build the wsr file, and copy the compiled client class back to the client directory. It also puts the wsr file into the deploy directory of your JBoss server. You should see some output in the console window Telling you what is happening.
Any errors that you encounter are probably due to missing items in your classpath, as the build.xml script checks that all of the Axis required jars are in your classpath. If jars are missing, then they will appear as errors, class not found.
Open a browser and navigate to
Http: // localhost: 8080 / jboss-net / servlet / axisservlet where you shop Your newly deployed service at the bottom of the point. Now navigate to
http: // localhost: 8080 / jboss-net / services / testHelloWorld wsdl where you should see the wsdl details of your application Note that it provides the targetnamespace of http:?. // localhost: 8080 / jboss-net / services / testHelloWorld Which is where we find the webservice.
Some of you will realise that the client goes to http: // localhost:. 8070 / jboss-net / services / testHelloWorld, and wonder what gives Well, it's an excuse to introduce another debug tool, the tcpmon which comes with Axis The. TCPMON Intercepts Messages on One Port (IE 8070), Shows Theme in One Window, And The Redirects The Message To ITS Designated Port (IE 8080) And Chicks Up The Response.
Open another console window and enter this command (assuming that you have added the axis.jar to your classpath Unfortunately, I have found that this ONLY works if the axis.jar is in your system classpth..): Java org.apache.axis .utils.tcpmon
You should have a Swing application open up. Put 8070 in the 'Listen Port #' textfield, put localhost in the 'Target hostname' textfield, and 8080 in the 'Target Port #' textfield. The radio button for 'Act as a listener 'Should Be SELECTED. Now Click' Add 'and A New Tab' Port 8070 'Should Appear. SELECT IT.
Open another console window and navigate to the jboss-axis / main / client directory and rain the command:
Runclient
You Should See "Hello World to Axis!" Appear in your client console window, and Both the Sent and received SOAP Messages in the Tcpmon Windows.
That's it, you've done it. You Built a Simple Application, Deployed It On Jboss-Net and Discovered How Similar It Is To The Raw Axis, Which Sits on The Server.
I've Also Done A Hello World Using EJB-JSP Example with Jboss-Net Which You Can Find Here.
You Can Also Go Through The Jboss-Net Examples from The CVS Files At Sourceforge To Also Browse Through. Go TO:
Http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/jboss/contrib/jboss.net/ and look Under Samples and testsuite. Needless to say, these Only Give You Some Indication of What's Going on, And You Really Should Build Jboss-Net from the sourcecode as described in ahowto here.