You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by Wolfram Ditzer <di...@optel-informatik.de> on 2003/10/10 14:42:34 UTC
WSDL2Java Stub and Call objects
Hello,
I use a wsdl2java to generate client classes. I also get a
MyServiceStub.java, which prvides a interface to my webservices.
When I look into this list and a lot of example I see nearly nno one
using ths Stub-classes. Instead all people uses Call objects created by
a Service object.
Shouldn´ t I use my Stub class MyServiceStub?
Can I have access to internal used Call objects of my Stub class?
Thanks Wolfram
RE: WSDL2Java Stub and Call objects
Posted by Alex Chen <al...@sbcglobal.net>.
In my experience, I use the sample code under samples/jaxrpc/hello.
In that example, I use the '--server-side --skeletonDeploy
true --deployScope Application' flags
to build the wsdl file, i.e. I use my own build.xml. The following files are
created:
Hello.java <-- RPC interface
HelloWorld.java <-- Service interface
HelloWorldLocator.java <-- Service locator, i.e. client stub locator
HelloBindingStub.java <-- Client side stub
HelloBindingSkeleton.java <-- Server side skeleton
HelloBindingImpl.java <-- Server side implementation, WSDL2Java will
not overwrite it if it exits
The client program is HelloClient.java. The original program uses
ServiceFactory to get the service, i.e.
public static void main(String[] args) throws Exception {
String UrlString =
"http://localhost:8080/axis/services/HelloPort?wsdl";
String nameSpaceUri = "http://hello.jaxrpc.samples/";
String serviceName = "HelloWorld";
String portName = "HelloPort";
URL helloWsdlUrl = new URL(UrlString);
// BEGIN
ServiceFactory serviceFactory = ServiceFactory.newInstance();
Service helloService = serviceFactory.createService(helloWsdlUrl,
new QName(nameSpaceUri, serviceName));
java.util.List list =
helloService.getHandlerRegistry().getHandlerChain(new QName(nameSpaceUri,
portName));
list.add(new
javax.xml.rpc.handler.HandlerInfo(ClientHandler.class,null,null));
Hello myProxy = (Hello) helloService.getPort(
new QName(nameSpaceUri, portName),
samples.jaxrpc.hello.Hello.class);
// END
System.out.println(myProxy.sayHello("Buzz"));
}
But you can use the following two lines of code to replace code between
'BEGIN' and 'END':
HelloWorld helloService = new HelloWorldLocator();
Hello myProxy = helloService.getHelloPort(helloWsdlUrl);
The HelloBindingStub is used internally in HelloWorldLocator.getHelloPort.
There is a bug in WSDL2Java that the default getHelloPort() it generates
does not work. You have to use the
one that takes a URL.
This is somewhat explained in the user's guide.
-----Original Message-----
From: Wolfram Ditzer [mailto:ditzer@optel-informatik.de]
Sent: Friday, October 10, 2003 5:43 AM
To: axis-user@ws.apache.org
Subject: WSDL2Java Stub and Call objects
Hello,
I use a wsdl2java to generate client classes. I also get a
MyServiceStub.java, which prvides a interface to my webservices.
When I look into this list and a lot of example I see nearly nno one
using ths Stub-classes. Instead all people uses Call objects created by
a Service object.
Shouldn´ t I use my Stub class MyServiceStub?
Can I have access to internal used Call objects of my Stub class?
Thanks Wolfram