List of usage examples for javax.xml.ws Service getPort
public <T> T getPort(Class<T> serviceEndpointInterface)
From source file:org.jboss.additional.testsuite.jdkall.present.web.mtom.MtomTestCase.java
@Test public void mtomTest() throws Exception { URL url = new URL("http://localhost:8080/war-mtom?wsdl"); QName qname = new QName("http://mtom.web.present.jdkall.testsuite.additional.jboss.org/", "ImageServerImplService"); String path = this.getClass().getClassLoader().getResource("").getPath(); FileInputStream inputStream = new FileInputStream(path + "../" + serverLogPath); try {/*from w w w .jav a2s .co m*/ String everything = IOUtils.toString(inputStream); assertFalse("Testing archive has enabled mtom feature", everything.contains("mtomEnabled=true")); } finally { inputStream.close(); } Service service = Service.create(url, qname); ImageServer imageServer = service.getPort(ImageServer.class); //enable MTOM in client BindingProvider bp = (BindingProvider) imageServer; SOAPBinding binding = (SOAPBinding) bp.getBinding(); binding.setMTOMEnabled(true); Image im = imageServer.downloadImage(path + "rss.png"); if (im == null) { fail(); } }
From source file:org.jboss.as.jbossws.jbpapp10625.DuplicateServicesGeneratedWsdlIT.java
protected <T> T createServiceProxy(String serviceURL, Class<T> serviceProxyClass, QName serviceName) throws MalformedURLException { Service service = Service.create(createWsdlUrl(serviceURL), serviceName); return service.getPort(serviceProxyClass); }
From source file:org.jboss.as.test.integration.ws.wsse.trust.WSBearerElytronSecurityPropagationTestCase.java
@Test @RunAsClient/*from w w w . ja va 2s . c o m*/ @OperateOnDeployment(BEARER_SERVER_DEP) @WrapThreadContextClassLoader public void testBearer() throws Exception { // TLSv1.2 seems buggy on JDK-11 (Invalid ECDH ServerKeyExchange signature) String originalProtocols = System.getProperty("https.protocols"); System.setProperty("https.protocols", "TLSv1.1"); Bus bus = BusFactory.newInstance().createBus(); try { BusFactory.setThreadDefaultBus(bus); final QName serviceName = new QName("http://www.jboss.org/jbossws/ws-extensions/bearerwssecuritypolicy", "BearerService"); Service service = Service.create(new URL(serviceURL + "BearerService?wsdl"), serviceName); BearerIface proxy = (BearerIface) service.getPort(BearerIface.class); WSTrustTestUtils.setupWsseAndSTSClientBearer((BindingProvider) proxy, bus); assertEquals("alice&alice", proxy.sayHello()); } finally { bus.shutdown(true); if (originalProtocols == null) { System.clearProperty("https.protocols"); } else { System.setProperty("https.protocols", originalProtocols); } } }
From source file:org.jboss.as.test.integration.ws.wsse.trust.WSTrustTestCase.java
/** * WS-Trust test with the STS information programmatically provided * * @throws Exception// w w w . j av a 2 s. co m */ @Test @RunAsClient @OperateOnDeployment(SERVER_DEP) @WrapThreadContextClassLoader public void test() throws Exception { Bus bus = BusFactory.newInstance().createBus(); try { BusFactory.setThreadDefaultBus(bus); final QName serviceName = new QName("http://www.jboss.org/jbossws/ws-extensions/wssecuritypolicy", "SecurityService"); final URL wsdlURL = new URL(serviceURL + "SecurityService?wsdl"); Service service = Service.create(wsdlURL, serviceName); ServiceIface proxy = (ServiceIface) service.getPort(ServiceIface.class); final QName stsServiceName = new QName("http://docs.oasis-open.org/ws-sx/ws-trust/200512/", "SecurityTokenService"); final QName stsPortName = new QName("http://docs.oasis-open.org/ws-sx/ws-trust/200512/", "UT_Port"); URL stsURL = new URL(serviceURL.getProtocol(), serviceURL.getHost(), serviceURL.getPort(), "/jaxws-samples-wsse-policy-trust-sts/SecurityTokenService?wsdl"); WSTrustTestUtils.setupWsseAndSTSClient(proxy, bus, stsURL.toString(), stsServiceName, stsPortName); try { assertEquals("WS-Trust Hello World!", proxy.sayHello()); } catch (Exception e) { e.printStackTrace(); throw e; } } finally { bus.shutdown(true); } }
From source file:org.jboss.as.test.integration.ws.wsse.trust.WSTrustTestCase.java
/** * WS-Trust test with the STS information coming from EPR specified in service endpoint contract policy * * @throws Exception//www .j a v a 2s . c o m */ @Test @RunAsClient @OperateOnDeployment(SERVER_DEP) @WrapThreadContextClassLoader public void testUsingEPR() throws Exception { Bus bus = BusFactory.newInstance().createBus(); try { BusFactory.setThreadDefaultBus(bus); final QName serviceName = new QName("http://www.jboss.org/jbossws/ws-extensions/wssecuritypolicy", "SecurityService"); final URL wsdlURL = new URL(serviceURL + "SecurityService?wsdl"); Service service = Service.create(wsdlURL, serviceName); ServiceIface proxy = (ServiceIface) service.getPort(ServiceIface.class); WSTrustTestUtils.setupWsse(proxy, bus); try { assertEquals("WS-Trust Hello World!", proxy.sayHello()); } catch (Exception e) { throw e; } } finally { bus.shutdown(true); } }
From source file:org.jboss.as.test.integration.ws.wsse.trust.WSTrustTestCase.java
/** * No CallbackHandler is provided in STSCLient. Username and password provided instead. * * @throws Exception//from w ww.j av a 2 s . c o m */ @Test @RunAsClient @OperateOnDeployment(SERVER_DEP) @WrapThreadContextClassLoader public void testNoClientCallback() throws Exception { Bus bus = BusFactory.newInstance().createBus(); try { BusFactory.setThreadDefaultBus(bus); final QName serviceName = new QName("http://www.jboss.org/jbossws/ws-extensions/wssecuritypolicy", "SecurityService"); final URL wsdlURL = new URL(serviceURL + "SecurityService?wsdl"); Service service = Service.create(wsdlURL, serviceName); ServiceIface proxy = (ServiceIface) service.getPort(ServiceIface.class); final QName stsServiceName = new QName("http://docs.oasis-open.org/ws-sx/ws-trust/200512/", "SecurityTokenService"); final QName stsPortName = new QName("http://docs.oasis-open.org/ws-sx/ws-trust/200512/", "UT_Port"); URL stsURL = new URL(serviceURL.getProtocol(), serviceURL.getHost(), serviceURL.getPort(), "/jaxws-samples-wsse-policy-trust-sts/SecurityTokenService?wsdl"); WSTrustTestUtils.setupWsseAndSTSClientNoCallbackHandler(proxy, bus, stsURL.toString(), stsServiceName, stsPortName); assertEquals("WS-Trust Hello World!", proxy.sayHello()); } finally { bus.shutdown(true); } }
From source file:org.jboss.as.test.integration.ws.wsse.trust.WSTrustTestCase.java
/** * No SIGNATURE_USERNAME is provided to the service. Service will use the * client's keystore alias in its place. * * @throws Exception/*from www . j av a 2 s. c o m*/ */ @Test @RunAsClient @OperateOnDeployment(SERVER_DEP) @WrapThreadContextClassLoader public void testNoSignatureUsername() throws Exception { Bus bus = BusFactory.newInstance().createBus(); try { BusFactory.setThreadDefaultBus(bus); final QName serviceName = new QName("http://www.jboss.org/jbossws/ws-extensions/wssecuritypolicy", "SecurityService"); final URL wsdlURL = new URL(serviceURL + "SecurityService?wsdl"); Service service = Service.create(wsdlURL, serviceName); ServiceIface proxy = (ServiceIface) service.getPort(ServiceIface.class); final QName stsServiceName = new QName("http://docs.oasis-open.org/ws-sx/ws-trust/200512/", "SecurityTokenService"); final QName stsPortName = new QName("http://docs.oasis-open.org/ws-sx/ws-trust/200512/", "UT_Port"); URL stsURL = new URL(serviceURL.getProtocol(), serviceURL.getHost(), serviceURL.getPort(), "/jaxws-samples-wsse-policy-trust-sts/SecurityTokenService?wsdl"); WSTrustTestUtils.setupWsseAndSTSClientNoSignatureUsername(proxy, bus, stsURL.toString(), stsServiceName, stsPortName); assertEquals("WS-Trust Hello World!", proxy.sayHello()); } finally { bus.shutdown(true); } }
From source file:org.jboss.as.test.integration.ws.wsse.trust.WSTrustTestCase.java
/** * Request a security token that allows it to act as if it were somebody else. * * @throws Exception// w w w. j a v a 2 s. c o m */ @Test @RunAsClient @OperateOnDeployment(ACT_AS_SERVER_DEP) @WrapThreadContextClassLoader public void testActAs() throws Exception { Bus bus = BusFactory.newInstance().createBus(); try { BusFactory.setThreadDefaultBus(bus); final QName serviceName = new QName("http://www.jboss.org/jbossws/ws-extensions/actaswssecuritypolicy", "ActAsService"); final URL wsdlURL = new URL(serviceURL + "ActAsService?wsdl"); Service service = Service.create(wsdlURL, serviceName); ActAsServiceIface proxy = (ActAsServiceIface) service.getPort(ActAsServiceIface.class); WSTrustTestUtils.setupWsseAndSTSClientActAs((BindingProvider) proxy, bus); assertEquals("ActAs WS-Trust Hello World!", proxy.sayHello(serviceURL.getHost(), String.valueOf(serviceURL.getPort()))); } finally { bus.shutdown(true); } }
From source file:org.jboss.as.test.integration.ws.wsse.trust.WSTrustTestCase.java
/** * Request a security token that allows it to act on behalf of somebody else. * * @throws Exception/*from w ww.j a v a 2 s .c om*/ */ @Test @RunAsClient @OperateOnDeployment(ON_BEHALF_OF_SERVER_DEP) @WrapThreadContextClassLoader public void testOnBehalfOf() throws Exception { Bus bus = BusFactory.newInstance().createBus(); try { BusFactory.setThreadDefaultBus(bus); final QName serviceName = new QName( "http://www.jboss.org/jbossws/ws-extensions/onbehalfofwssecuritypolicy", "OnBehalfOfService"); final URL wsdlURL = new URL(serviceURL + "OnBehalfOfService?wsdl"); Service service = Service.create(wsdlURL, serviceName); OnBehalfOfServiceIface proxy = (OnBehalfOfServiceIface) service.getPort(OnBehalfOfServiceIface.class); WSTrustTestUtils.setupWsseAndSTSClientOnBehalfOf((BindingProvider) proxy, bus); assertEquals("OnBehalfOf WS-Trust Hello World!", proxy.sayHello(serviceURL.getHost(), String.valueOf(serviceURL.getPort()))); } finally { bus.shutdown(true); } }
From source file:org.jboss.as.test.integration.ws.wsse.trust.WSTrustTestCase.java
@Test @RunAsClient/*from w w w . java2s . c o m*/ @OperateOnDeployment(HOLDER_OF_KEY_SERVER_DEP) @WrapThreadContextClassLoader public void testHolderOfKey() throws Exception { Bus bus = BusFactory.newInstance().createBus(); try { BusFactory.setThreadDefaultBus(bus); final QName serviceName = new QName( "http://www.jboss.org/jbossws/ws-extensions/holderofkeywssecuritypolicy", "HolderOfKeyService"); final URL wsdlURL = new URL("https", serviceURL.getHost(), serviceURL.getPort() - 8080 + 8444, "/jaxws-samples-wsse-policy-trust-holderofkey/HolderOfKeyService?wsdl"); Service service = Service.create(wsdlURL, serviceName); HolderOfKeyIface proxy = (HolderOfKeyIface) service.getPort(HolderOfKeyIface.class); WSTrustTestUtils.setupWsseAndSTSClientHolderOfKey((BindingProvider) proxy, bus); assertEquals("Holder-Of-Key WS-Trust Hello World!", proxy.sayHello()); } finally { bus.shutdown(true); } }