use of org.apache.cxf.service.model.InterfaceInfo in project cxf by apache.
the class SoapActionInterceptorTest method createBindingOperation.
private BindingOperationInfo createBindingOperation() {
ServiceInfo s = new ServiceInfo();
InterfaceInfo ii = s.createInterface(new QName("FooInterface"));
s.setInterface(ii);
ii.addOperation(new QName("fooOp"));
BindingInfo b = new BindingInfo(s, "foo");
return b.buildOperation(new QName("fooOp"), null, null);
}
use of org.apache.cxf.service.model.InterfaceInfo in project cxf by apache.
the class SoapPreProtocolOutInterceptorTest method setUpBindingOperationInfo.
private BindingOperationInfo setUpBindingOperationInfo(String nsuri, String opreq, String opresp, Method method) {
ServiceInfo si = new ServiceInfo();
InterfaceInfo iinf = new InterfaceInfo(si, new QName(nsuri, method.getDeclaringClass().getSimpleName()));
OperationInfo opInfo = iinf.addOperation(new QName(nsuri, method.getName()));
opInfo.setProperty(Method.class.getName(), method);
opInfo.setInput(opreq, opInfo.createMessage(new QName(nsuri, opreq), Type.INPUT));
opInfo.setOutput(opresp, opInfo.createMessage(new QName(nsuri, opresp), Type.INPUT));
return new BindingOperationInfo(null, opInfo);
}
use of org.apache.cxf.service.model.InterfaceInfo in project cxf by apache.
the class JAXBEncoderDecoderTest method testMarshallExceptionWithOrder.
@Test
public void testMarshallExceptionWithOrder() throws Exception {
Document doc = DOMUtils.getEmptyDocument();
Element elNode = doc.createElementNS("http://cxf.apache.org", "ExceptionRoot");
OrderException exception = new OrderException("Mymessage");
exception.setAValue("avalue");
exception.setDetail("detail");
exception.setInfo1("info1");
exception.setInfo2("info2");
exception.setIntVal(10000);
QName elName = new QName("http://cxf.apache.org", "OrderException");
ServiceInfo serviceInfo = new ServiceInfo();
InterfaceInfo interfaceInfo = new InterfaceInfo(serviceInfo, null);
OperationInfo op = interfaceInfo.addOperation(new QName("http://cxf.apache.org", "operation"));
MessageInfo message = new MessageInfo(op, null, null);
MessagePartInfo part = new MessagePartInfo(elName, message);
part.setElement(true);
part.setElementQName(elName);
part.setTypeClass(OrderException.class);
// just need a simple generic context to handle the exceptions internal primitives
JAXBContext exceptionContext = JAXBContext.newInstance(new Class[] { String.class });
JAXBEncoderDecoder.marshallException(exceptionContext.createMarshaller(), exception, part, elNode);
ByteArrayOutputStream bout = new ByteArrayOutputStream();
StaxUtils.writeTo(elNode, bout);
int a = bout.toString().lastIndexOf("aValue");
int b = bout.toString().lastIndexOf("detail");
int c = bout.toString().lastIndexOf("info1");
int d = bout.toString().lastIndexOf("info2");
int e = bout.toString().lastIndexOf("intVal");
assertTrue(a < b);
assertTrue(b < c);
assertTrue(c < d);
assertTrue(d < e);
assertTrue(bout.toString().indexOf("transientValue") < 0);
assertTrue(bout.toString(), bout.toString().indexOf("mappedField=\"MappedField\"") > 0);
}
use of org.apache.cxf.service.model.InterfaceInfo in project cxf by apache.
the class DefaultLogEventMapper method setServiceInfo.
private void setServiceInfo(ServiceInfo service, LogEvent event) {
event.setServiceName(service.getName());
InterfaceInfo iface = service.getInterface();
event.setPortTypeName(iface.getName());
}
use of org.apache.cxf.service.model.InterfaceInfo in project cxf by apache.
the class DocLiteralInInterceptorTest method testUnmarshalSourceData.
@Test
public void testUnmarshalSourceData() throws Exception {
XMLStreamReader reader = StaxUtils.createXMLStreamReader(getClass().getResourceAsStream("resources/multiPartDocLitBareReq.xml"));
assertEquals(XMLStreamConstants.START_ELEMENT, reader.nextTag());
XMLStreamReader filteredReader = new PartialXMLStreamReader(reader, new QName("http://schemas.xmlsoap.org/soap/envelope/", "Body"));
// advance the xml reader to the message parts
StaxUtils.read(filteredReader);
assertEquals(XMLStreamConstants.START_ELEMENT, reader.nextTag());
Message m = new MessageImpl();
Exchange exchange = new ExchangeImpl();
Service service = control.createMock(Service.class);
exchange.put(Service.class, service);
EasyMock.expect(service.getDataBinding()).andReturn(new SourceDataBinding());
EasyMock.expect(service.size()).andReturn(0).anyTimes();
EasyMock.expect(service.isEmpty()).andReturn(true).anyTimes();
Endpoint endpoint = control.createMock(Endpoint.class);
exchange.put(Endpoint.class, endpoint);
OperationInfo operationInfo = new OperationInfo();
operationInfo.setProperty("operation.is.synthetic", Boolean.TRUE);
MessageInfo messageInfo = new MessageInfo(operationInfo, Type.INPUT, new QName("http://foo.com", "bar"));
messageInfo.addMessagePart(new MessagePartInfo(new QName("http://foo.com", "partInfo1"), null));
messageInfo.addMessagePart(new MessagePartInfo(new QName("http://foo.com", "partInfo2"), null));
messageInfo.addMessagePart(new MessagePartInfo(new QName("http://foo.com", "partInfo3"), null));
messageInfo.addMessagePart(new MessagePartInfo(new QName("http://foo.com", "partInfo4"), null));
for (MessagePartInfo mpi : messageInfo.getMessageParts()) {
mpi.setMessageContainer(messageInfo);
}
operationInfo.setInput("inputName", messageInfo);
BindingOperationInfo boi = new BindingOperationInfo(null, operationInfo);
exchange.put(BindingOperationInfo.class, boi);
EndpointInfo endpointInfo = control.createMock(EndpointInfo.class);
BindingInfo binding = control.createMock(BindingInfo.class);
EasyMock.expect(endpoint.getEndpointInfo()).andReturn(endpointInfo).anyTimes();
EasyMock.expect(endpointInfo.getBinding()).andReturn(binding).anyTimes();
EasyMock.expect(binding.getProperties()).andReturn(new HashMap<String, Object>()).anyTimes();
EasyMock.expect(endpointInfo.getProperties()).andReturn(new HashMap<String, Object>()).anyTimes();
EasyMock.expect(endpoint.size()).andReturn(0).anyTimes();
EasyMock.expect(endpoint.isEmpty()).andReturn(true).anyTimes();
ServiceInfo serviceInfo = control.createMock(ServiceInfo.class);
EasyMock.expect(endpointInfo.getService()).andReturn(serviceInfo).anyTimes();
EasyMock.expect(serviceInfo.getName()).andReturn(new QName("http://foo.com", "service")).anyTimes();
InterfaceInfo interfaceInfo = control.createMock(InterfaceInfo.class);
EasyMock.expect(serviceInfo.getInterface()).andReturn(interfaceInfo).anyTimes();
EasyMock.expect(interfaceInfo.getName()).andReturn(new QName("http://foo.com", "interface")).anyTimes();
EasyMock.expect(endpointInfo.getName()).andReturn(new QName("http://foo.com", "endpoint")).anyTimes();
EasyMock.expect(endpointInfo.getProperty("URI", URI.class)).andReturn(new URI("dummy")).anyTimes();
List<OperationInfo> operations = new ArrayList<>();
EasyMock.expect(interfaceInfo.getOperations()).andReturn(operations).anyTimes();
m.setExchange(exchange);
m.put(Message.SCHEMA_VALIDATION_ENABLED, false);
m.setContent(XMLStreamReader.class, reader);
control.replay();
new DocLiteralInInterceptor().handleMessage(m);
MessageContentsList params = (MessageContentsList) m.getContent(List.class);
assertEquals(4, params.size());
assertEquals("StringDefaultInputElem", ((DOMSource) params.get(0)).getNode().getFirstChild().getNodeName());
assertEquals("IntParamInElem", ((DOMSource) params.get(1)).getNode().getFirstChild().getNodeName());
}
Aggregations