blob: be8401e8453c7356ceed31769ae14a14c27bc18d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
package examples.session.ws;
import java.net.URL;
import javax.xml.namespace.QName;
import javax.xml.ws.Service;
/**
* This is an example of a standalone JAX-WS client. To compile,
* it requires some XML artifacts to be generated from the service's
* WSDL. This is done in the build file.
*
* The mapped XML classes used her are
* 1. the HelloBean port type class (this is NOT the bean impl. class!)
* 2. the Greeter service class
*/
public class JAXWSClient {
static String host = "localhost";
static String portType = "HelloBean";
static String serviceName = "Greeter";
static String serviceEndpointAddress = "http://" + host + ":8080/" + serviceName;
static String nameSpace = "urn:ws.session.examples";
public static void main(String[] args) throws Exception {
URL wsdlLocation = new URL(serviceEndpointAddress + "/" + portType + "?WSDL");
QName serviceNameQ = new QName( nameSpace, serviceName);
// dynamic service usage
Service service = Service.create(wsdlLocation, serviceNameQ);
HelloBean firstGreeterPort = service.getPort(HelloBean.class);
System.out.println("1: " + firstGreeterPort.hello());
// static service usage
// Greeter greeter = new Greeter();
// HelloBean secondGreeterPort = greeter.getGreeterPort();
// System.out.println("2: " +secondGreeterPort.hello());
}
}
|