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

The following examples show how to use org.apache.cxf.service.model.OperationInfo#getUnwrappedOperation() . 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: RequestWrapperTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
private OperationInfo getOperation(Class<?> clz, String opName) {
    builder.setServiceClass(clz);
    ServiceInfo serviceInfo = builder.createService();

    for (OperationInfo op : serviceInfo.getInterface().getOperations()) {
        if (op.getUnwrappedOperation() != null
            && op.hasInput() && opName.equals(op.getName().getLocalPart())) {
            return op;
        }
    }
    return null;
}
 
Example 2
Source File: ResponseWrapperTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
private OperationInfo getOperation(Class<?> clz, String opName) {
    builder.setServiceClass(clz);
    ServiceInfo serviceInfo = builder.createService();

    for (OperationInfo op : serviceInfo.getInterface().getOperations()) {
        if (op.getUnwrappedOperation() != null
            && op.hasInput() && opName.equals(op.getName().getLocalPart())) {
            return op;
        }
    }
    return null;
}
 
Example 3
Source File: JaxWsServiceFactoryBean.java    From cxf with Apache License 2.0 5 votes vote down vote up
@Override
protected OperationInfo createOperation(ServiceInfo serviceInfo, InterfaceInfo intf, Method m) {
    OperationInfo op = super.createOperation(serviceInfo, intf, m);
    if (op.getUnwrappedOperation() != null) {
        op = op.getUnwrappedOperation();
    }
    buildWSAActions(op, m);
    return op;
}
 
Example 4
Source File: ReflectionServiceFactoryTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
@Test
public void testWrappedBuild() throws Exception {
    Service service = createService(true);

    ServiceInfo si = service.getServiceInfos().get(0);
    InterfaceInfo intf = si.getInterface();

    assertEquals(4, intf.getOperations().size());

    String ns = si.getName().getNamespaceURI();
    OperationInfo sayHelloOp = intf.getOperation(new QName(ns, "sayHello"));
    assertNotNull(sayHelloOp);

    assertEquals("sayHello", sayHelloOp.getInput().getName().getLocalPart());

    List<MessagePartInfo> messageParts = sayHelloOp.getInput().getMessageParts();
    assertEquals(1, messageParts.size());
    assertNotNull(messageParts.get(0).getXmlSchema());

    // test unwrapping
    assertTrue(sayHelloOp.isUnwrappedCapable());

    OperationInfo unwrappedOp = sayHelloOp.getUnwrappedOperation();
    assertEquals("sayHello", unwrappedOp.getInput().getName().getLocalPart());

    messageParts = unwrappedOp.getInput().getMessageParts();
    assertEquals(0, messageParts.size());

    // test output
    messageParts = sayHelloOp.getOutput().getMessageParts();
    assertEquals(1, messageParts.size());
    assertEquals("sayHelloResponse", sayHelloOp.getOutput().getName().getLocalPart());

    messageParts = unwrappedOp.getOutput().getMessageParts();
    assertEquals("sayHelloResponse", unwrappedOp.getOutput().getName().getLocalPart());
    assertEquals(1, messageParts.size());
    MessagePartInfo mpi = messageParts.get(0);
    assertEquals("return", mpi.getName().getLocalPart());
    assertEquals(String.class, mpi.getTypeClass());
}
 
Example 5
Source File: JaxWsServiceFactoryBeanTest.java    From cxf with Apache License 2.0 4 votes vote down vote up
@Test
public void testHolder() throws Exception {
    ReflectionServiceFactoryBean bean = new JaxWsServiceFactoryBean();

    Bus bus = getBus();
    bean.setBus(bus);
    bean.setServiceClass(TestMtomImpl.class);

    Service service = bean.create();
    InterfaceInfo intf = service.getServiceInfos().get(0).getInterface();

    OperationInfo op = intf.getOperation(
        new QName("http://cxf.apache.org/mime", "testXop"));
    assertNotNull(op);


    Iterator<MessagePartInfo> itr = op.getInput().getMessageParts().iterator();
    assertTrue(itr.hasNext());
    MessagePartInfo part = itr.next();
    assertEquals("testXop", part.getElementQName().getLocalPart());

    op = op.getUnwrappedOperation();
    assertNotNull(op);

    // test setup of input parts
    itr = op.getInput().getMessageParts().iterator();
    assertTrue(itr.hasNext());
    part = itr.next();
    assertEquals("name", part.getName().getLocalPart());
    assertEquals(String.class, part.getTypeClass());

    /*
     * revisit, try to use other wsdl operation rewrite test in future
    assertTrue(itr.hasNext());
    part = itr.next();
    assertEquals(Boolean.TRUE, part.getProperty(JaxWsServiceFactoryBean.MODE_INOUT));
    assertEquals(byte[].class, part.getTypeClass());

    assertFalse(itr.hasNext());

    // test output setup
    itr = op.getOutput().getMessageParts().iterator();

    assertTrue(itr.hasNext());
    part = itr.next();
    assertEquals(Boolean.TRUE, part.getProperty(JaxWsServiceFactoryBean.MODE_INOUT));
    */
}
 
