javax.xml.ws.Service Java Examples
The following examples show how to use
javax.xml.ws.Service.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WSSCUnitTest.java From cxf with Apache License 2.0 | 6 votes |
@Test public void testEndorsingSecureConverationSP12() throws Exception { SpringBusFactory bf = new SpringBusFactory(); URL busFile = WSSCUnitTest.class.getResource("client.xml"); Bus bus = bf.createBus(busFile.toString()); BusFactory.setDefaultBus(bus); BusFactory.setThreadDefaultBus(bus); URL wsdl = WSSCUnitTest.class.getResource("DoubleItWSSC.wsdl"); Service service = Service.create(wsdl, SERVICE_QNAME); QName portQName = new QName(NAMESPACE, "DoubleItTransportSP12Port"); DoubleItPortType port = service.getPort(portQName, DoubleItPortType.class); updateAddressPort(port, test.getPort()); if (test.isStreaming()) { SecurityTestUtil.enableStreaming(port); } assertEquals(50, port.doubleIt(25)); ((java.io.Closeable)port).close(); }
Example #2
Source File: WSServiceDelegate.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
protected Dispatch<Object> createDispatch(QName portName, WSEndpointReference wsepr, JAXBContext jaxbContext, Service.Mode mode, WebServiceFeatureList features) { PortInfo port = safeGetPort(portName); ComponentFeature cf = features.get(ComponentFeature.class); if (cf != null && !Target.STUB.equals(cf.getTarget())) { throw new IllegalArgumentException(); } ComponentsFeature csf = features.get(ComponentsFeature.class); if (csf != null) { for (ComponentFeature cfi : csf.getComponentFeatures()) { if (!Target.STUB.equals(cfi.getTarget())) throw new IllegalArgumentException(); } } features.addAll(this.features); BindingImpl binding = port.createBinding(features, null, null); binding.setMode(mode); Dispatch<Object> dispatch = Stubs.createJAXBDispatch( port, binding, jaxbContext, mode,wsepr); serviceInterceptor.postCreateDispatch((WSBindingProvider)dispatch); return dispatch; }
Example #3
Source File: SecondClient.java From cxf with Apache License 2.0 | 6 votes |
public static SecondServiceAT newInstance() throws Exception { URL wsdlLocation = new URL("http://localhost:8082/Service/SecondServiceAT?wsdl"); QName serviceName = new QName("http://service.ws.sample", "SecondServiceATService"); QName portName = new QName("http://service.ws.sample", "SecondServiceAT"); Service service = Service.create(wsdlLocation, serviceName); SecondServiceAT client = service.getPort(portName, SecondServiceAT.class); List<Handler> handlerChain = new ArrayList<>(); JaxWSTxOutboundBridgeHandler txOutboundBridgeHandler = new JaxWSTxOutboundBridgeHandler(); EnabledWSTXHandler wstxHandler = new EnabledWSTXHandler(); handlerChain.add(txOutboundBridgeHandler); handlerChain.add(wstxHandler); ((BindingProvider)client).getBinding().setHandlerChain(handlerChain); return client; }
Example #4
Source File: X509TokenTest.java From cxf with Apache License 2.0 | 6 votes |
@org.junit.Test public void testAsymmetricSignatureSP11() throws Exception { SpringBusFactory bf = new SpringBusFactory(); URL busFile = X509TokenTest.class.getResource("client.xml"); Bus bus = bf.createBus(busFile.toString()); BusFactory.setDefaultBus(bus); BusFactory.setThreadDefaultBus(bus); URL wsdl = X509TokenTest.class.getResource("DoubleItX509Signature.wsdl"); Service service = Service.create(wsdl, SERVICE_QNAME); QName portQName = new QName(NAMESPACE, "DoubleItAsymmetricSignatureSP11Port"); DoubleItPortType x509Port = service.getPort(portQName, DoubleItPortType.class); updateAddressPort(x509Port, test.getPort()); if (test.isStreaming()) { SecurityTestUtil.enableStreaming(x509Port); } assertEquals(50, x509Port.doubleIt(25)); ((java.io.Closeable)x509Port).close(); bus.shutdown(true); }
Example #5
Source File: STSClientTest.java From cxf with Apache License 2.0 | 6 votes |
@org.junit.Test public void testDefaultSTSClient() throws Exception { SpringBusFactory bf = new SpringBusFactory(); URL busFile = STSClientTest.class.getResource("cxf-default-client.xml"); Bus bus = bf.createBus(busFile.toString()); BusFactory.setDefaultBus(bus); BusFactory.setThreadDefaultBus(bus); URL wsdl = STSClientTest.class.getResource("DoubleIt.wsdl"); Service service = Service.create(wsdl, SERVICE_QNAME); QName portQName = new QName(NAMESPACE, "DoubleItTransportSAML1Port"); DoubleItPortType transportSaml1Port = service.getPort(portQName, DoubleItPortType.class); updateAddressPort(transportSaml1Port, PORT); doubleIt(transportSaml1Port, 25); ((java.io.Closeable)transportSaml1Port).close(); bus.shutdown(true); }
Example #6
Source File: StaxTransformFeatureTest.java From cxf with Apache License 2.0 | 6 votes |
@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); }
Example #7
Source File: Invoker.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
/** * Creates a classloader for loading JAXB/WS 2.2 jar and tools.jar */ private static URL[] findIstack22APIs(ClassLoader cl) throws ClassNotFoundException, IOException, ToolsJarNotFoundException { List<URL> urls = new ArrayList<URL>(); if(Service.class.getClassLoader()==null) { // JAX-WS API is loaded from bootstrap classloader URL res = cl.getResource("javax/xml/ws/EndpointContext.class"); if(res==null) throw new ClassNotFoundException("There's no JAX-WS 2.2 API in the classpath"); urls.add(ParallelWorldClassLoader.toJarUrl(res)); res = cl.getResource("javax/xml/bind/JAXBPermission.class"); if(res==null) throw new ClassNotFoundException("There's no JAXB 2.2 API in the classpath"); urls.add(ParallelWorldClassLoader.toJarUrl(res)); } findToolsJar(cl, urls); return urls.toArray(new URL[urls.size()]); }
Example #8
Source File: X509TokenTest.java From cxf with Apache License 2.0 | 6 votes |
@org.junit.Test public void testAsymmetricEncryption() throws Exception { SpringBusFactory bf = new SpringBusFactory(); URL busFile = X509TokenTest.class.getResource("client.xml"); Bus bus = bf.createBus(busFile.toString()); BusFactory.setDefaultBus(bus); BusFactory.setThreadDefaultBus(bus); URL wsdl = X509TokenTest.class.getResource("DoubleItX509Signature.wsdl"); Service service = Service.create(wsdl, SERVICE_QNAME); QName portQName = new QName(NAMESPACE, "DoubleItAsymmetricEncryptionPort"); DoubleItPortType x509Port = service.getPort(portQName, DoubleItPortType.class); updateAddressPort(x509Port, test.getPort()); if (test.isStreaming()) { SecurityTestUtil.enableStreaming(x509Port); } assertEquals(50, x509Port.doubleIt(25)); ((java.io.Closeable)x509Port).close(); bus.shutdown(true); }
Example #9
Source File: Invoker.java From mwsc with MIT License | 6 votes |
/** * Creates a classloader for loading JAXB/WS 2.1 jar and tools.jar */ private static URL[] findIstackAPIs(ClassLoader cl) throws ClassNotFoundException, MalformedURLException, ToolsJarNotFoundException { List<URL> urls = new ArrayList<URL>(); if(Service.class.getClassLoader()==null) { // JAX-WS API is loaded from bootstrap classloader URL res = cl.getResource("javax/xml/ws/EndpointReference.class"); if(res==null) throw new ClassNotFoundException("There's no JAX-WS 2.1 API in the classpath"); urls.add(ParallelWorldClassLoader.toJarUrl(res)); res = cl.getResource("javax/xml/bind/annotation/XmlSeeAlso.class"); if(res==null) throw new ClassNotFoundException("There's no JAXB 2.1 API in the classpath"); urls.add(ParallelWorldClassLoader.toJarUrl(res)); } findToolsJar(cl, urls); return urls.toArray(new URL[urls.size()]); }
Example #10
Source File: Invoker.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
/** * Creates a classloader for loading JAXB/WS 2.2 jar and tools.jar */ private static URL[] findIstack22APIs(ClassLoader cl) throws ClassNotFoundException, IOException, ToolsJarNotFoundException { List<URL> urls = new ArrayList<URL>(); if(Service.class.getClassLoader()==null) { // JAX-WS API is loaded from bootstrap classloader URL res = cl.getResource("javax/xml/ws/EndpointContext.class"); if(res==null) throw new ClassNotFoundException("There's no JAX-WS 2.2 API in the classpath"); urls.add(ParallelWorldClassLoader.toJarUrl(res)); res = cl.getResource("javax/xml/bind/JAXBPermission.class"); if(res==null) throw new ClassNotFoundException("There's no JAXB 2.2 API in the classpath"); urls.add(ParallelWorldClassLoader.toJarUrl(res)); } findToolsJar(cl, urls); return urls.toArray(new URL[urls.size()]); }
Example #11
Source File: WSServiceDelegate.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
public <T> Dispatch<T> createDispatch(QName portName, WSEndpointReference wsepr, Class<T> aClass, Service.Mode mode, WebServiceFeatureList features) { PortInfo port = safeGetPort(portName); ComponentFeature cf = features.get(ComponentFeature.class); if (cf != null && !Target.STUB.equals(cf.getTarget())) { throw new IllegalArgumentException(); } ComponentsFeature csf = features.get(ComponentsFeature.class); if (csf != null) { for (ComponentFeature cfi : csf.getComponentFeatures()) { if (!Target.STUB.equals(cfi.getTarget())) throw new IllegalArgumentException(); } } features.addAll(this.features); BindingImpl binding = port.createBinding(features, null, null); binding.setMode(mode); Dispatch<T> dispatch = Stubs.createDispatch(port, this, binding, aClass, mode, wsepr); serviceInterceptor.postCreateDispatch((WSBindingProvider) dispatch); return dispatch; }
Example #12
Source File: X509TokenTest.java From cxf with Apache License 2.0 | 6 votes |
@org.junit.Test public void testAsymmetricSHA512() throws Exception { SpringBusFactory bf = new SpringBusFactory(); URL busFile = X509TokenTest.class.getResource("client.xml"); Bus bus = bf.createBus(busFile.toString()); BusFactory.setDefaultBus(bus); BusFactory.setThreadDefaultBus(bus); URL wsdl = X509TokenTest.class.getResource("DoubleItX509.wsdl"); Service service = Service.create(wsdl, SERVICE_QNAME); QName portQName = new QName(NAMESPACE, "DoubleItAsymmetricSHA512Port"); DoubleItPortType x509Port = service.getPort(portQName, DoubleItPortType.class); updateAddressPort(x509Port, test.getPort()); if (test.isStreaming()) { SecurityTestUtil.enableStreaming(x509Port); } assertEquals(50, x509Port.doubleIt(25)); ((java.io.Closeable)x509Port).close(); bus.shutdown(true); }
Example #13
Source File: HTTPGetTest.java From cxf with Apache License 2.0 | 6 votes |
@org.junit.Test public void testSOAPClientSecurityPolicy() throws Exception { if (!TestUtilities.checkUnrestrictedPoliciesInstalled()) { return; } SpringBusFactory bf = new SpringBusFactory(); URL busFile = HTTPGetTest.class.getResource("client.xml"); Bus bus = bf.createBus(busFile.toString()); BusFactory.setDefaultBus(bus); BusFactory.setThreadDefaultBus(bus); URL wsdl = HTTPGetTest.class.getResource("DoubleItHTTPGet.wsdl"); Service service = Service.create(wsdl, SERVICE_QNAME); QName portQName = new QName(NAMESPACE, "DoubleItKeyIdentifierPort"); DoubleItPortType x509Port = service.getPort(portQName, DoubleItPortType.class); updateAddressPort(x509Port, PORT); int result = x509Port.doubleIt(25); assertEquals(result, 50); bus.shutdown(true); }
Example #14
Source File: DispatchTest.java From cxf with Apache License 2.0 | 6 votes |
@Test public void testSOAPPBindingNullMessage() throws Exception { d.setMessageObserver(new MessageReplayObserver("/org/apache/cxf/jaxws/sayHiResponse.xml")); URL wsdl = getClass().getResource("/wsdl/hello_world.wsdl"); assertNotNull(wsdl); SOAPService service = new SOAPService(wsdl, SERVICE_NAME); assertNotNull(service); JAXBContext jc = JAXBContext.newInstance("org.apache.hello_world_soap_http.types"); Dispatch<Object> disp = service.createDispatch(PORT_NAME, jc, Service.Mode.PAYLOAD); try { // Send a null message disp.invoke(null); } catch (SOAPFaultException e) { //Passed return; } fail("SOAPFaultException was not thrown"); }
Example #15
Source File: WSServiceDelegate.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
protected Dispatch<Object> createDispatch(QName portName, JAXBContext jaxbContext, Service.Mode mode, WebServiceFeatureList features) { WSEndpointReference wsepr = null; boolean isAddressingEnabled = false; AddressingFeature af = features.get(AddressingFeature.class); if (af == null) { af = this.features.get(AddressingFeature.class); } if (af != null && af.isEnabled()) isAddressingEnabled = true; MemberSubmissionAddressingFeature msa = features.get(MemberSubmissionAddressingFeature.class); if (msa == null) { msa = this.features.get(MemberSubmissionAddressingFeature.class); } if (msa != null && msa.isEnabled()) isAddressingEnabled = true; if(isAddressingEnabled && wsdlService != null && wsdlService.get(portName) != null) { wsepr = wsdlService.get(portName).getEPR(); } return createDispatch(portName, wsepr, jaxbContext, mode, features); }
Example #16
Source File: ClaimsTest.java From cxf with Apache License 2.0 | 6 votes |
@org.junit.Test public void testSaml2ChildClaims() throws Exception { SpringBusFactory bf = new SpringBusFactory(); URL busFile = ClaimsTest.class.getResource("cxf-client.xml"); Bus bus = bf.createBus(busFile.toString()); BusFactory.setDefaultBus(bus); BusFactory.setThreadDefaultBus(bus); URL wsdl = ClaimsTest.class.getResource("DoubleIt.wsdl"); Service service = Service.create(wsdl, SERVICE_QNAME); QName portQName = new QName(NAMESPACE, "DoubleItTransportSAML2ChildClaimsPort"); DoubleItPortType transportClaimsPort = service.getPort(portQName, DoubleItPortType.class); updateAddressPort(transportClaimsPort, PORT); doubleIt(transportClaimsPort, 25); ((java.io.Closeable)transportClaimsPort).close(); bus.shutdown(true); }
Example #17
Source File: XMLProviderArgumentBuilder.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
static XMLProviderArgumentBuilder createBuilder(ProviderEndpointModel model, WSBinding binding) { if (model.mode == Service.Mode.PAYLOAD) { return new PayloadSource(); } else { if(model.datatype==Source.class) return new PayloadSource(); if(model.datatype== DataSource.class) return new DataSourceParameter(binding); throw new WebServiceException(ServerMessages.PROVIDER_INVALID_PARAMETER_TYPE(model.implClass,model.datatype)); } }
Example #18
Source File: TransportBindingTest.java From cxf with Apache License 2.0 | 5 votes |
@org.junit.Test public void testSAML2SymmetricEndorsingDerived() throws Exception { // Only works for DOM (clients) if (test.isStreaming()) { return; } SpringBusFactory bf = new SpringBusFactory(); URL busFile = TransportBindingTest.class.getResource("cxf-client.xml"); Bus bus = bf.createBus(busFile.toString()); BusFactory.setDefaultBus(bus); BusFactory.setThreadDefaultBus(bus); URL wsdl = TransportBindingTest.class.getResource("DoubleIt.wsdl"); Service service = Service.create(wsdl, SERVICE_QNAME); QName portQName = new QName(NAMESPACE, "DoubleItTransportSAML2SymmetricEndorsingDerivedPort"); DoubleItPortType transportSaml1Port = service.getPort(portQName, DoubleItPortType.class); updateAddressPort(transportSaml1Port, test.getPort()); TokenTestUtils.updateSTSPort((BindingProvider)transportSaml1Port, test.getStsPort()); if (test.isStreaming()) { SecurityTestUtil.enableStreaming(transportSaml1Port); } doubleIt(transportSaml1Port, 25); ((java.io.Closeable)transportSaml1Port).close(); bus.shutdown(true); }
Example #19
Source File: SequenceTimeoutTest.java From cxf with Apache License 2.0 | 5 votes |
private Dispatch<DOMSource> initDispatch() { GreeterService gs = new GreeterService(); Dispatch<DOMSource> dispatch = gs.createDispatch(GreeterService.GreeterPort, DOMSource.class, Service.Mode.MESSAGE); try { updateAddressPort(dispatch, PORT); } catch (Exception e) { //ignore } dispatch.getRequestContext().put(BindingProvider.SOAPACTION_USE_PROPERTY, Boolean.FALSE); dispatch.getRequestContext().put(MessageContext.WSDL_OPERATION, GREETME_NAME); return dispatch; }
Example #20
Source File: TemplateTest.java From cxf with Apache License 2.0 | 5 votes |
@org.junit.Test public void testSAML1PublicKey() throws Exception { SpringBusFactory bf = new SpringBusFactory(); URL busFile = TemplateTest.class.getResource("cxf-client.xml"); Bus bus = bf.createBus(busFile.toString()); BusFactory.setDefaultBus(bus); BusFactory.setThreadDefaultBus(bus); URL wsdl = TemplateTest.class.getResource("DoubleIt.wsdl"); Service service = Service.create(wsdl, SERVICE_QNAME); QName portQName = new QName(NAMESPACE, "DoubleItTransportSAML1PublicKeyPort"); DoubleItPortType port = service.getPort(portQName, DoubleItPortType.class); updateAddressPort(port, test.getPort()); // Setup STSClient STSClient stsClient = createSTSClient(bus); String wsdlLocation = "https://localhost:" + test.getStsPort() + "/SecurityTokenService/Transport?wsdl"; stsClient.setWsdlLocation(wsdlLocation); ((BindingProvider)port).getRequestContext().put( SecurityConstants.STS_CLIENT, stsClient ); if (test.isStreaming()) { SecurityTestUtil.enableStreaming(port); } doubleIt(port, 25); ((java.io.Closeable)port).close(); bus.shutdown(true); }
Example #21
Source File: JaxwsBasicAuthTest.java From cxf with Apache License 2.0 | 5 votes |
@org.junit.Test public void testBadBasicAuth() throws Exception { SpringBusFactory bf = new SpringBusFactory(); URL busFile = JaxwsBasicAuthTest.class.getResource("cxf-bad-client.xml"); Bus bus = bf.createBus(busFile.toString()); BusFactory.setDefaultBus(bus); BusFactory.setThreadDefaultBus(bus); URL wsdl = JaxwsBasicAuthTest.class.getResource("DoubleIt.wsdl"); Service service = Service.create(wsdl, SERVICE_QNAME); QName portQName = new QName(NAMESPACE, "DoubleItPort"); DoubleItPortType port = service.getPort(portQName, DoubleItPortType.class); updateAddressPort(port, test.getPort()); if (test.isStreaming()) { SecurityTestUtil.enableStreaming(port); } try { doubleIt(port, 30); fail("Expected failure on a bad password"); } catch (javax.xml.ws.soap.SOAPFaultException fault) { String message = fault.getMessage(); assertTrue(message.contains("STS Authentication failed") || message.contains("Validation of security token failed")); } ((java.io.Closeable)port).close(); bus.shutdown(true); }
Example #22
Source File: CalculatorTest.java From tomee with Apache License 2.0 | 5 votes |
public void testCalculatorViaWsInterfaceWithSign() throws Exception { final Service calcService = Service.create(new URL("http://localhost:" + port + "/webservice-ws-security/CalculatorImplSign?wsdl"), new QName("http://superbiz.org/wsdl", "CalculatorWsService")); assertNotNull(calcService); // for debugging (ie. TCPMon) calcService.addPort(new QName("http://superbiz.org/wsdl", "CalculatorWsService2"), SOAPBinding.SOAP12HTTP_BINDING, "http://127.0.0.1:8204/CalculatorImplSign"); // CalculatorWs calc = calcService.getPort( // new QName("http://superbiz.org/wsdl", "CalculatorWsService2"), // CalculatorWs.class); final CalculatorWs calc = calcService.getPort(CalculatorWs.class); final Client client = ClientProxy.getClient(calc); final Endpoint endpoint = client.getEndpoint(); endpoint.getOutInterceptors().add(new SAAJOutInterceptor()); final Map<String, Object> outProps = new HashMap<String, Object>(); outProps.put(WSHandlerConstants.ACTION, WSHandlerConstants.SIGNATURE); outProps.put(WSHandlerConstants.USER, "clientalias"); outProps.put(WSHandlerConstants.PW_CALLBACK_REF, new CallbackHandler() { @Override public void handle(final Callback[] callbacks) throws IOException, UnsupportedCallbackException { final WSPasswordCallback pc = (WSPasswordCallback) callbacks[0]; pc.setPassword("clientPassword"); } }); outProps.put(WSHandlerConstants.SIG_PROP_FILE, "META-INF/CalculatorImplSign-client.properties"); outProps.put(WSHandlerConstants.SIG_KEY_ID, "IssuerSerial"); final WSS4JOutInterceptor wssOut = new WSS4JOutInterceptor(outProps); endpoint.getOutInterceptors().add(wssOut); assertEquals(24, calc.multiply(4, 6)); }
Example #23
Source File: FaultTest.java From cxf with Apache License 2.0 | 5 votes |
@org.junit.Test public void testUnsecuredSoap11Action() throws Exception { SpringBusFactory bf = new SpringBusFactory(); URL busFile = FaultTest.class.getResource("client.xml"); Bus bus = bf.createBus(busFile.toString()); BusFactory.setDefaultBus(bus); BusFactory.setThreadDefaultBus(bus); URL wsdl = FaultTest.class.getResource("DoubleItFault.wsdl"); Service service = Service.create(wsdl, SERVICE_QNAME); QName portQName = new QName(NAMESPACE, "DoubleItSoap11UnsecuredPort"); DoubleItPortType utPort = service.getPort(portQName, DoubleItPortType.class); updateAddressPort(utPort, PORT); try { utPort.doubleIt(25); fail("Expected failure on bob"); } catch (Exception ex) { assertTrue(ex.getMessage().contains("This is a fault")); } ((java.io.Closeable)utPort).close(); bus.shutdown(true); }
Example #24
Source File: Test.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) throws IOException, TransformerException { try { String address = deployWebservice(); Service service = Service.create(new URL(address), ServiceImpl.SERVICE_NAME); Dispatch<Source> d = service.createDispatch(ServiceImpl.PORT_NAME, Source.class, Service.Mode.MESSAGE); Source response = d.invoke(new StreamSource(new StringReader(XML_REQUEST))); String resultXml = toString(response); log("= request ======== \n"); log(XML_REQUEST); log("= result ========= \n"); log(resultXml); log("\n=================="); boolean xsAnyMixedPartSame = resultXml.contains(XS_ANY_MIXED_PART); log("resultXml.contains(XS_ANY_PART) = " + xsAnyMixedPartSame); if (!xsAnyMixedPartSame) { fail("The xs:any content=mixed part is supposed to be same in request and response."); throw new RuntimeException(); } log("TEST PASSED"); } finally { stopWebservice(); // if you need to debug or explore wsdl generation result // comment this line out: deleteGeneratedFiles(); } }
Example #25
Source File: SamlTokenTest.java From cxf with Apache License 2.0 | 5 votes |
@org.junit.Test public void testSaml2OverSymmetricSupporting() throws Exception { SpringBusFactory bf = new SpringBusFactory(); URL busFile = SamlTokenTest.class.getResource("client.xml"); Bus bus = bf.createBus(busFile.toString()); BusFactory.setDefaultBus(bus); BusFactory.setThreadDefaultBus(bus); URL wsdl = SamlTokenTest.class.getResource("DoubleItSaml.wsdl"); Service service = Service.create(wsdl, SERVICE_QNAME); QName portQName = new QName(NAMESPACE, "DoubleItSaml2SymmetricSupportingPort"); DoubleItPortType saml2Port = service.getPort(portQName, DoubleItPortType.class); updateAddressPort(saml2Port, test.getPort()); if (test.isStreaming()) { SecurityTestUtil.enableStreaming(saml2Port); } ((BindingProvider)saml2Port).getRequestContext().put( SecurityConstants.SAML_CALLBACK_HANDLER, new SamlCallbackHandler() ); try { saml2Port.doubleIt(25); fail("Expected failure on an invocation with an unsigned SAML SV Assertion"); } catch (javax.xml.ws.soap.SOAPFaultException ex) { assertTrue(ex.getMessage().contains("SamlToken not satisfied") || ex.getMessage().equals(WSSecurityException.UNIFIED_SECURITY_ERR)); } ((java.io.Closeable)saml2Port).close(); bus.shutdown(true); }
Example #26
Source File: DispatchXMLClientServerTest.java From cxf with Apache License 2.0 | 5 votes |
@Test public void testStreamSourceMESSAGE() throws Exception { /*URL wsdl = getClass().getResource("/wsdl/hello_world_xml_wrapped.wsdl"); assertNotNull(wsdl); XMLService service = new XMLService(wsdl, serviceName); assertNotNull(service);*/ Service service = Service.create(SERVICE_NAME); assertNotNull(service); service.addPort(PORT_NAME, "http://cxf.apache.org/bindings/xformat", "http://localhost:" + port + "/XMLService/XMLDispatchPort"); InputStream is = getClass().getResourceAsStream("/messages/XML_GreetMeDocLiteralReq.xml"); StreamSource reqMsg = new StreamSource(is); assertNotNull(reqMsg); Dispatch<Source> disp = service.createDispatch(PORT_NAME, Source.class, Service.Mode.MESSAGE); Source source = disp.invoke(reqMsg); assertNotNull(source); String streamString = StaxUtils.toString(source); Document doc = StaxUtils.read(new StringReader(streamString)); assertEquals("greetMeResponse", doc.getFirstChild().getLocalName()); assertEquals("Hello tli", doc.getFirstChild().getTextContent()); }
Example #27
Source File: XmlWebServiceRef.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
@Override @SuppressWarnings("unchecked") public Class<? extends Service> value() { if (value == null) { return Service.class; } return (Class<Service>) findClass(value); }
Example #28
Source File: X509TokenTest.java From cxf with Apache License 2.0 | 5 votes |
@org.junit.Test public void testTransportSignedEndorsing() throws Exception { SpringBusFactory bf = new SpringBusFactory(); URL busFile = X509TokenTest.class.getResource("client.xml"); Bus bus = bf.createBus(busFile.toString()); BusFactory.setDefaultBus(bus); BusFactory.setThreadDefaultBus(bus); URL wsdl = X509TokenTest.class.getResource("DoubleItX509.wsdl"); Service service = Service.create(wsdl, SERVICE_QNAME); QName portQName = new QName(NAMESPACE, "DoubleItTransportSignedEndorsingPort"); DoubleItPortType x509Port = service.getPort(portQName, DoubleItPortType.class); String port = PORT2; if (STAX_PORT.equals(test.getPort())) { port = STAX_PORT2; } updateAddressPort(x509Port, port); if (test.isStreaming()) { SecurityTestUtil.enableStreaming(x509Port); } assertEquals(50, x509Port.doubleIt(25)); ((java.io.Closeable)x509Port).close(); bus.shutdown(true); }
Example #29
Source File: PartsTest.java From cxf with Apache License 2.0 | 5 votes |
@org.junit.Test public void testSOAPFaultError() throws Exception { SpringBusFactory bf = new SpringBusFactory(); URL busFile = PartsTest.class.getResource("client.xml"); Bus bus = bf.createBus(busFile.toString()); BusFactory.setDefaultBus(bus); BusFactory.setThreadDefaultBus(bus); URL wsdl = PartsTest.class.getResource("DoubleItParts.wsdl"); Service service = Service.create(wsdl, SERVICE_QNAME); // This should fail, as the service requires a (bad) header QName portQName = new QName(NAMESPACE, "DoubleItRequiredPartsPort2"); DoubleItPortType port = service.getPort(portQName, DoubleItPortType.class); updateAddressPort(port, test.getPort()); if (test.isStreaming()) { SecurityTestUtil.enableStreaming(port); } try { port.doubleIt(25); fail("Failure expected on a required header which isn't present"); } catch (javax.xml.ws.soap.SOAPFaultException ex) { String error = "RequiredParts: No header element"; assertTrue(ex.getMessage().contains(error) || ex.getMessage().contains("ToTo must be present")); } ((java.io.Closeable)port).close(); bus.shutdown(true); }
Example #30
Source File: GCMTest.java From cxf with Apache License 2.0 | 5 votes |
@org.junit.Test public void testAESGCM256MGFSHA256() throws Exception { if (!unrestrictedPoliciesInstalled) { return; } SpringBusFactory bf = new SpringBusFactory(); URL busFile = GCMTest.class.getResource("mgf-client.xml"); Bus bus = bf.createBus(busFile.toString()); BusFactory.setDefaultBus(bus); BusFactory.setThreadDefaultBus(bus); URL wsdl = GCMTest.class.getResource("DoubleItGCM.wsdl"); Service service = Service.create(wsdl, SERVICE_QNAME); QName portQName = new QName(NAMESPACE, "DoubleItGCM256MGFSHA256Port"); DoubleItPortType gcmPort = service.getPort(portQName, DoubleItPortType.class); String port = MGF_PORT; if (STAX_PORT.equals(test.getPort())) { port = MGF_STAX_PORT; } updateAddressPort(gcmPort, port); if (test.isStreaming()) { SecurityTestUtil.enableStreaming(gcmPort); } assertEquals(50, gcmPort.doubleIt(25)); ((java.io.Closeable)gcmPort).close(); bus.shutdown(true); }