@Override public boolean test() { String repoUrl = repositoryMeta.getRepositoryLocation().getUrl(); final String url = repoUrl + ( repoUrl.endsWith( "/" ) ? "" : "/" ) + "webservices/unifiedRepository?wsdl"; Service service; try { service = Service.create( new URL( url ), new QName( "http://www.pentaho.org/ws/1.0", "unifiedRepository" ) ); if ( service != null ) { IUnifiedRepositoryJaxwsWebService repoWebService = service.getPort( IUnifiedRepositoryJaxwsWebService.class ); if ( repoWebService != null ) { return true; } } } catch ( Exception e ) { return false; } return false; }
@Test public void test() throws Exception { QName serviceName = new QName("http://www.jboss.org/jbossas/quickstarts/wshelloworld/HelloWorld", "HelloWorldService"); Service service = Service.create(new URL("http://localhost:" + getPort()), serviceName); HelloWorldService helloWorldService = service.getPort(HelloWorldService.class); assertThat(helloWorldService).isInstanceOf(BindingProvider.class); final BindingProvider bindingProvider = (BindingProvider) helloWorldService; boolean clientHandlerFound = false; for (Handler handler : bindingProvider.getBinding().getHandlerChain()) { if (handler instanceof TracingClientSOAPHandler) { clientHandlerFound = true; } } assertThat(clientHandlerFound).overridingErrorMessage("No %s found in %s", TracingClientSOAPHandler.class.getSimpleName(), bindingProvider.getBinding().getHandlerChain()).isTrue(); }
@Test public void testClientServer() throws Exception { Bus bus = new SpringBusFactory().createBus("org/apache/cxf/systest/ws/security/handler/client.xml"); BusFactory.setDefaultBus(bus); BusFactory.setThreadDefaultBus(bus); Service service = Service.create(new URL("http://localhost:" + PORT + "/wsse/HelloWorldWS?wsdl"), new QName("http://cxf.apache.org/wsse/handler/helloworld", "HelloWorldImplService")); QName portName = new QName("http://cxf.apache.org/wsse/handler/helloworld", "HelloWorldPort"); HelloWorld port = service.getPort(portName, HelloWorld.class); updateAddressPort(port, PORT); assertEquals("Hello CXF", port.sayHello("CXF")); bus.shutdown(true); }
@Test public void testWithManualMultiplexEprCreation() throws Exception { Service numService = Service.create(NumberFactoryImpl.NUMBER_SERVICE_QNAME); Number num = numService.getPort(Number.class); InvocationHandler handler = Proxy.getInvocationHandler(num); BindingProvider bp = (BindingProvider)handler; bp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, NUMBER_SERVANT_ADDRESS_ROOT + "103"); IsEvenResponse numResp = num.isEven(); assertTrue("103 is not even", Boolean.FALSE.equals(numResp.isEven())); }
@org.junit.Test public void testSignedSAML() throws Exception { SpringBusFactory bf = new SpringBusFactory(); URL busFile = ActionTest.class.getResource("client.xml"); Bus bus = bf.createBus(busFile.toString()); BusFactory.setDefaultBus(bus); BusFactory.setThreadDefaultBus(bus); URL wsdl = ActionTest.class.getResource("DoubleItAction.wsdl"); Service service = Service.create(wsdl, SERVICE_QNAME); QName portQName = new QName(NAMESPACE, "DoubleItSignedSAMLPort"); DoubleItPortType port = service.getPort(portQName, DoubleItPortType.class); updateAddressPort(port, PORT); assertEquals(50, port.doubleIt(25)); ((java.io.Closeable)port).close(); bus.shutdown(true); }
@Test public void testDocLitWrappedCodeFirstServiceWsdl() throws Exception { QName portName = new QName("http://cxf.apache.org/systest/jaxws/DocLitWrappedCodeFirstService", "DocLitWrappedCodeFirstServicePort"); QName servName = new QName("http://cxf.apache.org/systest/jaxws/DocLitWrappedCodeFirstService", "DocLitWrappedCodeFirstService"); Service service = Service.create(new URL(ServerMisc.DOCLIT_CODEFIRST_URL + "?wsdl"), servName); DocLitWrappedCodeFirstService port = service.getPort(portName, DocLitWrappedCodeFirstService.class); runDocLitTest(port); }
@Test public void testServerAsync() throws Exception { Service service = Service.create(serviceName); service.addPort(fakePortName, javax.xml.ws.soap.SOAPBinding.SOAP11HTTP_BINDING, "http://localhost:" + PORT + "/SoapContext/AsyncSoapPort"); Greeter greeter = service.getPort(fakePortName, Greeter.class); String resp = greeter.greetMe("World"); assertEquals("Hello World", resp); }
@Override public Object call() throws Exception { Service service = Service.create( url, new QName( NAMESPACE_URI, serviceName ) ); T port = service.getPort( clazz ); // add TRUST_USER if necessary if ( StringUtils.isNotBlank( System.getProperty( "pentaho.repository.client.attemptTrust" ) ) ) { ( (BindingProvider) port ).getRequestContext().put( MessageContext.HTTP_REQUEST_HEADERS, Collections.singletonMap( TRUST_USER, Collections.singletonList( username ) ) ); } else { // http basic authentication ( (BindingProvider) port ).getRequestContext().put( BindingProvider.USERNAME_PROPERTY, username ); ( (BindingProvider) port ).getRequestContext().put( BindingProvider.PASSWORD_PROPERTY, password ); } // accept cookies to maintain session on server ( (BindingProvider) port ).getRequestContext().put( BindingProvider.SESSION_MAINTAIN_PROPERTY, true ); // support streaming binary data // TODO mlowery this is not portable between JAX-WS implementations (uses com.sun) ( (BindingProvider) port ).getRequestContext().put( JAXWSProperties.HTTP_CLIENT_STREAMING_CHUNK_SIZE, 8192 ); SOAPBinding binding = (SOAPBinding) ( (BindingProvider) port ).getBinding(); binding.setMTOMEnabled( true ); return port; } } );
@org.junit.Test public void testTransformFeature() throws Exception { SpringBusFactory bf = new SpringBusFactory(); URL busFile = StaxTransformFeatureTest.class.getResource("client.xml"); Bus bus = bf.createBus(busFile.toString()); BusFactory.setDefaultBus(bus); BusFactory.setThreadDefaultBus(bus); URL wsdl = StaxTransformFeatureTest.class.getResource("DoubleItTransform.wsdl"); Service service = Service.create(wsdl, SERVICE_QNAME); QName portQName = new QName(NAMESPACE, "DoubleItPlaintextPort2"); DoubleItPortType2 port = service.getPort(portQName, DoubleItPortType2.class); updateAddressPort(port, PORT); assertEquals(50, port.doubleIt2(25)); ((java.io.Closeable)port).close(); bus.shutdown(true); }
@Test public void testRpcLitWsdl() throws Exception { QName portName = new QName("http://cxf.apache.org/systest/jaxws/RpcLitCodeFirstService", "RpcLitCodeFirstServicePort"); QName servName = new QName("http://cxf.apache.org/systest/jaxws/RpcLitCodeFirstService", "RpcLitCodeFirstService"); Service service = Service.create(new URL(ServerMisc.RPCLIT_CODEFIRST_URL + "?wsdl"), servName); RpcLitCodeFirstService port = service.getPort(portName, RpcLitCodeFirstService.class); runRpcLitTest(port); }
@Test public void testClientOutTransformation() { Service service = Service.create(SERVICE_NAME); String endpoint = "http://localhost:" + PORT + "/EchoContext/EchoPort"; service.addPort(PORT_NAME, SOAPBinding.SOAP11HTTP_BINDING, endpoint); Echo port = service.getPort(PORT_NAME, Echo.class); Client client = ClientProxy.getClient(port); XSLTOutInterceptor outInterceptor = new XSLTOutInterceptor(XSLT_REQUEST_PATH); client.getOutInterceptors().add(outInterceptor); String response = port.echo("test"); assertTrue("Request was not transformed", response.contains(TRANSFORMED_CONSTANT)); }
Service service; try { service = Service.create( new URL( url ), new QName( "http://www.pentaho.org/ws/1.0", "unifiedRepository" ) ); //$NON-NLS-1$ //$NON-NLS-2$ if ( service != null ) { IUnifiedRepositoryJaxwsWebService repoWebService = service.getPort( IUnifiedRepositoryJaxwsWebService.class ); if ( repoWebService != null ) { messageBox.setTitle( BaseMessages.getString( PurRepositoryDialog.class, "Dialog.Success" ) );//$NON-NLS-1$
@org.junit.Test public void test3DESEncryptionGivenKey() throws Exception { SpringBusFactory bf = new SpringBusFactory(); URL busFile = ActionTest.class.getResource("client.xml"); Bus bus = bf.createBus(busFile.toString()); BusFactory.setDefaultBus(bus); BusFactory.setThreadDefaultBus(bus); URL wsdl = ActionTest.class.getResource("DoubleItAction.wsdl"); Service service = Service.create(wsdl, SERVICE_QNAME); QName portQName = new QName(NAMESPACE, "DoubleIt3DESEncryptionPort"); DoubleItPortType port = service.getPort(portQName, DoubleItPortType.class); updateAddressPort(port, PORT); assertEquals(50, port.doubleIt(25)); ((java.io.Closeable)port).close(); bus.shutdown(true); }
@Test public void testDocLitWrappedCodeFirstServiceNoWsdl() throws Exception { QName portName = new QName("http://cxf.apache.org/systest/jaxws/DocLitWrappedCodeFirstService", "DocLitWrappedCodeFirstServicePort"); QName servName = new QName("http://cxf.apache.org/systest/jaxws/DocLitWrappedCodeFirstService", "DocLitWrappedCodeFirstService"); Service service = Service.create(servName); service.addPort(portName, SOAPBinding.SOAP11HTTP_BINDING, ServerMisc.DOCLIT_CODEFIRST_URL); DocLitWrappedCodeFirstService port = service.getPort(portName, DocLitWrappedCodeFirstService.class); runDocLitTest(port); }
@org.junit.Test public void testBasicAuth() throws Exception { SpringBusFactory bf = new SpringBusFactory(); URL busFile = BasicAuthTest.class.getResource("client.xml"); Bus bus = bf.createBus(busFile.toString()); BusFactory.setDefaultBus(bus); BusFactory.setThreadDefaultBus(bus); URL wsdl = BasicAuthTest.class.getResource("DoubleItBasicAuth.wsdl"); Service service = Service.create(wsdl, SERVICE_QNAME); QName portQName = new QName(NAMESPACE, "DoubleItBasicAuthPort"); DoubleItPortType utPort = service.getPort(portQName, DoubleItPortType.class); updateAddressPort(utPort, PORT); assertEquals(50, utPort.doubleIt(25)); ((java.io.Closeable)utPort).close(); bus.shutdown(true); }
@Test public void testHelloSoap() throws Exception { final QName serviceName = new QName("http://hello.com", "HelloWorld"); final QName portName = new QName("http://hello.com", "HelloWorldPort"); final String address = "http://localhost:" + PORT + "/bp/services/hello-soap"; Service service = Service.create(serviceName); service.addPort(portName, SOAPBinding.SOAP11HTTP_BINDING, address); HelloWorld hw = service.getPort(HelloWorld.class); useHelloService(hw); } private void useHelloService(HelloWorld service) {
@org.junit.Test public void testAsymmetricEncryptBeforeSigningActionToPolicy() throws Exception { SpringBusFactory bf = new SpringBusFactory(); URL busFile = ActionTest.class.getResource("client.xml"); Bus bus = bf.createBus(busFile.toString()); BusFactory.setDefaultBus(bus); BusFactory.setThreadDefaultBus(bus); URL wsdl = ActionTest.class.getResource("DoubleItAction.wsdl"); Service service = Service.create(wsdl, SERVICE_QNAME); QName portQName = new QName(NAMESPACE, "DoubleItAsymmetricEncryptBeforeSigningPort"); DoubleItPortType port = service.getPort(portQName, DoubleItPortType.class); updateAddressPort(port, PORT); // Successful call assertEquals(50, port.doubleIt(25)); ((java.io.Closeable)port).close(); bus.shutdown(true); }
@Test public void testHelloSoap() throws Exception { final QName serviceName = new QName("http://hello.com", "HelloWorld"); final QName portName = new QName("http://hello.com", "HelloWorldPort"); final String address = "http://localhost:" + PORT + "/test/services/hello-soap"; Service service = Service.create(serviceName); service.addPort(portName, SOAPBinding.SOAP11HTTP_BINDING, address); HelloWorld hw = service.getPort(HelloWorld.class); useHelloService(hw); }
@org.junit.Test public void testEncryption() throws Exception { SpringBusFactory bf = new SpringBusFactory(); URL busFile = ActionTest.class.getResource("client.xml"); Bus bus = bf.createBus(busFile.toString()); BusFactory.setDefaultBus(bus); BusFactory.setThreadDefaultBus(bus); URL wsdl = ActionTest.class.getResource("DoubleItAction.wsdl"); Service service = Service.create(wsdl, SERVICE_QNAME); QName portQName = new QName(NAMESPACE, "DoubleItEncryptionPort"); DoubleItPortType port = service.getPort(portQName, DoubleItPortType.class); updateAddressPort(port, PORT); // Successful call assertEquals(50, port.doubleIt(25)); ((java.io.Closeable)port).close(); bus.shutdown(true); }
@Test public void testRpcLitNoWsdl() throws Exception { QName portName = new QName("http://cxf.apache.org/systest/jaxws/RpcLitCodeFirstService", "RpcLitCodimlpementor6eFirstServicePort"); QName servName = new QName("http://cxf.apache.org/systest/jaxws/RpcLitCodeFirstService", "RpcLitCodeFirstService"); Service service = Service.create(servName); service.addPort(portName, SOAPBinding.SOAP11HTTP_BINDING, ServerMisc.RPCLIT_CODEFIRST_URL); RpcLitCodeFirstService port = service.getPort(portName, RpcLitCodeFirstService.class); runRpcLitTest(port); }