Professional Documents
Culture Documents
import java.rmi.Remote;
Import java.rmi.RemoteException;
public interface HelloIF extends Remote {
public String sayHello(String s) throws
RemoteException;
}
Implement the service
package helloservice;
1. Static stubs
compiled by wscompile before runtime
2. Dynamic stubs
has an interface but fetches the WSDL at runtime
3. Dynamic Invocation Interface
knows no interface - the method names
and signatures
4. A J2EE Application Client
Locate the local web service with JNDI
Client Using a Static Stub
import javax.xml.rpc.Stub; It almost looks like a local call.
ServiceFactory serviceFactory =
ServiceFactory.newInstance();
Service helloService =
serviceFactory.createService(helloWsdlUrl,
new QName(nameSpaceUri, serviceName));
helloService.getPort(
new QName(nameSpaceUri, portName),
dynamicproxy.HelloIF.class);
System.out.println(myProxy.sayHello("Buzz"));
try {
ServiceFactory factory =
ServiceFactory.newInstance();
call.setOperationName(
new QName(BODY_NAMESPACE_VALUE,"sayHello"));
call.addParameter("String_1", QNAME_TYPE_STRING,
ParameterMode.IN);
String[] params = { "Murph!" };
((Stub)helloPort)._setProperty
(Stub.ENDPOINT_ADDRESS_PROPERTY,args[0]);
System.out.println(helloPort.sayHello("Jake!"));
System.exit(0);