Java Code Examples for org.apache.cxf.service.model.OperationInfo#setInput()

The following examples show how to use org.apache.cxf.service.model.OperationInfo#setInput() . 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 vote down vote up
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: STSUtils.java    From steady with Apache License 2.0 6 votes vote down vote up
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 3
Source File: STSUtils.java    From steady with Apache License 2.0 6 votes vote down vote up
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 4
Source File: STSUtils.java    From steady with Apache License 2.0 6 votes vote down vote up
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 5
Source File: STSUtils.java    From steady with Apache License 2.0 6 votes vote down vote up
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 6
Source File: STSUtils.java    From steady with Apache License 2.0 6 votes vote down vote up
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 7
Source File: STSUtils.java    From steady with Apache License 2.0 6 votes vote down vote up
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 8
Source File: STSUtils.java    From cxf with Apache License 2.0 6 votes vote down vote up
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 9
Source File: STSUtils.java    From cxf with Apache License 2.0 6 votes vote down vote up
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 10
Source File: JaxWsServiceConfigurationTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
@Test
public void testGetInPartName() throws Exception {
    QName opName = new QName("http://cxf.com/", "sayHello");
    Method sayHelloMethod = Hello.class.getMethod("sayHello", new Class[]{String.class, String.class});
    ServiceInfo si = getMockedServiceModel("/wsdl/default_partname_test.wsdl");
    JaxWsServiceFactoryBean bean = new JaxWsServiceFactoryBean();
    bean.setServiceClass(Hello.class);
    JaxWsServiceConfiguration jwsc = (JaxWsServiceConfiguration) bean.getServiceConfigurations().get(0);
    jwsc.setServiceFactory(bean);

    OperationInfo op = si.getInterface().getOperation(opName);
    op.setInput("input", new MessageInfo(op, MessageInfo.Type.INPUT,
                                         new QName("http://cxf.com/", "input")));
    op.setOutput("output", new MessageInfo(op, MessageInfo.Type.OUTPUT,
                                           new QName("http://cxf.com/", "output")));

    QName partName = jwsc.getInPartName(op, sayHelloMethod, 0);
    assertEquals("get wrong in partName for first param", new QName("http://cxf.com/", "arg0"), partName);

    op.getInput().addMessagePart(new QName("arg0"));

    partName = jwsc.getInPartName(op, sayHelloMethod, 1);
    assertEquals("get wrong in partName for first param", new QName("http://cxf.com/", "arg1"), partName);
}
 
Example 11
Source File: JAXRSServiceImpl.java    From cxf with Apache License 2.0 6 votes vote down vote up
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 12
Source File: STSUtils.java    From cxf with Apache License 2.0 6 votes vote down vote up
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: RMEndpoint.java    From cxf with Apache License 2.0 5 votes vote down vote up
void buildSequenceAckOperationInfo(InterfaceInfo ii, ProtocolVariation protocol) {

        OperationInfo operationInfo = null;
        MessageInfo messageInfo = null;

        RMConstants consts = protocol.getConstants();
        operationInfo = ii.addOperation(consts.getSequenceAckOperationName());
        messageInfo = operationInfo.createMessage(consts.getSequenceAckOperationName(),
                                                  MessageInfo.Type.INPUT);
        operationInfo.setInput(messageInfo.getName().getLocalPart(), messageInfo);
    }
 
Example 14
Source File: RMEndpoint.java    From cxf with Apache License 2.0 5 votes vote down vote up
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 15
Source File: SoapPreProtocolOutInterceptorTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
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);
}
 
Example 16
Source File: MethodMapperTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
@Test
public void testMapOneWayOperation() throws Exception {
    OperationInfo operation = getOperation();

    MessageInfo inputMessage = operation.createMessage(new QName("urn:test:ns", "testInputMessage"),
                                                       MessageInfo.Type.INPUT);
    operation.setInput("input", inputMessage);

    JavaMethod method = new MethodMapper().map(operation);
    assertNotNull(method);
    assertTrue(method.isOneWay());
}
 
Example 17
Source File: RMEndpoint.java    From cxf with Apache License 2.0 5 votes vote down vote up
void buildAckRequestedOperationInfo(InterfaceInfo ii, ProtocolVariation protocol) {

        OperationInfo operationInfo = null;
        MessageInfo messageInfo = null;

        RMConstants consts = protocol.getConstants();
        operationInfo = ii.addOperation(consts.getAckRequestedOperationName());
        messageInfo = operationInfo.createMessage(consts.getAckRequestedOperationName(),
                                                  MessageInfo.Type.INPUT);
        operationInfo.setInput(messageInfo.getName().getLocalPart(), messageInfo);
    }
 
Example 18
Source File: DocLiteralInInterceptorTest.java    From cxf with Apache License 2.0 4 votes vote down vote up
@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()));

}
 
Example 19
Source File: DocLiteralInInterceptorTest.java    From cxf with Apache License 2.0 4 votes vote down vote up
@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 20
Source File: RMEndpoint.java    From cxf with Apache License 2.0 4 votes vote down vote up
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());
    }