wood burning stoves*
The moose likes Web Services and the fly likes using custom class in JWSDP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Web Services
Bookmark "using custom class in JWSDP" Watch "using custom class in JWSDP" New topic
Author

using custom class in JWSDP

Anita Wang
Greenhorn

Joined: Mar 15, 2004
Posts: 20
Could anyone who knows this help me?
I'm setting up a web service using jaxrpc and a client using dynamic proxy, just like the helloservice and helloclient in the JWSDP tutorial, only that I added a class of my own (MyClass) and both the service and client need to access this class. I put the jar file of MyClass in the compile and run path of both service and client. It works for the service, but whenever I ant build the client, a copy of MyClass will be put under the build folder, and when I run the client, it says it cannot find MyClass.
I've tried everything I could think of, so thanks so much whoever can help!
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
Could you post some more details like the commands you run the client with, etc.?


Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
Stan Sokolov
Ranch Hand

Joined: Apr 13, 2004
Posts: 120

Hmm :-)
The server and client use different classes to the web service call. Probably from the your point of view they look the same but in fact it is
different classes (probably belonging to the same package). The reason
is that client does not know about server implemenation. You can use .NET
as webservice implementation (not java). You should generate client
stub code. Using ant target from JWSDP examples
<target name="generate-stubs"
description="Runs wscompile to generate the client stub classes">
<antcall target="run-wscompile">
<param name="param1" value="-gen:client -d ${build}
-classpath ${build}/${mpas} ${config.wsdl.file}"/>
</antcall>
</target>
It will create a copy (but not original) of paramter class that you should
use. Package name may or may not be the same like you used on server - depend on namespace


Good luck for yourself.
Anita Wang
Greenhorn

Joined: Mar 15, 2004
Posts: 20
Thanks for helping! Here is the error message when I run the client:
***************************************************************************
Buildfile: build.xml
run-client:
[java] nameSpaceUri= http://localhost:8080/shippingarrangementservice-masterproject/shippingarrangementservice?WSDL
[java] java.lang.NoClassDefFoundError: shippingarrangementclient/ShippingArrangement
[java] at java.lang.Class.getDeclaredMethods0(Native Method)
[java] at java.lang.Class.privateGetDeclaredMethods(Class.java:1647)
[java] portName= ShippingArrangementIFPort
[java] at java.lang.Class.privateGetPublicMethods(Class.java:1770)
[java] at java.lang.Class.getMethods(Class.java:824)
[java] at com.sun.xml.rpc.client.dii.ConfiguredService.getPortNameForIn
terface(ConfiguredService.java:140)
[java] at com.sun.xml.rpc.client.dii.ConfiguredService.getPort(ConfiguredService.java:127)
[java] at shippingarrangementclient.ShippingArrangementClient.main(Unknown Source)
[java] Exception in thread "main"
[java] Java Result: 1
run:
BUILD SUCCESSFUL
Total time: 2 seconds
**************************************************************************
ShippingArrangement is the class I defined. In my client targets.xml, I used the following target:
**************************************************************************
<target name="generate-interface" description="Runs wscompile to generate the service endpoint interface">
<echo message="Generating the service endpoint interface...."/>
<antcall target="run-wscompile">
<param name="param1" value="-import -d ${build} -nd ${build} -f:norpcstructures -verbose -classpath ${build} ${config.wsdl.file}"/>
</antcall>
</target>
Anita Wang
Greenhorn

Joined: Mar 15, 2004
Posts: 20
Forgot to say, the client build with no problem. After the build, there is a ShippingArrangement class file generated in the build file under the shippingarrangementclient folder. So I don't know why it says it cannot find the shippingarrangementclient/ShippingArrangement class.
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
Originally posted by Anita Wang:
Forgot to say, the client build with no problem. After the build, there is a ShippingArrangement class file generated in the build file under the shippingarrangementclient folder. So I don't know why it says it cannot find the shippingarrangementclient/ShippingArrangement class.
Are you telling the JVM to include it into the classpath? Have you double-checked for typos in your classpath?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: using custom class in JWSDP