1 package demo.callback.client; 2 3 import java.io.File ; 4 import java.net.URL ; 5 6 import javax.xml.namespace.QName ; 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 SERVICE_NAME 23 = new QName ("http://objectweb.org/callback", "SOAPService"); 24 25 private Client() { 26 } 27 28 public static void main(String args[]) throws Exception { 29 30 Bus bus = Bus.init(); 31 32 Object implementor = new CallbackImpl(); 33 String 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 wsdlURL; 42 File wsdlFile = new File (args[0]); 43 if (wsdlFile.exists()) { 44 wsdlURL = wsdlFile.toURL(); 45 } else { 46 wsdlURL = new URL (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 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 |