List of usage examples for javax.xml.ws Service getPort
public <T> T getPort(Class<T> serviceEndpointInterface, WebServiceFeature... features)
From source file:demo.wssec.client.Client.java
public static void main(String args[]) throws Exception { if (args.length == 0) { System.out.println("please specify wsdl"); System.exit(1);/*from ww w .j a va2 s . c o m*/ } URL wsdlURL; File wsdlFile = new File(args[0]); if (wsdlFile.exists()) { wsdlURL = wsdlFile.toURI().toURL(); } else { wsdlURL = new URL(args[0]); } SpringBusFactory bf = new SpringBusFactory(); URL busFile = new ClassPathResource("wssec-client.xml").getURL(); Bus bus = bf.createBus(busFile.toString()); SpringBusFactory.setDefaultBus(bus); SpringBusFactory.setThreadDefaultBus(bus); Service service = Service.create(wsdlURL, SERVICE_NAME); Greeter port = service.getPort(PORT_NAME, Greeter.class); System.out.println("Invoking greetMe..."); try { String resp = port.greetMe(System.getProperty("user.name")); System.out.println("Server responded with: " + resp); System.out.println(); } catch (Exception e) { System.out.println("Invocation failed with the following: " + e.getCause()); System.out.println(); } System.exit(0); }
From source file:de.intevation.test.irixservice.UploadReportTest.java
/** * Test that the webservice can be created and accepts a valid report. *//*from w w w .j av a2 s. com*/ @Test public void testServiceCreated() throws MalformedURLException, IOException, UploadReportException { Endpoint endpoint = Endpoint.publish("http://localhost:18913/upload-report", testObj); Assert.assertTrue(endpoint.isPublished()); Assert.assertEquals("http://schemas.xmlsoap.org/wsdl/soap/http", endpoint.getBinding().getBindingID()); URL wsdlDocumentLocation = new URL("http://localhost:18913/upload-report?wsdl"); String namespaceURI = "http://irixservice.intevation.de/"; String servicePart = "UploadReportService"; String portName = "UploadReportPort"; QName serviceQN = new QName(namespaceURI, servicePart); QName portQN = new QName(namespaceURI, portName); Service serv = Service.create(wsdlDocumentLocation, serviceQN); UploadReportInterface service = serv.getPort(portQN, UploadReportInterface.class); ReportType report = getReportFromFile(VALID_REPORT); service.uploadReport(report); String uuid = report.getIdentification().getReportUUID(); String expectedPath = testObj.outputDir + "/" + uuid + ".xml"; Assert.assertTrue(new File(expectedPath).exists()); }
From source file:org.apache.servicemix.camel.nmr.ws.security.WSSecurityTest.java
public void testTimestampSignEncrypt() { LOG.info("test security"); Bus bus = new SpringBusFactory().createBus("org/apache/servicemix/camel/ws/security/client.xml"); BusFactory.setDefaultBus(bus);// ww w.ja va 2 s . c om LoggingInInterceptor in = new LoggingInInterceptor(); bus.getInInterceptors().add(in); bus.getInFaultInterceptors().add(in); LoggingOutInterceptor out = new LoggingOutInterceptor(); bus.getOutInterceptors().add(out); bus.getOutFaultInterceptors().add(out); final javax.xml.ws.Service svc = javax.xml.ws.Service.create(WSDL_LOC, new javax.xml.namespace.QName("http://apache.org/hello_world_soap_http", "SOAPServiceWSSecurity")); final Greeter greeter = svc.getPort( new javax.xml.namespace.QName("http://apache.org/hello_world_soap_http", "TimestampSignEncrypt"), Greeter.class); String ret = greeter.sayHi(); assertEquals(ret, "Bonjour"); ret = greeter.greetMe("ffang"); assertEquals(ret, "Hello ffang"); }
From source file:kms.prolog.comms.TransportServlet.java
public TransportServiceImpl getTransportModuleWebService(String transportId) throws ServiceException, MalformedURLException { if (transportId != null) { Transport transport = transportManager.findById(transportId); String wsdlURL = transport.getWsdl(); String namespace = transport.getNamespace(); String serviceName = transport.getServiceName(); String portName = transport.getPortName(); QName serviceQN = new QName(namespace, serviceName); QName portQN = new QName(namespace, portName); Service requestedService = Service.create(new URL(wsdlURL), serviceQN); TransportServiceImpl port = (TransportServiceImpl) requestedService.getPort(portQN, TransportServiceImpl.class); return port; } else {//from w ww . j a v a 2 s. c o m return null; } }
From source file:nl.tue.gale.geb.GEBManager.java
private void init() { if (!"true".equals(GaleUtil.getProperty("useGEB"))) return;//from w w w. j a v a 2 s. co m if (initialized) return; try { URL url; Service service; url = new URL(gebURL, "gebListenerService?wsdl"); service = Service.create(url, new QName("http://j2ee.netbeans.org/wsdl/GEB/gebListener", "gebListenerService")); gebListenerService = (GEBListenerService) service.getPort( new QName("http://j2ee.netbeans.org/wsdl/GEB/gebListener", "gebListenerPort"), GEBListenerService.class); url = new URL(gebURL, "eventGEBListenerService?wsdl"); service = Service.create(url, new QName("http://j2ee.netbeans.org/wsdl/GEB/eventGEBListener", "eventGEBListenerService")); eventGEBListenerService = (EventGEBListenerService) service.getPort( new QName("http://j2ee.netbeans.org/wsdl/GEB/eventGEBListener", "eventGEBListenerPort"), EventGEBListenerService.class); } catch (Exception e) { throw new IllegalArgumentException("unable to initialize GEBManager: " + e.getMessage(), e); } initialized = true; try { for (Map.Entry<String, String> entry : autoRegister.entrySet()) { if (!registerService(entry.getValue().trim(), Arrays.asList(entry.getKey().trim().split(";")))) System.out.println("unable to register (assuming already registered)"); } } catch (Exception e) { throw new IllegalArgumentException( "unable to auto-register the EventListener on GEB: " + e.getMessage(), e); } }
From source file:org.apache.coheigea.cxf.jdbc.authentication.AuthenticationTest.java
@org.junit.Test public void testAuthenticatedRequestViaJetty() throws Exception { SpringBusFactory bf = new SpringBusFactory(); URL busFile = AuthenticationTest.class.getResource("cxf-client.xml"); Bus bus = bf.createBus(busFile.toString()); SpringBusFactory.setDefaultBus(bus); SpringBusFactory.setThreadDefaultBus(bus); URL wsdl = AuthenticationTest.class.getResource("DoubleIt.wsdl"); Service service = Service.create(wsdl, SERVICE_QNAME); QName portQName = new QName(NAMESPACE, "DoubleItTransportUTJettyPort"); DoubleItPortType transportPort = service.getPort(portQName, DoubleItPortType.class); TestUtil.updateAddressPort(transportPort, PORT); Client client = ClientProxy.getClient(transportPort); client.getRequestContext().put("ws-security.username", "alice"); doubleIt(transportPort, 25);// w w w . j a va2 s. com }
From source file:org.apache.coheigea.cxf.jdbc.authentication.AuthenticationTest.java
@org.junit.Test public void testUnauthenticatedRequestViaJetty() throws Exception { SpringBusFactory bf = new SpringBusFactory(); URL busFile = AuthenticationTest.class.getResource("cxf-client.xml"); Bus bus = bf.createBus(busFile.toString()); SpringBusFactory.setDefaultBus(bus); SpringBusFactory.setThreadDefaultBus(bus); URL wsdl = AuthenticationTest.class.getResource("DoubleIt.wsdl"); Service service = Service.create(wsdl, SERVICE_QNAME); QName portQName = new QName(NAMESPACE, "DoubleItTransportUTJettyPort"); DoubleItPortType transportPort = service.getPort(portQName, DoubleItPortType.class); TestUtil.updateAddressPort(transportPort, PORT); Client client = ClientProxy.getClient(transportPort); client.getRequestContext().put("ws-security.username", "bob"); try {/*from w w w . ja v a 2 s. c om*/ doubleIt(transportPort, 25); Assert.fail("Failure expected on bob"); } catch (Exception ex) { // expected } }
From source file:org.apache.coheigea.cxf.jdbc.authorization.AuthorizationTest.java
@org.junit.Test public void testAuthorizedRequestViaJetty() throws Exception { SpringBusFactory bf = new SpringBusFactory(); URL busFile = AuthorizationTest.class.getResource("cxf-client.xml"); Bus bus = bf.createBus(busFile.toString()); SpringBusFactory.setDefaultBus(bus); SpringBusFactory.setThreadDefaultBus(bus); URL wsdl = AuthorizationTest.class.getResource("DoubleIt.wsdl"); Service service = Service.create(wsdl, SERVICE_QNAME); QName portQName = new QName(NAMESPACE, "DoubleItTransportUTJettyPort"); DoubleItPortType transportPort = service.getPort(portQName, DoubleItPortType.class); TestUtil.updateAddressPort(transportPort, PORT); Client client = ClientProxy.getClient(transportPort); client.getRequestContext().put("ws-security.username", "alice"); doubleIt(transportPort, 25);/* w w w . jav a2 s . c om*/ }
From source file:org.apache.coheigea.cxf.jdbc.authorization.AuthorizationTest.java
@org.junit.Test public void testUnauthorizedRequestViaJetty() throws Exception { SpringBusFactory bf = new SpringBusFactory(); URL busFile = AuthorizationTest.class.getResource("cxf-client.xml"); Bus bus = bf.createBus(busFile.toString()); SpringBusFactory.setDefaultBus(bus); SpringBusFactory.setThreadDefaultBus(bus); URL wsdl = AuthorizationTest.class.getResource("DoubleIt.wsdl"); Service service = Service.create(wsdl, SERVICE_QNAME); QName portQName = new QName(NAMESPACE, "DoubleItTransportUTJettyPort"); DoubleItPortType transportPort = service.getPort(portQName, DoubleItPortType.class); TestUtil.updateAddressPort(transportPort, PORT); Client client = ClientProxy.getClient(transportPort); client.getRequestContext().put("ws-security.username", "bob"); try {//from w w w . j a v a 2s. c o m doubleIt(transportPort, 25); Assert.fail("Failure expected on bob"); } catch (Exception ex) { // expected } }
From source file:org.apache.coheigea.cxf.kerberos.authentication.AuthenticationTest.java
@org.junit.Test public void testKerberos() throws Exception { SpringBusFactory bf = new SpringBusFactory(); URL busFile = AuthenticationTest.class.getResource("cxf-client.xml"); Bus bus = bf.createBus(busFile.toString()); SpringBusFactory.setDefaultBus(bus); SpringBusFactory.setThreadDefaultBus(bus); URL wsdl = AuthenticationTest.class.getResource("DoubleIt.wsdl"); Service service = Service.create(wsdl, SERVICE_QNAME); QName portQName = new QName(NAMESPACE, "DoubleItKerberosTransportPort"); DoubleItPortType transportPort = service.getPort(portQName, DoubleItPortType.class); TestUtil.updateAddressPort(transportPort, PORT); doubleIt(transportPort, 25);//from w w w. ja v a 2 s . co m }