Java Code Examples for org.apache.cxf.jaxws.JaxWsServerFactoryBean#setProperties()
The following examples show how to use
org.apache.cxf.jaxws.JaxWsServerFactoryBean#setProperties() .
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: JavaFirstSchemaValidationTest.java From cxf with Apache License 2.0 | 6 votes |
public static Server createServer(String port, Class<?> serviceInterface, Object serviceImpl, SchemaValidationType type, Feature ... features) throws IOException { JaxWsServerFactoryBean svrFactory = new JaxWsServerFactoryBean(); svrFactory.setServiceClass(serviceImpl.getClass()); if (features != null) { Collections.addAll(svrFactory.getFeatures(), features); } if (type != null) { Map<String, Object> properties = new HashMap<>(); properties.put(Message.SCHEMA_VALIDATION_ENABLED, type); svrFactory.setProperties(properties); } svrFactory.setAddress(getAddress(port, serviceInterface)); svrFactory.setServiceBean(serviceImpl); Server server = svrFactory.create(); serverList.add(server); return server; }
Example 2
Source File: IntegrationBaseTest.java From cxf with Apache License 2.0 | 6 votes |
protected Server createRemoteResource(ResourceManager manager) { ResourceRemote implementor = new ResourceRemote(); implementor.setManager(manager); JaxWsServerFactoryBean factory = new JaxWsServerFactoryBean(); Map<String, Object> props = factory.getProperties(true); props.put("jaxb.additionalContextClasses", org.apache.cxf.ws.transfer.dialect.fragment.ExpressionType.class); factory.setProperties(props); factory.setBus(bus); factory.setServiceClass(ResourceFactory.class); factory.setAddress(RESOURCE_REMOTE_MANAGER_ADDRESS); factory.setServiceBean(implementor); return factory.create(); }
Example 3
Source File: IntegrationBaseTest.java From cxf with Apache License 2.0 | 6 votes |
protected Server createLocalResource(ResourceManager manager) { ResourceLocal implementor = new ResourceLocal(); implementor.setManager(manager); JaxWsServerFactoryBean factory = new JaxWsServerFactoryBean(); Map<String, Object> props = factory.getProperties(true); props.put("jaxb.additionalContextClasses", org.apache.cxf.ws.transfer.dialect.fragment.ExpressionType.class); factory.setProperties(props); factory.setBus(bus); factory.setServiceClass(Resource.class); factory.setAddress(RESOURCE_LOCAL_ADDRESS); factory.setServiceBean(implementor); return factory.create(); }
Example 4
Source File: Server12.java From cxf with Apache License 2.0 | 5 votes |
protected void run() { Object implementor = new GreeterImpl12(); String address = "http://localhost:" + PORT + "/SoapContext/SoapPort"; // enable the options of stack trace and the exception cause message Map<String, Object> properties = new HashMap<>(); properties.put("exceptionMessageCauseEnabled", "true"); properties.put("faultStackTraceEnabled", "true"); JaxWsServerFactoryBean factory = new JaxWsServerFactoryBean(); factory.setAddress(address); factory.setServiceBean(implementor); factory.setProperties(properties); factory.create(); }
Example 5
Source File: Server11.java From cxf with Apache License 2.0 | 5 votes |
protected void run() { Object implementor = new GreeterImpl11(); String address = "http://localhost:" + PORT + "/SoapContext/GreeterPort"; // enable the options of stack trace and the exception cause message Map<String, Object> properties = new HashMap<>(); properties.put("exceptionMessageCauseEnabled", "true"); properties.put("faultStackTraceEnabled", "true"); JaxWsServerFactoryBean factory = new JaxWsServerFactoryBean(); factory.setAddress(address); factory.setServiceBean(implementor); factory.setProperties(properties); factory.create(); }
Example 6
Source File: MtomServerTest.java From cxf with Apache License 2.0 | 4 votes |
@Test public void testMtomRequest() throws Exception { JaxWsServerFactoryBean sf = new JaxWsServerFactoryBean(); sf.setServiceBean(new EchoService()); sf.setBus(getStaticBus()); String address = "http://localhost:" + PORT1 + "/EchoService"; sf.setAddress(address); Map<String, Object> props = new HashMap<>(); props.put(Message.MTOM_ENABLED, "true"); sf.setProperties(props); sf.create(); EndpointInfo ei = new EndpointInfo(null, HTTP_ID); ei.setAddress(address); ConduitInitiatorManager conduitMgr = getStaticBus().getExtension(ConduitInitiatorManager.class); ConduitInitiator conduitInit = conduitMgr.getConduitInitiator("http://schemas.xmlsoap.org/soap/http"); Conduit conduit = conduitInit.getConduit(ei, getStaticBus()); TestUtilities.TestMessageObserver obs = new TestUtilities.TestMessageObserver(); conduit.setMessageObserver(obs); Message m = new MessageImpl(); String ct = "multipart/related; type=\"application/xop+xml\"; " + "start=\"<[email protected]>\"; " + "start-info=\"text/xml\"; " + "boundary=\"----=_Part_4_701508.1145579811786\""; m.put(Message.CONTENT_TYPE, ct); conduit.prepare(m); OutputStream os = m.getContent(OutputStream.class); InputStream is = testUtilities.getResourceAsStream("request"); if (is == null) { throw new RuntimeException("Could not find resource " + "request"); } IOUtils.copy(is, os); os.flush(); is.close(); os.close(); byte[] res = obs.getResponseStream().toByteArray(); MessageImpl resMsg = new MessageImpl(); resMsg.setContent(InputStream.class, new ByteArrayInputStream(res)); resMsg.put(Message.CONTENT_TYPE, obs.getResponseContentType()); resMsg.setExchange(new ExchangeImpl()); AttachmentDeserializer deserializer = new AttachmentDeserializer(resMsg); deserializer.initializeAttachments(); Collection<Attachment> attachments = resMsg.getAttachments(); assertNotNull(attachments); assertEquals(1, attachments.size()); Attachment inAtt = attachments.iterator().next(); try (ByteArrayOutputStream out = new ByteArrayOutputStream()) { IOUtils.copy(inAtt.getDataHandler().getInputStream(), out); assertEquals(27364, out.size()); } }
Example 7
Source File: MtomServerTest.java From cxf with Apache License 2.0 | 4 votes |
@Test public void testURLBasedAttachment() throws Exception { JaxWsServerFactoryBean sf = new JaxWsServerFactoryBean(); sf.setServiceBean(new EchoService()); sf.setBus(getStaticBus()); String address = "http://localhost:" + PORT2 + "/EchoService"; sf.setAddress(address); Map<String, Object> props = new HashMap<>(); props.put(Message.MTOM_ENABLED, "true"); sf.setProperties(props); Server server = sf.create(); server.getEndpoint().getService().getDataBinding().setMtomThreshold(0); servStatic(getClass().getResource("mtom-policy.xml"), "http://localhost:" + PORT2 + "/policy.xsd"); EndpointInfo ei = new EndpointInfo(null, HTTP_ID); ei.setAddress(address); ConduitInitiatorManager conduitMgr = getStaticBus().getExtension(ConduitInitiatorManager.class); ConduitInitiator conduitInit = conduitMgr.getConduitInitiator("http://schemas.xmlsoap.org/soap/http"); Conduit conduit = conduitInit.getConduit(ei, getStaticBus()); TestUtilities.TestMessageObserver obs = new TestUtilities.TestMessageObserver(); conduit.setMessageObserver(obs); Message m = new MessageImpl(); String ct = "multipart/related; type=\"application/xop+xml\"; " + "start=\"<[email protected]>\"; " + "start-info=\"text/xml; charset=utf-8\"; " + "boundary=\"----=_Part_4_701508.1145579811786\""; m.put(Message.CONTENT_TYPE, ct); conduit.prepare(m); OutputStream os = m.getContent(OutputStream.class); InputStream is = testUtilities.getResourceAsStream("request-url-attachment"); if (is == null) { throw new RuntimeException("Could not find resource " + "request"); } try (ByteArrayOutputStream bout = new ByteArrayOutputStream()) { IOUtils.copy(is, bout); String s = bout.toString(StandardCharsets.UTF_8.name()); s = s.replaceAll(":9036/", ":" + PORT2 + "/"); os.write(s.getBytes(StandardCharsets.UTF_8)); } os.flush(); is.close(); os.close(); byte[] res = obs.getResponseStream().toByteArray(); MessageImpl resMsg = new MessageImpl(); resMsg.setContent(InputStream.class, new ByteArrayInputStream(res)); resMsg.put(Message.CONTENT_TYPE, obs.getResponseContentType()); resMsg.setExchange(new ExchangeImpl()); AttachmentDeserializer deserializer = new AttachmentDeserializer(resMsg); deserializer.initializeAttachments(); Collection<Attachment> attachments = resMsg.getAttachments(); assertNotNull(attachments); assertEquals(1, attachments.size()); Attachment inAtt = attachments.iterator().next(); try (ByteArrayOutputStream out = new ByteArrayOutputStream()) { IOUtils.copy(inAtt.getDataHandler().getInputStream(), out); assertTrue("Wrong size: " + out.size() + "\n" + out.toString(), out.size() > 970 && out.size() < 1020); } unregisterServStatic("http://localhost:" + PORT2 + "/policy.xsd"); }
Example 8
Source File: ActionTest.java From cxf with Apache License 2.0 | 4 votes |
@org.junit.Test public void testAsymmetricActionToPolicyServerFactory() throws Exception { JaxWsServerFactoryBean svrFactory = new JaxWsServerFactoryBean(); URL serviceWSDL = ActionTest.class.getResource("DoubleItActionPolicy.wsdl"); svrFactory.setWsdlLocation(serviceWSDL.toString()); String address = "http://localhost:" + PORT2 + "/DoubleItAsymmetric"; svrFactory.setAddress(address); svrFactory.setServiceBean(new DoubleItImpl()); QName portQName = new QName(NAMESPACE, "DoubleItAsymmetricPort"); svrFactory.setEndpointName(portQName); Map<String, Object> props = new HashMap<>(); props.put("security.callback-handler", "org.apache.cxf.systest.ws.common.KeystorePasswordCallback"); props.put("security.signature.properties", "bob.properties"); props.put("security.encryption.properties", "alice.properties"); props.put("security.encryption.username", "alice"); svrFactory.setProperties(props); org.apache.cxf.endpoint.Server server = svrFactory.create(); 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); DoubleItPortType port = service.getPort(portQName, DoubleItPortType.class); updateAddressPort(port, PORT2); // Successful call assertEquals(50, port.doubleIt(25)); ((java.io.Closeable)port).close(); server.destroy(); bus.shutdown(true); }