-
1. Re: Call a web service
peterj Mar 14, 2008 12:07 PM (in response to rodosa)Yes, you use the files generated by wsconsume in your client. As an example, say you have a hello web service (I am not sowing all the code):
class Hello { public String sayHello(String name) {...} }
wsconsume will create an interface named Hello and a class named HelloService (and possibly other classes). The code for the client is:public class Client { public static void main(String[] args) { HelloService svc = new HelloService(); Hello hello = svc.getHelloPort(); System.out.println(hello.sayHello(args[0])); } }
Compile the client with the classes generated by wsconsume, and package the client and the wsconsume classes info a jar file. Then use wsrunclient to run it:
wsrunclient -classpath client.jar Hello me -
2. Re: Call a web service
rphadnis Mar 14, 2008 2:56 PM (in response to rodosa)Can you make sure that the url for the wsdl is accessible? For example you can put the url in a browser location bar and make sure it shows up.
-
3. Re: Call a web service
rodosa Mar 15, 2008 2:30 PM (in response to rodosa)Thanks for yours answers but I should make sth bad because it doesn't work.
1) rphadnis: Yes, the url for the wsdl is accessible. I could see in the browser.
2) PeterJ: I have some problems. I follow the steps you've mencionated but I don't know what's wrong. This is what occurs when I try to execute the client.Entro en el cliente Exception in thread "main" java.lang.NoClassDefFoundError: org/jboss/util/NotImp lementedException at java.lang.Class.getDeclaredConstructors0(Native Method) at java.lang.Class.privateGetDeclaredConstructors(Class.java:2389) at java.lang.Class.getConstructor0(Class.java:2699) at java.lang.Class.newInstance0(Class.java:326) at java.lang.Class.newInstance(Class.java:308) at javax.xml.ws.spi.FactoryFinder.newInstance(FactoryFinder.java:36) at javax.xml.ws.spi.FactoryFinder.find(FactoryFinder.java:95) at javax.xml.ws.spi.Provider.provider(Provider.java:76) at javax.xml.ws.Service.<init>(Service.java:57) at client.JbpmServiceService.<init>(JbpmServiceService.java:42) at client.JbpmWSClient.main(JbpmWSClient.java:79)
Any ideas? Thank you very much -
4. Re: Call a web service
rodosa Mar 15, 2008 4:54 PM (in response to rodosa)If I run the client as Java application the following exception it's thrown:
java.lang.LinkageError: JAXB 2.0 API is being loaded from the bootstrap classloader, but this RI (from jar:file:/C:/jboss-4.2.2.GA/client/jaxb-impl.jar!/com/sun/xml/bind/v2/model/impl/ModelBuilder.class) needs 2.1 API. Use the endorsed directory mechanism to place jaxb-api.jar in the bootstrap classloader. (See http://java.sun.com/j2se/1.5.0/docs/guide/standards/) at com.sun.xml.bind.v2.model.impl.ModelBuilder.<clinit>(ModelBuilder.java:172) at com.sun.xml.bind.v2.runtime.JAXBContextImpl.getTypeInfoSet(JAXBContextImpl.java:422) at com.sun.xml.bind.v2.runtime.JAXBContextImpl.<init>(JAXBContextImpl.java:286) at com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:139) at com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:117) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at javax.xml.bind.ContextFinder.newInstance(Unknown Source) at javax.xml.bind.ContextFinder.find(Unknown Source) at javax.xml.bind.JAXBContext.newInstance(Unknown Source) at javax.xml.bind.JAXBContext.newInstance(Unknown Source) at com.sun.xml.ws.spi.ProviderImpl.getEPRJaxbContext(ProviderImpl.java:186) at com.sun.xml.ws.spi.ProviderImpl.<clinit>(ProviderImpl.java:65) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) at java.lang.reflect.Constructor.newInstance(Unknown Source) at java.lang.Class.newInstance0(Unknown Source) at java.lang.Class.newInstance(Unknown Source) at javax.xml.ws.spi.FactoryFinder.newInstance(Unknown Source) at javax.xml.ws.spi.FactoryFinder.find(Unknown Source) at javax.xml.ws.spi.Provider.provider(Unknown Source) at javax.xml.ws.Service.<init>(Unknown Source) at client.JbpmServiceService.<init>(JbpmServiceService.java:42) at client.JbpmWSClient.<clinit>(JbpmWSClient.java:85) Exception in thread "main"
I've put jaxb-api.jar in the lib/endorsed folder but it doesn't work.
Any ideas? -
5. Re: Call a web service
rodosa Mar 17, 2008 5:34 AM (in response to rodosa)The before exception was solucionated putting the libraries into the endorsed lib folder of my JAVA_HOME. But now I have another problem. I was looking information about that in google and I think that is a problem of bad situation of my files I don't now exactly. This is the exception:
Exception in thread "main" com.sun.xml.ws.model.RuntimeModelerException: runtime modeler error: Wrapper class ws.jaxws.Hola is not found. Have you run APT to generate them? at com.sun.xml.ws.model.RuntimeModeler.getClass(RuntimeModeler.java:249) at com.sun.xml.ws.model.RuntimeModeler.processDocWrappedMethod(RuntimeModeler.java:545) at com.sun.xml.ws.model.RuntimeModeler.processMethod(RuntimeModeler.java:492) at com.sun.xml.ws.model.RuntimeModeler.processClass(RuntimeModeler.java:334) at com.sun.xml.ws.model.RuntimeModeler.buildRuntimeModel(RuntimeModeler.java:220) at com.sun.xml.ws.client.WSServiceDelegate.addSEI(WSServiceDelegate.java:588) at com.sun.xml.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java:291) at com.sun.xml.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java:274) at com.sun.xml.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java:267) at javax.xml.ws.Service.getPort(Service.java:92) at client.JbpmServiceService.getJbpmServicePort(JbpmServiceService.java:52) at client.JbpmWSClient.main(JbpmWSClient.java:91)
And my files are in the following directories:
*client* //The client and the files generated with wsconsume
-Hola.java
-HolaResponse.java
-JbpmService.java
-JbpmServiceService.java
-JbpmWSClient.java
-ObjectFactory.java
-package-info.java
*ws*
-JbpmService.java
Any ideas? -
6. Re: Call a web service
rodosa Mar 17, 2008 6:08 AM (in response to rodosa)I don't know why it's looking into ws.jaxws.Hola directory because it doesn't exist! I built it and to check what happens and now the exception is :
Exception in thread "main" java.lang.IllegalArgumentException: ws.JbpmService is not an interface at java.lang.reflect.Proxy.getProxyClass(Unknown Source) at java.lang.reflect.Proxy.newProxyInstance(Unknown Source) at com.sun.xml.ws.client.WSServiceDelegate.createEndpointIFBaseProxy(WSServiceDelegate.java:546) at com.sun.xml.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java:292) at com.sun.xml.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java:274) at com.sun.xml.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java:267) at javax.xml.ws.Service.getPort(Service.java:92) at client.JbpmServiceService.getJbpmServicePort(JbpmServiceService.java:52) at client.JbpmWSClient.main(JbpmWSClient.java:91)
This is right. I haven't got the interface there, I have the class. So, how I have to put the files to this work fine??? Have I to create the jaxws manually to this works fine?? -
7. Re: Call a web service
peterj Mar 17, 2008 11:47 AM (in response to rodosa)Be careful because after you use wsconsume to generate the stubs, you will have to items named ws.JbpmService. One is the web service class, the other is the interface generated by wsconsume. You want to include only the generated interface in your client's classpath.
Also,m are you suing wsrunclient to run the client? It build the correct classpath, you need to add in only the jar file containing your client code and the generated stubs. -
8. Re: Call a web service
rodosa Mar 17, 2008 12:25 PM (in response to rodosa)Hello!
Now I'm executing from Eclipse, because I'm building an .ear that contains a dinamic web project where the web service is inside. But I got the following error:Exception in thread "main" java.lang.NoClassDefFoundError: com/sun/xml/messaging/saaj/soap/AttachmentPartImpl at com.sun.xml.ws.message.AttachmentUnmarshallerImpl.<clinit>(AttachmentUnmarshallerImpl.java:55) at com.sun.xml.ws.client.sei.ResponseBuilder$DocLit.readResponse(ResponseBuilder.java:500) at com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:242) at com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:210) at com.sun.xml.ws.client.sei.SEIStub.invoke(SEIStub.java:103) at $Proxy25.hola(Unknown Source) at client.JbpmWSClient.main(JbpmWSClient.java:95)
If I generate the jar and executing it with wsrunclient the following exception it's thrown (the library jboss-common-client.jar is in my path):Exception in thread "main" java.lang.NoClassDefFoundError: org/jboss/util/NotImplementedException at java.lang.Class.getDeclaredConstructors0(Native Method) at java.lang.Class.privateGetDeclaredConstructors(Class.java:2389) at java.lang.Class.getConstructor0(Class.java:2699) at java.lang.Class.newInstance0(Class.java:326) at java.lang.Class.newInstance(Class.java:308) at javax.xml.ws.spi.FactoryFinder.newInstance(FactoryFinder.java:36) at javax.xml.ws.spi.FactoryFinder.find(FactoryFinder.java:95) at javax.xml.ws.spi.Provider.provider(Provider.java:76) at javax.xml.ws.Service.<init>(Service.java:57) at client.JbpmServiceService.<init>(JbpmServiceService.java:42) at client.JbpmWSClient.main(JbpmWSClient.java:79)
-
9. Re: Call a web service
rodosa Mar 18, 2008 9:10 AM (in response to rodosa)Hello!!
I've get to call the web service from a Java application in Eclipse. I've solucionated the before error adding the library saaj-impl.jar.
Now I have a problem. I have jbpm-jpdl.3.2.2 installed in a remote machine.I would like to call this web service from here. But jbpm uses Jboss 4.0.4. I've added some libraries to the lib directory and I've copy the files that I've generated in the other machine (Jboss 4.2.2). I've modified the files replacing localhost with the IP where the webService exist. But it seems that it doesn't find the wsdl. I can do pings to my remote machine but if I put http://x.x.x.x:8080/proyecto/JbpmService?wsdl in the browser the system doesn't find anything.Exception in thread "main" javax.xml.ws.WebServiceException: Failed to access the WSDL at: http://x.x.x.x:8080/proyecto/JbpmService?wsdl. It failed with: Connection refused: connect. at com.sun.xml.ws.wsdl.parser.RuntimeWSDLParser.tryWithMex(RuntimeWSDLParser.java:136) at com.sun.xml.ws.wsdl.parser.RuntimeWSDLParser.parse(RuntimeWSDLParser.java:122) at com.sun.xml.ws.client.WSServiceDelegate.parseWSDL(WSServiceDelegate.java:226) at com.sun.xml.ws.client.WSServiceDelegate.<init>(WSServiceDelegate.java:189) at com.sun.xml.ws.client.WSServiceDelegate.<init>(WSServiceDelegate.java:159) at com.sun.xml.ws.spi.ProviderImpl.createServiceDelegate(ProviderImpl.java:81) at javax.xml.ws.Service.<init>(Service.java:56) at jbpmservice.ws.JbpmService_Service.<init>(JbpmService_Service.java:40) at client.JbpmWSClient.main(JbpmWSClient.java:15) Caused by: java.net.ConnectException: Connection refused: connect at java.net.PlainSocketImpl.socketConnect(Native Method) at java.net.PlainSocketImpl.doConnect(Unknown Source) at java.net.PlainSocketImpl.connectToAddress(Unknown Source) at java.net.PlainSocketImpl.connect(Unknown Source) at java.net.Socket.connect(Unknown Source) at java.net.Socket.connect(Unknown Source) at sun.net.NetworkClient.doConnect(Unknown Source) at sun.net.www.http.HttpClient.openServer(Unknown Source) at sun.net.www.http.HttpClient.openServer(Unknown Source) at sun.net.www.http.HttpClient.<init>(Unknown Source) at sun.net.www.http.HttpClient.New(Unknown Source) at sun.net.www.http.HttpClient.New(Unknown Source) at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(Unknown Source) at sun.net.www.protocol.http.HttpURLConnection.plainConnect(Unknown Source) at sun.net.www.protocol.http.HttpURLConnection.connect(Unknown Source) at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source) at java.net.URL.openStream(Unknown Source) at com.sun.xml.ws.wsdl.parser.RuntimeWSDLParser.createReader(RuntimeWSDLParser.java:785) at com.sun.xml.ws.wsdl.parser.RuntimeWSDLParser.resolveWSDL(RuntimeWSDLParser.java:236) at com.sun.xml.ws.wsdl.parser.RuntimeWSDLParser.parse(RuntimeWSDLParser.java:107) ... 7 more
Any ideas?
Thanks -
10. Re: Call a web service
randhawag Jul 6, 2009 3:51 PM (in response to rodosa)Has anyone been able to resolve this?
We have difficulty connecting via client to web service endpoint.
When running client we see,
JBDS 2.0 GA
JAX-WS 2.0
Server: JBoss 4.3 EAP CP02
***********************
Create Web Service Client...
Create Web Service...
Call Web Service Operation...
Exception in thread "main" java.lang.NoClassDefFoundError: com/sun/xml/messaging/saaj/soap/AttachmentPartImpl
at com.sun.xml.ws.message.AttachmentUnmarshallerImpl.(AttachmentUnmarshallerImpl.java:55)
at com.sun.xml.ws.client.sei.ResponseBuilder$RpcLit$PartBuilder.readResponse(ResponseBuilder.java:635)
at com.sun.xml.ws.client.sei.ResponseBuilder$RpcLit.readResponse(ResponseBuilder.java:599)
at com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:242)
at com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:210)
at com.sun.xml.ws.client.sei.SEIStub.invoke(SEIStub.java:103)
at $Proxy22.echo(Unknown Source)
at venture.services.helloworld.clientsample.ClientSample.main(ClientSample.java:16)
Caused by: java.lang.ClassNotFoundException: com.sun.xml.messaging.saaj.soap.AttachmentPartImpl
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
... 8 more