Hi,
I have a question about the Dynamic Proxy Client which is extracted from the scjws guide of Mikalai Zaikin.
1/ How can I compile this
java code because I don't have the com.example.HelloIF class when I write the client ?
2/ If the web service uses complex types in parameters, you don't have these complex types when you write this dynamic proxy client, how can I compile the java client code ?
Thanks.
Olivier
package com.example;
import java.net.URL;
import javax.xml.rpc.Service;
import javax.xml.rpc.JAXRPCException;
import javax.xml.namespace.QName;
import javax.xml.rpc.ServiceFactory;
public class HelloClient {
public static void main(
String[] args) {
try {
String UrlString = "http://localhost:8080/ProxyHelloWorld.wsdl";
String nameSpaceUri = "http://sample.proxy.org/wsdl";
String serviceName = "HelloWorld"; // maps to service name in WSDL
String portName = "HelloIFPort"; // maps to port name in WSDL
URL helloWsdlUrl = new URL(UrlString);
ServiceFactory serviceFactory = ServiceFactory.newInstance();
// Create a Service object named helloService
Service helloService = serviceFactory.createService(helloWsdlUrl, new QName(nameSpaceUri, serviceName));
// Destination for service endpoint retrieval
QName qn = new QName(nameSpaceUri, portName);
// Create a proxy with type of interface 'com.example.HelloIF'
HelloIF myProxy = (HelloIF) helloService.getPort(qn, com.example.HelloIF.class);
System.out.println(myProxy.sayHello("Duke"));
} catch (Exception ex) {
ex.printStackTrace();
}
}
}