- This topic has 5 replies, 2 voices, and was last updated 16 years, 5 months ago by Riyad Kalla.
-
AuthorPosts
-
Douglas M HurstParticipantI’v successfully built the HelloWorld WebService and Client in the IDE and it works fine in there.
I don’t see anything in the documentation about deploying the client outside the IDE.
I’ve tried putting it in a .bat file with what I think are all the required .jar files, but it doesn’t execute. The error I’m currently getting is…
Exception in thread “main” java.lang.NoClassDefFoundError: org/apache/commons/lo
gging/LogFactory…even though …
set cl_path=../lib/commons-logging-1.0.4.jar;%cl_path%
is definitely in my classpath.
AND, I’m also curious, since it’s required to import the IHellowWorldService, does that have to be deployed with the client?
package com.genuitec.myeclipse.wsexample.client;import java.net.MalformedURLException;
import org.codehaus.xfire.XFireFactory;
import org.codehaus.xfire.client.XFireProxyFactory;
import org.codehaus.xfire.service.Service;
import org.codehaus.xfire.service.binding.ObjectServiceFactory;
import com.genuitec.myeclipse.wsexample.IHelloWorldService;public class HelloWorldClient {
/**
* @param args
*/
public static void main(String[] args) {
Service srvcModel = new ObjectServiceFactory().create(IHelloWorldService.class);
XFireProxyFactory factory = new XFireProxyFactory(XFireFactory
.newInstance().getXFire());
String helloWorldURL = “http://localhost:8080/HelloWorld/services/HelloWorldService”;
try {
IHelloWorldService srvc = (IHelloWorldService) factory.create(srvcModel, helloWorldURL);
String result = srvc.example(“?UserID=Andrew&Password=pword99”);
System.out.println(result);
} catch (MalformedURLException e) {
e.printStackTrace();
}
}
}Bottom line, is there some documentation on deploying WS clients?
Douglas M HurstParticipantI also tried to generate a Web Service Client (ala the TerraServerWS tutorial) but pointing to the HelloWorld web service built in that tutorial.
I had Tomcat running and when the wizard is trying to validate, it cycles for quite sometime before coming back with an error
I tried both
http://localhost:8080/HelloWorld/services/HelloWorldService (error: Cannot find the declaration element of html)
and
http://localhost:8080/HelloWorld/services/HelloWorldService?WSDL (error: TAD could not be found and/or processed… something like that).
both seem to be connecting but both also return an error.
I also noticed that it created several new files in the HelloWorld project. That is unexplained in the documentation.
Riyad KallaMemberI don’t see anything in the documentation about deploying the client outside the IDE.
That’s a good point… the details depend on where the WS Client is going to go live and can be treated as a plain Java class to some degree (just make sure to ship it’s dependencies along with it) but we can clarify this in the documentation.
…even though …
set cl_path=../lib/commons-logging-1.0.4.jar;%cl_path%
is definitely in my classpath.
You are making sure to use cl_path when executing the class right? THere is something going wrong because the class isn’t getting found.
AND, I’m also curious, since it’s required to import the IHellowWorldService, does that have to be deployed with the client?
Yes absolutely, otherwise you’ll get a ClassDefNotFoundException. It’s similar to working with EJBs where you need to ship the interface you are using along with the client code.
http://localhost:8080/HelloWorld/services/HelloWorldService?WSDL
If you pop this into your browser, do you get a correct response of the WSDL?
Douglas M HurstParticipantYes, http://localhost:8080/HelloWorld/services/HelloWorldService?WSDL resulted in a full page of XML.
I was able to deploy the client, but i’m not absolutely certain I did it properly
1) I first created a .jar file out of the original HelloWorld project. I called it WebServiceClient.jar
2) I created a new Java project, then added a Web Service Client called HelloWorldWebserviceClient.java
3) I created a lib folder within the project and move all the required XFile .jar files there.
4) I then move that entire project out of workspace and under my c:\temp directory.
5) In the bin directory, I created the following batch file (hw.bat)echo off
set cl_path=.;../lib/WebServiceClient.jar
set cl_path=../lib/activation-1.1.jar;%cl_path%
set cl_path=../lib/commons-beanutils-1.7.0.jar;%cl_path%
set cl_path=../lib/commons-codec-1.3.jar;%cl_path%
set cl_path=../lib/commons-httpclient-3.0.jar;%cl_path%
set cl_path=../lib/commons-logging-1.0.4.jar;%cl_path%
set cl_path=../lib/jaxb-api-2.0.jar;%cl_path%
set cl_path=../lib/jaxb-impl-2.0.1.jar;%cl_path%
set cl_path=../lib/jaxb-xjc-2.0.1.jar;%cl_path%
set cl_path=../lib/jaxen-1.1-beta-9.jar;%cl_path%
set cl_path=../lib/jaxws-api-2.0.jar;%cl_path%
set cl_path=../lib/jdom-1.0.jar;%cl_path%
set cl_path=../lib/jsr173_api-1.0.jar;%cl_path%
set cl_path=../lib/mail-1.4.jar;%cl_path%
set cl_path=../lib/saaj-api-1.3.jar;%cl_path%
set cl_path=../lib/saaj-impl-1.3.jar;%cl_path%
set cl_path=../lib/spring-1.2.6.jar;%cl_path%
set cl_path=../lib/stax-api-1.0.1.jar;%cl_path%
set cl_path=../lib/wsdl4j-1.6.1.jar;%cl_path%
set cl_path=../lib/wstx-asl-3.2.0.jar;%cl_path%
set cl_path=../lib/xbean-2.2.0.jar;%cl_path%
set cl_path=../lib/xbean-spring-2.8.jar;%cl_path%
set cl_path=../lib/xfire-aegis-1.2.6.jar;%cl_path%
set cl_path=../lib/xfire-annotations-1.2.6.jar;%cl_path%
set cl_path=../lib/xfire-core-1.2.6.jar;%cl_path%
set cl_path=../lib/xfire-generator-1.2.6.jar;%cl_path%
set cl_path=../lib/xfire-java5-1.2.6.jar;%cl_path%
set cl_path=../lib/xfire-jaxb-1.1.2.jar;%cl_path%
set cl_path=../lib/xfire-jaxb2-1.2.6.jar;%cl_path%
set cl_path=../lib/xfire-jaxws-1.2.6.jar;%cl_path%
set cl_path=../lib/xfire-jsr181-api-1.0-M1.jar;%cl_path%
set cl_path=../lib/xfire-spring-1.2.6.jar;%cl_path%
set cl_path=../lib/xfire-ws-security-1.2.6.jar;%cl_path%
set cl_path=../lib/xfire-xmlbeans-1.2.6.jar;%cl_path%
set cl_path=../lib/XmlSchema-1.1.jar;%cl_path%
java -classpath %cl_path% com.eclipse.helloworldservice.HelloWorldWebserviceClientWith the original HelloWorld project running under Tomcat, I ran that batch file and it worked just fine.
Douglas M HurstParticipant1) I first created a .jar file out of the original HelloWorld project. I called it WebServiceClient.jar
I should have mentioned that I included the WebServiceClient.jar that I created from the original HelloWorld project with all the XFire stuff. It’s the first entry in cl_path
echo off
set cl_path=.;../lib/WebServiceClient.jar
set cl_path=../lib/activation-1.1.jar;%cl_path%
set cl_path=../lib/commons-beanutils-1.7.0.jar;%cl_path%
set cl_path=../lib/commons-codec-1.3.jar;%cl_path%
set cl_path=../lib/commons-httpclient-3.0.jar;%cl_path%
set cl_path=../lib/commons-logging-1.0.4.jar;%cl_path%
set cl_path=../lib/jaxb-api-2.0.jar;%cl_path%
set cl_path=../lib/jaxb-impl-2.0.1.jar;%cl_path%
set cl_path=../lib/jaxb-xjc-2.0.1.jar;%cl_path%
set cl_path=../lib/jaxen-1.1-beta-9.jar;%cl_path%
set cl_path=../lib/jaxws-api-2.0.jar;%cl_path%
set cl_path=../lib/jdom-1.0.jar;%cl_path%
set cl_path=../lib/jsr173_api-1.0.jar;%cl_path%
set cl_path=../lib/mail-1.4.jar;%cl_path%
set cl_path=../lib/saaj-api-1.3.jar;%cl_path%
set cl_path=../lib/saaj-impl-1.3.jar;%cl_path%
set cl_path=../lib/spring-1.2.6.jar;%cl_path%
set cl_path=../lib/stax-api-1.0.1.jar;%cl_path%
set cl_path=../lib/wsdl4j-1.6.1.jar;%cl_path%
set cl_path=../lib/wstx-asl-3.2.0.jar;%cl_path%
set cl_path=../lib/xbean-2.2.0.jar;%cl_path%
set cl_path=../lib/xbean-spring-2.8.jar;%cl_path%
set cl_path=../lib/xfire-aegis-1.2.6.jar;%cl_path%
set cl_path=../lib/xfire-annotations-1.2.6.jar;%cl_path%
set cl_path=../lib/xfire-core-1.2.6.jar;%cl_path%
set cl_path=../lib/xfire-generator-1.2.6.jar;%cl_path%
set cl_path=../lib/xfire-java5-1.2.6.jar;%cl_path%
set cl_path=../lib/xfire-jaxb-1.1.2.jar;%cl_path%
set cl_path=../lib/xfire-jaxb2-1.2.6.jar;%cl_path%
set cl_path=../lib/xfire-jaxws-1.2.6.jar;%cl_path%
set cl_path=../lib/xfire-jsr181-api-1.0-M1.jar;%cl_path%
set cl_path=../lib/xfire-spring-1.2.6.jar;%cl_path%
set cl_path=../lib/xfire-ws-security-1.2.6.jar;%cl_path%
set cl_path=../lib/xfire-xmlbeans-1.2.6.jar;%cl_path%
set cl_path=../lib/XmlSchema-1.1.jar;%cl_path%
java -classpath %cl_path% com.eclipse.helloworldservice.HelloWorldWebserviceClient
Riyad KallaMemberI’m glad to hear you got it working, and like i mentioned, there is no “correct” way to deploy a client class, just depends on how you are going to use it. But yes the trick is to deploy the class with all the build and runtime dependencies it needs, which it sounds like you did.
-
AuthorPosts