I am presently developing a reference implementation of a JAX-RPC one-way web service. The service will be run on an Oracle 10g server. I currently developing it on Oracle (OC4J 10.1.2) standalone developmental server.
I used Lavadora Web Services Eclipse Plugin to create the service client. I can compile and run the client fine when I use eclipse (Success is defined when I see the xml payload getting transported to the server). When I compile and run the client using command line, the client doesn't seem to work.
The only major difference I saw was that eclipse was using the elipse plugin jars and eclipse ant jars in it's classpath.
Any suggestions?
Thanks,
Enoch Moses
P.S. The plugin generates classes using wsdl2java.
-
Run the web client via command line (3 messages)
- Posted by: Enoch Moses
- Posted on: February 01 2005 23:19 EST
Threaded Messages (3)
- Run the web client via command line by Raghu Kodali on February 02 2005 01:19 EST
- Run the web client via command line by Enoch Moses on February 02 2005 08:28 EST
- Run the web client via command line by Enoch Moses on February 04 2005 11:07 EST
- Run the web client via command line by Enoch Moses on February 02 2005 08:28 EST
-
Run the web client via command line[ Go to top ]
- Posted by: Raghu Kodali
- Posted on: February 02 2005 01:19 EST
- in response to Enoch Moses
Are you getting NoClassDefFoundError or something else ? Can you post the stacktrace if any ?
raghu -
Run the web client via command line[ Go to top ]
- Posted by: Enoch Moses
- Posted on: February 02 2005 08:28 EST
- in response to Raghu Kodali
I am using an ant script to add libraries to the classpath.
Here is the script:
=============================================================
<project name="ws-client" default="compile" basedir=".">
<property name="build.dir" value="${basedir}/build"/>
<property name="build.classes" value="${build.dir}/classes"/>
<property name="lib.dir" value="${basedir}/lib"/>
<property name="axis.lib.classpath" value="C:/axis-1_1/lib"/>
<property name="ant.dir" value="c:/apache-ant-1.6.1/lib"/>
<property name="src.dir" value="${basedir}/src"/>
<property name="debug" value="true" />
<path id="axis.classpath">
<fileset dir="C:/axis-1_1/lib">
<include name="**/*.jar" />
</fileset>
</path>
<path id="ant.classpath">
<fileset dir="${ant.dir}">
<include name="**/*.jar" />
</fileset>
</path>
<path id="classpath">
<pathelement path="${build.classes}" />
<pathelement path="${lib.dir}" />
<fileset dir="${lib.dir}">
<include name="**/*.jar" />
</fileset>
</path>
<target name="compile" description="Compiles the client code">
<delete dir="${build.classes}"/>
<mkdir dir="${build.classes}"/>
<mkdir dir="${build.classes}/config"/>
<javac srcdir="${src.dir}" destdir="${build.classes}" includes="**/*.java" optimize="${optimize}" deprecation="${deprecation}">
<classpath refid="ant.classpath" />
<classpath refid="classpath" />
<classpath refid="axis.classpath" />
</javac>
</target>
<target name="run" depends="compile" description="Run the client">
<java classname="com.csi.mos.ws.client.WS_Client">
<classpath refid="ant.classpath" />
<classpath refid="classpath" />
<classpath refid="axis.classpath" />
</java>
</target>
</project>
=============================================================
My Class:
==============================================================
package com.csi.mos.ws.client;
import java.io.FileInputStream;
import javax.xml.soap.MessageFactory;
import javax.xml.soap.Name;
import javax.xml.soap.SOAPBody;
import javax.xml.soap.SOAPBodyElement;
import javax.xml.soap.SOAPElement;
import javax.xml.soap.SOAPElementFactory;
import javax.xml.soap.SOAPEnvelope;
import javax.xml.soap.SOAPException;
import javax.xml.soap.SOAPFactory;
import javax.xml.soap.SOAPMessage;
import javax.xml.soap.SOAPPart;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMResult;
import javax.xml.transform.stream.StreamSource;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
/**
* @author ENOCH MOSES
*
* TODO To change the template for this generated type comment go to Window -
* Preferences - Java - Code Style - Code Templates
*/
public class WS_Client {
/**
* A simple client to MOSTrimWebservice client.
*
* @param args
* args[0] The name and path of the file which will be the
* SOAPBody
* @throws Exception
*/
public static void main(String[] args) throws Exception {
//===============================================
// Creating the SOAPMessage
//===============================================
MessageFactory messageFact;
messageFact = MessageFactory.newInstance();
SOAPMessage message = messageFact.createMessage();
SOAPPart soap = message.getSOAPPart();
SOAPEnvelope envelope = soap.getEnvelope();
envelope.addNamespaceDeclaration("SOAP-ENV",
"http://schemas.xmlsoap.org/soap/envelope/");
envelope.removeNamespaceDeclaration("soapenv");
envelope.addNamespaceDeclaration("xsd",
"http://www.w3.org/2001/XMLSchema");
SOAPBody body = envelope.getBody();
Name name = envelope.createName("param");
SOAPBodyElement paramElement = body.addBodyElement(name);
//================================================
// Adding the xmlPayload from a file and
// converting from stream to DOM node.
//================================================
TransformerFactory tFactory = TransformerFactory.newInstance();
Transformer transformer = tFactory.newTransformer();
String file = "C:/MOS-home/xmlschema/tempFile.xml";
StreamSource source = new StreamSource(new FileInputStream(file));
Node node = null;
DOMResult result = new DOMResult(node);
transformer.transform(source, result);
//=================================================
// Converting from DOM node to SOAPElement and
// add it to the soap
//=================================================
SOAPFactory soapFactory = SOAPFactory.newInstance();
SOAPElement xmlPayload = dom2SOAPElement(envelope, result.getNode()
.getFirstChild());
paramElement.addChildElement(xmlPayload);
//================================================
private static SOAPElement dom2SOAPElement(SOAPEnvelope env, Node domNode) {
... }
}
// Implementing the generated code for the
// Web service. Used Lavadora Web Services Plugin
// to generated the generated code.
//================================================
MOSTrimWebserviceBindingStub _stub;
_stub = (MOSTrimWebserviceBindingStub) new MOSTrimWebserviceLocator()
.getMOSTrimWebservicePort();
_stub.sendTrim(paramElement);
} -
Run the web client via command line[ Go to top ]
- Posted by: Enoch Moses
- Posted on: February 04 2005 11:07 EST
- in response to Enoch Moses
I figured out the problem.
I needed to add lines, "Thread.sleep(4000); System.exit(0);"