use of org.apache.cxf.jaxws.JaxWsServerFactoryBean in project cxf by apache.
the class MtomServerTest method testMtomRequest.
@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=\"<soap.xml@xfire.codehaus.org>\"; " + "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());
}
}
use of org.apache.cxf.jaxws.JaxWsServerFactoryBean in project cxf by apache.
the class TestUtils method createTeacherResourceEndpoint.
private static Server createTeacherResourceEndpoint(ResourceRemote resource, String port) {
JaxWsServerFactoryBean factory = new JaxWsServerFactoryBean();
factory.setServiceClass(Resource.class);
factory.setServiceBean(resource);
factory.setAddress("http://localhost:" + port + "/ResourceTeachers");
return factory.create();
}
use of org.apache.cxf.jaxws.JaxWsServerFactoryBean in project cxf by apache.
the class TestUtils method createTeachersResourceFactoryEndpoint.
private static Server createTeachersResourceFactoryEndpoint(ResourceRemote resource, String port) {
JaxWsServerFactoryBean factory = new JaxWsServerFactoryBean();
factory.setServiceClass(ResourceFactory.class);
factory.setServiceBean(resource);
factory.setAddress("http://localhost:" + port + "/ResourceTeachers" + TransferConstants.RESOURCE_REMOTE_SUFFIX);
return factory.create();
}
use of org.apache.cxf.jaxws.JaxWsServerFactoryBean in project cxf by apache.
the class JavaFirstNoWsdlTest method startServer.
@BeforeClass
public static void startServer() {
startBusAndJMS(JavaFirstNoWsdlTest.class);
JaxWsServerFactoryBean svrFactory = new JaxWsServerFactoryBean();
svrFactory.setBus(bus);
svrFactory.getFeatures().add(cff);
svrFactory.setServiceClass(Hello.class);
svrFactory.setAddress(SERVICE_ADDRESS);
svrFactory.setTransportId(JMSSpecConstants.SOAP_JMS_SPECIFICATION_TRANSPORTID);
svrFactory.setServiceBean(new HelloImpl());
svrFactory.create();
}
use of org.apache.cxf.jaxws.JaxWsServerFactoryBean in project cxf by apache.
the class Cxf1332Test method tryToSendStringArray.
@Test
public void tryToSendStringArray() throws Exception {
JaxWsServerFactoryBean server = getBean(JaxWsServerFactoryBean.class, "ServiceFactory");
server.create();
Cxf1332 client = getBean(Cxf1332.class, "client");
String[] a = new String[] { "a", "b", "c" };
client.hostSendData(a);
assertArrayEquals(a, Cxf1332Impl.getLastStrings());
}
Aggregations