Java Code Examples for org.apache.cxf.service.model.MessageInfo#addMessagePart()
The following examples show how to use
org.apache.cxf.service.model.MessageInfo#addMessagePart() .
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: STSUtils.java From steady with Apache License 2.0 | 6 votes |
private static OperationInfo addCancelOperation(InterfaceInfo ii, String namespace, String servNamespace) { OperationInfo oi = ii.addOperation(new QName(servNamespace, "CancelSecurityToken")); MessageInfo mii = oi.createMessage(new QName(servNamespace, "CancelSecurityTokenMsg"), MessageInfo.Type.INPUT); oi.setInput("CancelSecurityTokenMsg", mii); MessagePartInfo mpi = mii.addMessagePart("request"); mpi.setElementQName(new QName(namespace, "CancelSecurityToken")); MessageInfo mio = oi.createMessage(new QName(servNamespace, "CancelSecurityTokenResponseMsg"), MessageInfo.Type.OUTPUT); oi.setOutput("CancelSecurityTokenResponseMsg", mio); mpi = mio.addMessagePart("response"); mpi.setElementQName(new QName(namespace, "CancelSecurityTokenResponse")); return oi; }
Example 2
Source File: RMEndpoint.java From cxf with Apache License 2.0 | 6 votes |
void buildCloseSequenceOperationInfo(InterfaceInfo ii, ProtocolVariation protocol) { OperationInfo operationInfo = null; MessageInfo messageInfo = null; RMConstants consts = protocol.getConstants(); operationInfo = ii.addOperation(consts.getCloseSequenceOperationName()); messageInfo = operationInfo.createMessage(consts.getCloseSequenceOperationName(), MessageInfo.Type.INPUT); operationInfo.setInput(messageInfo.getName().getLocalPart(), messageInfo); if (RM11Constants.NAMESPACE_URI.equals(protocol.getWSRMNamespace())) { MessagePartInfo partInfo = messageInfo.addMessagePart(CLOSE_PART_NAME); partInfo.setElementQName(consts.getCloseSequenceOperationName()); partInfo.setElement(true); partInfo.setTypeClass(CloseSequenceType.class); messageInfo = operationInfo.createMessage( RM11Constants.INSTANCE.getCloseSequenceResponseOperationName(), MessageInfo.Type.OUTPUT); operationInfo.setOutput(messageInfo.getName().getLocalPart(), messageInfo); partInfo = messageInfo.addMessagePart(CLOSE_RESPONSE_PART_NAME); partInfo.setElementQName(RM11Constants.INSTANCE.getCloseSequenceResponseOperationName()); partInfo.setElement(true); partInfo.setTypeClass(CloseSequenceResponseType.class); partInfo.setIndex(0); } }
Example 3
Source File: STSUtils.java From cxf with Apache License 2.0 | 6 votes |
private static OperationInfo addRenewOperation(InterfaceInfo ii, String namespace, String servNamespace) { OperationInfo oi = ii.addOperation(new QName(servNamespace, "RenewSecurityToken")); MessageInfo mii = oi.createMessage(new QName(servNamespace, "RenewSecurityTokenMsg"), MessageInfo.Type.INPUT); oi.setInput("RenewSecurityTokenMsg", mii); MessagePartInfo mpi = mii.addMessagePart("request"); mpi.setElementQName(new QName(namespace, "RequestSecurityToken")); MessageInfo mio = oi.createMessage(new QName(servNamespace, "RenewSecurityTokenResponseMsg"), MessageInfo.Type.OUTPUT); oi.setOutput("RenewSecurityTokenResponseMsg", mio); mpi = mio.addMessagePart("response"); if (WST_NS_05_02.equals(namespace)) { mpi.setElementQName(new QName(namespace, "RequestSecurityTokenResponse")); } else { mpi.setElementQName(new QName(namespace, "RequestSecurityTokenResponseCollection")); } return oi; }
Example 4
Source File: STSUtils.java From cxf with Apache License 2.0 | 6 votes |
private static OperationInfo addCancelOperation(InterfaceInfo ii, String namespace, String servNamespace) { OperationInfo oi = ii.addOperation(new QName(servNamespace, "CancelSecurityToken")); MessageInfo mii = oi.createMessage(new QName(servNamespace, "CancelSecurityTokenMsg"), MessageInfo.Type.INPUT); oi.setInput("CancelSecurityTokenMsg", mii); MessagePartInfo mpi = mii.addMessagePart("request"); mpi.setElementQName(new QName(namespace, "RequestSecurityToken")); MessageInfo mio = oi.createMessage(new QName(servNamespace, "CancelSecurityTokenResponseMsg"), MessageInfo.Type.OUTPUT); oi.setOutput("CancelSecurityTokenResponseMsg", mio); mpi = mio.addMessagePart("response"); if (WST_NS_05_02.equals(namespace)) { mpi.setElementQName(new QName(namespace, "RequestSecurityTokenResponse")); } else { mpi.setElementQName(new QName(namespace, "RequestSecurityTokenResponseCollection")); } return oi; }
Example 5
Source File: STSUtils.java From cxf with Apache License 2.0 | 6 votes |
private static OperationInfo addIssueOperation(InterfaceInfo ii, String namespace, String servNamespace) { OperationInfo oi = ii.addOperation(new QName(servNamespace, "RequestSecurityToken")); MessageInfo mii = oi.createMessage(new QName(servNamespace, "RequestSecurityTokenMsg"), MessageInfo.Type.INPUT); oi.setInput("RequestSecurityTokenMsg", mii); MessagePartInfo mpi = mii.addMessagePart("request"); mpi.setElementQName(new QName(namespace, "RequestSecurityToken")); MessageInfo mio = oi.createMessage(new QName(servNamespace, "RequestSecurityTokenResponseMsg"), MessageInfo.Type.OUTPUT); oi.setOutput("RequestSecurityTokenResponseMsg", mio); mpi = mio.addMessagePart("response"); if (WST_NS_05_02.equals(namespace)) { mpi.setElementQName(new QName(namespace, "RequestSecurityTokenResponse")); } else { mpi.setElementQName(new QName(namespace, "RequestSecurityTokenResponseCollection")); } return oi; }
Example 6
Source File: JAXRSServiceImpl.java From cxf with Apache License 2.0 | 6 votes |
private void createMessagePartInfo(OperationInfo oi, Class<?> type, QName qname, Method m, boolean input) { if (type == void.class || Source.class.isAssignableFrom(type)) { return; } if (InjectionUtils.isPrimitive(type) || Response.class == type) { return; } QName mName = new QName(qname.getNamespaceURI(), (input ? "in" : "out") + m.getName()); MessageInfo ms = oi.createMessage(mName, input ? MessageInfo.Type.INPUT : MessageInfo.Type.OUTPUT); if (input) { oi.setInput("in", ms); } else { oi.setOutput("out", ms); } QName mpQName = JAXRSUtils.getClassQName(type); MessagePartInfo mpi = ms.addMessagePart(mpQName); mpi.setConcreteName(mpQName); mpi.setTypeQName(mpQName); mpi.setTypeClass(type); }
Example 7
Source File: STSUtils.java From steady with Apache License 2.0 | 6 votes |
private static OperationInfo addCancelOperation(InterfaceInfo ii, String namespace, String servNamespace) { OperationInfo oi = ii.addOperation(new QName(servNamespace, "CancelSecurityToken")); MessageInfo mii = oi.createMessage(new QName(servNamespace, "CancelSecurityTokenMsg"), MessageInfo.Type.INPUT); oi.setInput("CancelSecurityTokenMsg", mii); MessagePartInfo mpi = mii.addMessagePart("request"); mpi.setElementQName(new QName(namespace, "CancelSecurityToken")); MessageInfo mio = oi.createMessage(new QName(servNamespace, "CancelSecurityTokenResponseMsg"), MessageInfo.Type.OUTPUT); oi.setOutput("CancelSecurityTokenResponseMsg", mio); mpi = mio.addMessagePart("response"); mpi.setElementQName(new QName(namespace, "CancelSecurityTokenResponse")); return oi; }
Example 8
Source File: STSUtils.java From steady with Apache License 2.0 | 6 votes |
private static OperationInfo addIssueOperation(InterfaceInfo ii, String namespace, String servNamespace) { OperationInfo oi = ii.addOperation(new QName(servNamespace, "RequestSecurityToken")); MessageInfo mii = oi.createMessage(new QName(servNamespace, "RequestSecurityTokenMsg"), MessageInfo.Type.INPUT); oi.setInput("RequestSecurityTokenMsg", mii); MessagePartInfo mpi = mii.addMessagePart("request"); mpi.setElementQName(new QName(namespace, "RequestSecurityToken")); MessageInfo mio = oi.createMessage(new QName(servNamespace, "RequestSecurityTokenResponseMsg"), MessageInfo.Type.OUTPUT); oi.setOutput("RequestSecurityTokenResponseMsg", mio); mpi = mio.addMessagePart("response"); if (WST_NS_05_02.equals(namespace)) { mpi.setElementQName(new QName(namespace, "RequestSecurityTokenResponse")); } else { mpi.setElementQName(new QName(namespace, "RequestSecurityTokenResponseCollection")); } return oi; }
Example 9
Source File: STSUtils.java From steady with Apache License 2.0 | 6 votes |
private static OperationInfo addCancelOperation(InterfaceInfo ii, String namespace, String servNamespace) { OperationInfo oi = ii.addOperation(new QName(servNamespace, "CancelSecurityToken")); MessageInfo mii = oi.createMessage(new QName(servNamespace, "CancelSecurityTokenMsg"), MessageInfo.Type.INPUT); oi.setInput("CancelSecurityTokenMsg", mii); MessagePartInfo mpi = mii.addMessagePart("request"); mpi.setElementQName(new QName(namespace, "CancelSecurityToken")); MessageInfo mio = oi.createMessage(new QName(servNamespace, "CancelSecurityTokenResponseMsg"), MessageInfo.Type.OUTPUT); oi.setOutput("CancelSecurityTokenResponseMsg", mio); mpi = mio.addMessagePart("response"); mpi.setElementQName(new QName(namespace, "CancelSecurityTokenResponse")); return oi; }
Example 10
Source File: STSUtils.java From steady with Apache License 2.0 | 6 votes |
private static OperationInfo addIssueOperation(InterfaceInfo ii, String namespace, String servNamespace) { OperationInfo oi = ii.addOperation(new QName(servNamespace, "RequestSecurityToken")); MessageInfo mii = oi.createMessage(new QName(servNamespace, "RequestSecurityTokenMsg"), MessageInfo.Type.INPUT); oi.setInput("RequestSecurityTokenMsg", mii); MessagePartInfo mpi = mii.addMessagePart("request"); mpi.setElementQName(new QName(namespace, "RequestSecurityToken")); MessageInfo mio = oi.createMessage(new QName(servNamespace, "RequestSecurityTokenResponseMsg"), MessageInfo.Type.OUTPUT); oi.setOutput("RequestSecurityTokenResponseMsg", mio); mpi = mio.addMessagePart("response"); if (WST_NS_05_02.equals(namespace)) { mpi.setElementQName(new QName(namespace, "RequestSecurityTokenResponse")); } else { mpi.setElementQName(new QName(namespace, "RequestSecurityTokenResponseCollection")); } return oi; }
Example 11
Source File: STSUtils.java From steady with Apache License 2.0 | 6 votes |
private static OperationInfo addCancelOperation(InterfaceInfo ii, String namespace, String servNamespace) { OperationInfo oi = ii.addOperation(new QName(servNamespace, "CancelSecurityToken")); MessageInfo mii = oi.createMessage(new QName(servNamespace, "CancelSecurityTokenMsg"), MessageInfo.Type.INPUT); oi.setInput("CancelSecurityTokenMsg", mii); MessagePartInfo mpi = mii.addMessagePart("request"); mpi.setElementQName(new QName(namespace, "CancelSecurityToken")); MessageInfo mio = oi.createMessage(new QName(servNamespace, "CancelSecurityTokenResponseMsg"), MessageInfo.Type.OUTPUT); oi.setOutput("CancelSecurityTokenResponseMsg", mio); mpi = mio.addMessagePart("response"); mpi.setElementQName(new QName(namespace, "CancelSecurityTokenResponse")); return oi; }
Example 12
Source File: STSUtils.java From steady with Apache License 2.0 | 6 votes |
private static OperationInfo addIssueOperation(InterfaceInfo ii, String namespace, String servNamespace) { OperationInfo oi = ii.addOperation(new QName(servNamespace, "RequestSecurityToken")); MessageInfo mii = oi.createMessage(new QName(servNamespace, "RequestSecurityTokenMsg"), MessageInfo.Type.INPUT); oi.setInput("RequestSecurityTokenMsg", mii); MessagePartInfo mpi = mii.addMessagePart("request"); mpi.setElementQName(new QName(namespace, "RequestSecurityToken")); MessageInfo mio = oi.createMessage(new QName(servNamespace, "RequestSecurityTokenResponseMsg"), MessageInfo.Type.OUTPUT); oi.setOutput("RequestSecurityTokenResponseMsg", mio); mpi = mio.addMessagePart("response"); if (WST_NS_05_02.equals(namespace)) { mpi.setElementQName(new QName(namespace, "RequestSecurityTokenResponse")); } else { mpi.setElementQName(new QName(namespace, "RequestSecurityTokenResponseCollection")); } return oi; }
Example 13
Source File: STSUtils.java From steady with Apache License 2.0 | 6 votes |
private static OperationInfo addIssueOperation(InterfaceInfo ii, String namespace, String servNamespace) { OperationInfo oi = ii.addOperation(new QName(servNamespace, "RequestSecurityToken")); MessageInfo mii = oi.createMessage(new QName(servNamespace, "RequestSecurityTokenMsg"), MessageInfo.Type.INPUT); oi.setInput("RequestSecurityTokenMsg", mii); MessagePartInfo mpi = mii.addMessagePart("request"); mpi.setElementQName(new QName(namespace, "RequestSecurityToken")); MessageInfo mio = oi.createMessage(new QName(servNamespace, "RequestSecurityTokenResponseMsg"), MessageInfo.Type.OUTPUT); oi.setOutput("RequestSecurityTokenResponseMsg", mio); mpi = mio.addMessagePart("response"); if (WST_NS_05_02.equals(namespace)) { mpi.setElementQName(new QName(namespace, "RequestSecurityTokenResponse")); } else { mpi.setElementQName(new QName(namespace, "RequestSecurityTokenResponseCollection")); } return oi; }
Example 14
Source File: DispatchImpl.java From cxf with Apache License 2.0 | 5 votes |
private void addInvokeOperation(boolean oneWay) { String name = oneWay ? INVOKE_ONEWAY_NAME : INVOKE_NAME; ServiceInfo info = client.getEndpoint().getEndpointInfo().getService(); OperationInfo opInfo = info.getInterface() .addOperation(oneWay ? INVOKE_ONEWAY_QNAME : INVOKE_QNAME); MessageInfo mInfo = opInfo.createMessage(new QName(DISPATCH_NS, name + "Request"), Type.INPUT); opInfo.setInput(name + "Request", mInfo); MessagePartInfo mpi = mInfo.addMessagePart("parameters"); if (context == null) { mpi.setTypeClass(cl); } mpi.setElement(true); if (!oneWay) { mInfo = opInfo.createMessage(new QName(DISPATCH_NS, name + "Response"), Type.OUTPUT); opInfo.setOutput(name + "Response", mInfo); mpi = mInfo.addMessagePart("parameters"); mpi.setElement(true); if (context == null) { mpi.setTypeClass(cl); } } for (BindingInfo bind : client.getEndpoint().getEndpointInfo().getService().getBindings()) { BindingOperationInfo bo = new BindingOperationInfo(bind, opInfo); bind.addOperation(bo); } }
Example 15
Source File: RMEndpoint.java From cxf with Apache License 2.0 | 5 votes |
void buildTerminateSequenceOperationInfo(InterfaceInfo ii, ProtocolVariation protocol) { OperationInfo operationInfo = null; MessagePartInfo partInfo = null; MessageInfo messageInfo = null; RMConstants consts = protocol.getConstants(); operationInfo = ii.addOperation(consts.getTerminateSequenceOperationName()); messageInfo = operationInfo.createMessage(consts.getTerminateSequenceOperationName(), MessageInfo.Type.INPUT); operationInfo.setInput(messageInfo.getName().getLocalPart(), messageInfo); partInfo = messageInfo.addMessagePart(TERMINATE_PART_NAME); partInfo.setElementQName(consts.getTerminateSequenceOperationName()); partInfo.setElement(true); partInfo.setTypeClass(protocol.getCodec().getTerminateSequenceType()); if (RM11Constants.NAMESPACE_URI.equals(protocol.getWSRMNamespace())) { messageInfo = operationInfo.createMessage( RM11Constants.INSTANCE.getTerminateSequenceResponseOperationName(), MessageInfo.Type.OUTPUT); operationInfo.setOutput(messageInfo.getName().getLocalPart(), messageInfo); partInfo = messageInfo.addMessagePart(TERMINATE_RESPONSE_PART_NAME); partInfo.setElementQName(RM11Constants.INSTANCE.getTerminateSequenceResponseOperationName()); partInfo.setElement(true); partInfo.setTypeClass(protocol.getCodec().getTerminateSequenceResponseType()); partInfo.setIndex(0); } // for the TerminateSequence operation to an anonymous endpoint operationInfo = ii.addOperation(consts.getTerminateSequenceAnonymousOperationName()); messageInfo = operationInfo.createMessage(consts.getTerminateSequenceAnonymousOperationName(), MessageInfo.Type.OUTPUT); operationInfo.setOutput(messageInfo.getName().getLocalPart(), messageInfo); partInfo = messageInfo.addMessagePart(TERMINATE_PART_NAME); partInfo.setElementQName(consts.getTerminateSequenceOperationName()); partInfo.setElement(true); partInfo.setTypeClass(protocol.getCodec().getTerminateSequenceType()); }
Example 16
Source File: RMEndpoint.java From cxf with Apache License 2.0 | 4 votes |
void buildCreateSequenceOperationInfo(InterfaceInfo ii, ProtocolVariation protocol) { OperationInfo operationInfo = null; MessagePartInfo partInfo = null; MessageInfo messageInfo = null; RMConstants consts = protocol.getConstants(); operationInfo = ii.addOperation(consts.getCreateSequenceOperationName()); messageInfo = operationInfo.createMessage(consts.getCreateSequenceOperationName(), MessageInfo.Type.INPUT); operationInfo.setInput(messageInfo.getName().getLocalPart(), messageInfo); partInfo = messageInfo.addMessagePart(CREATE_PART_NAME); partInfo.setElementQName(consts.getCreateSequenceOperationName()); partInfo.setElement(true); partInfo.setTypeClass(protocol.getCodec().getCreateSequenceType()); messageInfo = operationInfo.createMessage(consts.getCreateSequenceResponseOperationName(), MessageInfo.Type.OUTPUT); operationInfo.setOutput(messageInfo.getName().getLocalPart(), messageInfo); partInfo = messageInfo.addMessagePart(CREATE_RESPONSE_PART_NAME); partInfo.setElementQName(consts.getCreateSequenceResponseOperationName()); partInfo.setElement(true); partInfo.setTypeClass(protocol.getCodec().getCreateSequenceResponseType()); partInfo.setIndex(0); operationInfo = ii.addOperation(consts.getCreateSequenceOnewayOperationName()); messageInfo = operationInfo.createMessage(consts.getCreateSequenceOnewayOperationName(), MessageInfo.Type.INPUT); operationInfo.setInput(messageInfo.getName().getLocalPart(), messageInfo); partInfo = messageInfo.addMessagePart(CREATE_PART_NAME); partInfo.setElementQName(consts.getCreateSequenceOnewayOperationName()); partInfo.setElement(true); partInfo.setTypeClass(protocol.getCodec().getCreateSequenceType()); operationInfo = ii.addOperation(consts.getCreateSequenceResponseOnewayOperationName()); messageInfo = operationInfo.createMessage(consts.getCreateSequenceResponseOnewayOperationName(), MessageInfo.Type.INPUT); operationInfo.setInput(messageInfo.getName().getLocalPart(), messageInfo); partInfo = messageInfo.addMessagePart(CREATE_RESPONSE_PART_NAME); partInfo.setElementQName(consts.getCreateSequenceResponseOnewayOperationName()); partInfo.setElement(true); partInfo.setTypeClass(protocol.getCodec().getCreateSequenceResponseType()); }
Example 17
Source File: DocLiteralInInterceptorTest.java From cxf with Apache License 2.0 | 4 votes |
@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()); }
Example 18
Source File: DocLiteralInInterceptorTest.java From cxf with Apache License 2.0 | 4 votes |
@Test public void testUnmarshalSourceDataWrapped() throws Exception { XMLStreamReader reader = StaxUtils.createXMLStreamReader(getClass() .getResourceAsStream("resources/docLitWrappedReq.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(); // request to keep the document as wrapped m.put(DocLiteralInInterceptor.KEEP_PARAMETERS_WRAPPER, true); Exchange exchange = new ExchangeImpl(); Service service = control.createMock(Service.class); exchange.put(Service.class, service); EasyMock.expect(service.getDataBinding()).andReturn(new SourceDataBinding()).anyTimes(); 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); // wrapped OperationInfo operationInfo = new OperationInfo(); MessageInfo messageInfo = new MessageInfo(operationInfo, Type.INPUT, new QName(NS, "foo")); messageInfo.addMessagePart(new MessagePartInfo(new QName(NS, "personId"), null)); messageInfo.addMessagePart(new MessagePartInfo(new QName(NS, "ssn"), null)); messageInfo.getMessagePart(0).setConcreteName(new QName(NS, "personId")); messageInfo.getMessagePart(1).setConcreteName(new QName(NS, "ssn")); operationInfo.setInput("inputName", messageInfo); // wrapper OperationInfo operationInfoWrapper = new OperationInfo(); MessageInfo messageInfoWrapper = new MessageInfo(operationInfo, Type.INPUT, new QName(NS, "foo")); messageInfoWrapper.addMessagePart(new MessagePartInfo(new QName(NS, "GetPerson"), null)); messageInfoWrapper.getMessagePart(0).setConcreteName(new QName(NS, "GetPerson")); operationInfoWrapper.setInput("inputName", messageInfoWrapper); operationInfoWrapper.setUnwrappedOperation(operationInfo); ServiceInfo serviceInfo = control.createMock(ServiceInfo.class); 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(); BindingInfo bindingInfo = new BindingInfo(serviceInfo, ""); BindingOperationInfo boi = new BindingOperationInfo(bindingInfo, operationInfoWrapper); 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(); EasyMock.expect(endpointInfo.getService()).andReturn(serviceInfo).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); // we expect a wrapped document assertEquals(1, params.size()); Map<String, String> ns = new HashMap<>(); ns.put("ns", NS); XPathUtils xu = new XPathUtils(ns); assertEquals("hello", xu.getValueString("//ns:GetPerson/ns:personId", ((DOMSource)params.get(0)).getNode().getFirstChild())); assertEquals("1234", xu.getValueString("//ns:GetPerson/ns:ssn", ((DOMSource)params.get(0)).getNode().getFirstChild())); }