Example 6
Source File: ServiceWSDLBuilder.java    From cxf with Apache License 2.0 4 votes vote down vote up
private OperationInfo getOperationInfo(OperationInfo operation) {
    if (operation.getUnwrappedOperation() != null) {
        return operation.getUnwrappedOperation();
    }
    return operation;
}
 
Example 7
Source File: WSDLServiceBuilderTest.java    From cxf with Apache License 2.0 4 votes vote down vote up
@Test
public void testOperationInfo() throws Exception {
    setUpBasic();
    QName name = new QName(serviceInfo.getName().getNamespaceURI(), "sayHi");
    assertEquals(4, serviceInfo.getInterface().getOperations().size());
    OperationInfo sayHi = serviceInfo.getInterface().getOperation(
            new QName(serviceInfo.getName().getNamespaceURI(), "sayHi"));
    assertNotNull(sayHi);
    assertEquals(sayHi.getName(), name);
    assertFalse(sayHi.isOneWay());
    assertTrue(sayHi.hasInput());
    assertTrue(sayHi.hasOutput());

    assertNull(sayHi.getParameterOrdering());

    name = new QName(serviceInfo.getName().getNamespaceURI(), "greetMe");
    OperationInfo greetMe = serviceInfo.getInterface().getOperation(name);
    assertNotNull(greetMe);
    assertEquals(greetMe.getName(), name);
    assertFalse(greetMe.isOneWay());
    assertTrue(greetMe.hasInput());
    assertTrue(greetMe.hasOutput());

    List<MessagePartInfo> inParts = greetMe.getInput().getMessageParts();
    assertEquals(1, inParts.size());
    MessagePartInfo part = inParts.get(0);
    assertNotNull(part.getXmlSchema());
    assertTrue(part.getXmlSchema() instanceof XmlSchemaElement);

    List<MessagePartInfo> outParts = greetMe.getOutput().getMessageParts();
    assertEquals(1, outParts.size());
    part = outParts.get(0);
    assertNotNull(part.getXmlSchema());
    assertTrue(part.getXmlSchema() instanceof XmlSchemaElement);

    assertTrue("greatMe should be wrapped", greetMe.isUnwrappedCapable());
    OperationInfo greetMeUnwrapped = greetMe.getUnwrappedOperation();

    assertNotNull(greetMeUnwrapped.getInput());
    assertNotNull(greetMeUnwrapped.getOutput());
    assertEquals("wrapped part not set", 1, greetMeUnwrapped.getInput().size());
    assertEquals("wrapped part not set", 1, greetMeUnwrapped.getOutput().size());
    assertEquals("wrapper part name wrong", "requestType", greetMeUnwrapped.getInput()
            .getMessagePartByIndex(0).getName().getLocalPart());
    assertEquals("wrapper part type name wrong", "MyStringType", greetMeUnwrapped.getInput()
            .getMessagePartByIndex(0).getTypeQName().getLocalPart());

    assertEquals("wrapper part name wrong", "responseType", greetMeUnwrapped.getOutput()
            .getMessagePartByIndex(0).getName().getLocalPart());
    assertEquals("wrapper part type name wrong", "string", greetMeUnwrapped.getOutput()
            .getMessagePartByIndex(0).getTypeQName().getLocalPart());

    name = new QName(serviceInfo.getName().getNamespaceURI(), "greetMeOneWay");
    OperationInfo greetMeOneWay = serviceInfo.getInterface().getOperation(name);
    assertNotNull(greetMeOneWay);
    assertEquals(greetMeOneWay.getName(), name);
    assertTrue(greetMeOneWay.isOneWay());
    assertTrue(greetMeOneWay.hasInput());
    assertFalse(greetMeOneWay.hasOutput());

    OperationInfo greetMeOneWayUnwrapped = greetMeOneWay.getUnwrappedOperation();
    assertNotNull(greetMeOneWayUnwrapped);
    assertNotNull(greetMeOneWayUnwrapped.getInput());
    assertNull(greetMeOneWayUnwrapped.getOutput());
    assertEquals("wrapped part not set", 1, greetMeOneWayUnwrapped.getInput().size());
    assertEquals(new QName("http://apache.org/hello_world_soap_http/types", "requestType"),
                 greetMeOneWayUnwrapped.getInput().getMessagePartByIndex(0).getConcreteName());

    name = new QName(serviceInfo.getName().getNamespaceURI(), "pingMe");
    OperationInfo pingMe = serviceInfo.getInterface().getOperation(name);
    assertNotNull(pingMe);
    assertEquals(pingMe.getName(), name);
    assertFalse(pingMe.isOneWay());
    assertTrue(pingMe.hasInput());
    assertTrue(pingMe.hasOutput());

    assertNull(serviceInfo.getInterface().getOperation(new QName("what ever")));
    control.verify();
}