KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > demo > callback > client > Client


1 package demo.callback.client;
2
3 import java.io.File JavaDoc;
4 import java.net.URL JavaDoc;
5
6 import javax.xml.namespace.QName JavaDoc;
7 import javax.xml.ws.Endpoint;
8
9 import org.objectweb.callback.SOAPService;
10 import org.objectweb.callback.ServerPortType;
11 import org.objectweb.celtix.Bus;
12 import org.objectweb.celtix.bus.wsdl.WSDLManagerImpl;
13 import org.objectweb.celtix.ws.addressing.EndpointReferenceType;
14 import org.objectweb.celtix.wsdl.EndpointReferenceUtils;
15
16
17
18
19
20 public final class Client {
21
22     private static final QName JavaDoc SERVICE_NAME
23         = new QName JavaDoc("http://objectweb.org/callback", "SOAPService");
24
25     private Client() {
26     }
27
28     public static void main(String JavaDoc args[]) throws Exception JavaDoc {
29         
30         Bus bus = Bus.init();
31         
32         Object JavaDoc implementor = new CallbackImpl();
33         String JavaDoc address = "http://localhost:9005/CallbackContext/CallbackPort";
34         Endpoint.publish(address, implementor);
35         
36         if (args.length == 0) {
37             System.out.println("please specify wsdl");
38             System.exit(1);
39         }
40
41         URL JavaDoc wsdlURL;
42         File JavaDoc wsdlFile = new File JavaDoc(args[0]);
43         if (wsdlFile.exists()) {
44             wsdlURL = wsdlFile.toURL();
45         } else {
46             wsdlURL = new URL JavaDoc(args[0]);
47         }
48         
49         SOAPService ss = new SOAPService(wsdlURL, SERVICE_NAME);
50         ServerPortType port = ss.getSOAPPort();
51         
52         EndpointReferenceType ref =
53             EndpointReferenceUtils.getEndpointReference(new WSDLManagerImpl(bus), implementor);
54         
55
56         String JavaDoc resp = port.registerCallback(ref);
57
58         System.out.println("Response from server: " + resp);
59         
60         bus.shutdown(true);
61         
62         System.exit(0);
63     }
64
65 }
66
Popular Tags