use of org.apache.hello_world_soap_http.types.GreetMe in project cxf by apache.
the class BareInInterceptorTest method setUpUsingHelloWorld.
private void setUpUsingHelloWorld() throws Exception {
String ns = "http://apache.org/hello_world_soap_http";
WSDLServiceFactory factory = new WSDLServiceFactory(bus, getClass().getResource("/wsdl/jaxb/hello_world.wsdl").toString(), new QName(ns, "SOAPService"));
service = factory.create();
endpointInfo = service.getServiceInfos().get(0).getEndpoint(new QName(ns, "SoapPort"));
endpoint = new EndpointImpl(bus, service, endpointInfo);
JAXBDataBinding db = new JAXBDataBinding();
db.setContext(JAXBContext.newInstance(new Class[] { GreetMe.class, GreetMeResponse.class }));
service.setDataBinding(db);
operation = endpointInfo.getBinding().getOperation(new QName(ns, "greetMe"));
operation.getOperationInfo().getInput().getMessagePartByIndex(0).setTypeClass(GreetMe.class);
operation.getOperationInfo().getOutput().getMessagePartByIndex(0).setTypeClass(GreetMeResponse.class);
message = new MessageImpl();
Exchange exchange = new ExchangeImpl();
message.setExchange(exchange);
exchange.put(Service.class, service);
exchange.put(Endpoint.class, endpoint);
exchange.put(Binding.class, endpoint.getBinding());
}
use of org.apache.hello_world_soap_http.types.GreetMe in project cxf by apache.
the class JAXBEncoderDecoderTest method testMarshallIntoStaxEventWriter.
@Test
public void testMarshallIntoStaxEventWriter() throws Exception {
GreetMe obj = new GreetMe();
obj.setRequestType("Hello");
QName elName = new QName(wrapperAnnotation.targetNamespace(), wrapperAnnotation.localName());
MessagePartInfo part = new MessagePartInfo(elName, null);
part.setElement(true);
part.setElementQName(elName);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
XMLOutputFactory opFactory = XMLOutputFactory.newInstance();
opFactory.setProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES, Boolean.TRUE);
FixNamespacesXMLEventWriter writer = new FixNamespacesXMLEventWriter(opFactory.createXMLEventWriter(baos));
assertNull(writer.getMarshaller());
// STARTDOCUMENT/ENDDOCUMENT is not required
// writer.add(eFactory.createStartDocument("utf-8", "1.0"));
Marshaller m = context.createMarshaller();
JAXBEncoderDecoder.marshall(m, obj, part, writer);
assertEquals(m, writer.getMarshaller());
// writer.add(eFactory.createEndDocument());
writer.flush();
writer.close();
// System.out.println(baos.toString());
ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
XMLInputFactory ipFactory = XMLInputFactory.newInstance();
XMLEventReader reader = ipFactory.createXMLEventReader(bais);
Unmarshaller um = context.createUnmarshaller();
Object val = um.unmarshal(reader, GreetMe.class);
assertTrue(val instanceof JAXBElement);
val = ((JAXBElement<?>) val).getValue();
assertTrue(val instanceof GreetMe);
assertEquals(obj.getRequestType(), ((GreetMe) val).getRequestType());
}
use of org.apache.hello_world_soap_http.types.GreetMe in project cxf by apache.
the class JAXBEncoderDecoderTest method testMarshallWithoutQNameInfo.
@Test
public void testMarshallWithoutQNameInfo() throws Exception {
GreetMe obj = new GreetMe();
obj.setRequestType("Hello");
ByteArrayOutputStream baos = new ByteArrayOutputStream();
XMLOutputFactory opFactory = XMLOutputFactory.newInstance();
opFactory.setProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES, Boolean.TRUE);
XMLEventWriter writer = opFactory.createXMLEventWriter(baos);
// STARTDOCUMENT/ENDDOCUMENT is not required
// writer.add(eFactory.createStartDocument("utf-8", "1.0"));
JAXBEncoderDecoder.marshall(context.createMarshaller(), obj, null, writer);
// writer.add(eFactory.createEndDocument());
writer.flush();
writer.close();
// System.out.println(baos.toString());
ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
XMLInputFactory ipFactory = XMLInputFactory.newInstance();
XMLEventReader reader = ipFactory.createXMLEventReader(bais);
Unmarshaller um = context.createUnmarshaller();
Object val = um.unmarshal(reader, GreetMe.class);
assertTrue(val instanceof JAXBElement);
val = ((JAXBElement<?>) val).getValue();
assertTrue(val instanceof GreetMe);
assertEquals(obj.getRequestType(), ((GreetMe) val).getRequestType());
}
use of org.apache.hello_world_soap_http.types.GreetMe in project cxf by apache.
the class DocLiteralInInterceptorTest method setUpUsingHelloWorld.
private void setUpUsingHelloWorld() throws Exception {
String ns = "http://apache.org/hello_world_soap_http";
WSDLServiceFactory factory = new WSDLServiceFactory(bus, getClass().getResource("/wsdl/jaxb/hello_world.wsdl").toString(), new QName(ns, "SOAPService"));
service = factory.create();
endpointInfo = service.getEndpointInfo(new QName(ns, "SoapPort"));
endpoint = new EndpointImpl(bus, service, endpointInfo);
JAXBDataBinding db = new JAXBDataBinding();
db.setContext(JAXBContext.newInstance(new Class[] { GreetMe.class, GreetMeResponse.class }));
service.setDataBinding(db);
operation = endpointInfo.getBinding().getOperation(new QName(ns, "greetMe"));
operation.getOperationInfo().getInput().getMessagePartByIndex(0).setTypeClass(GreetMe.class);
operation.getOperationInfo().getOutput().getMessagePartByIndex(0).setTypeClass(GreetMeResponse.class);
message = new MessageImpl();
Exchange exchange = new ExchangeImpl();
message.setExchange(exchange);
exchange.put(Service.class, service);
exchange.put(Endpoint.class, endpoint);
exchange.put(Binding.class, endpoint.getBinding());
}
use of org.apache.hello_world_soap_http.types.GreetMe in project cxf by apache.
the class DocLiteralInInterceptorTest method testInterceptorInboundWrapped.
@Test
public void testInterceptorInboundWrapped() throws Exception {
setUpUsingHelloWorld();
// WrappedInInterceptor interceptor = new WrappedInInterceptor();
DocLiteralInInterceptor interceptor = new DocLiteralInInterceptor();
message.setContent(XMLStreamReader.class, XMLInputFactory.newInstance().createXMLStreamReader(getTestStream(getClass(), "resources/GreetMeDocLiteralReq.xml")));
XMLStreamReader reader = message.getContent(XMLStreamReader.class);
// skip the start element of soap body
StaxUtils.skipToStartOfElement(reader);
message.put(Message.INBOUND_MESSAGE, Message.INBOUND_MESSAGE);
interceptor.handleMessage(message);
assertNull(message.getContent(Exception.class));
List<?> parameters = message.getContent(List.class);
assertEquals(1, parameters.size());
Object obj = parameters.get(0);
assertTrue(obj instanceof GreetMe);
GreetMe greet = (GreetMe) obj;
assertEquals("TestSOAPInputPMessage", greet.getRequestType());
}
Aggregations