Search in sources :

Example 41 with OperationInfo

use of org.apache.cxf.service.model.OperationInfo in project cxf by apache.

the class CorbaStreamOutEndingInterceptor method handleOutBoundMessage.

private void handleOutBoundMessage(CorbaMessage message, BindingOperationInfo boi) {
    OperationInfo opInfo = boi.getOperationInfo();
    OperationType opType = boi.getExtensor(OperationType.class);
    List<ParamType> paramTypes = opType.getParam();
    MessageInfo outMsgInfo = opInfo.getOutput();
    String wrapNSUri = null;
    boolean wrap = false;
    if (boi.isUnwrappedCapable()) {
        wrap = true;
        if (outMsgInfo != null) {
            wrapNSUri = getWrappedParamNamespace(outMsgInfo);
            if (!CorbaUtils.isElementFormQualified(service, wrapNSUri)) {
                wrapNSUri = "";
            }
        }
    }
    CorbaStreamWriter writer = (CorbaStreamWriter) message.getContent(XMLStreamWriter.class);
    CorbaObjectHandler[] objs = writer.getCorbaObjects();
    int count = 0;
    int msgIndex = 0;
    ArgType returnParam = opType.getReturn();
    if (returnParam != null) {
        QName retName;
        if (wrap) {
            retName = new QName(wrapNSUri, returnParam.getName());
        } else {
            retName = getMessageParamQName(outMsgInfo, returnParam.getName(), msgIndex);
        }
        QName retIdlType = returnParam.getIdltype();
        CorbaObjectHandler obj = CorbaHandlerUtils.initializeObjectHandler(orb, retName, retIdlType, typeMap, service);
        CorbaStreamable streamable = message.createStreamableObject(obj, retName);
        message.setStreamableReturn(streamable);
        msgIndex++;
    }
    for (Iterator<ParamType> iter = paramTypes.iterator(); iter.hasNext(); ) {
        ParamType param = iter.next();
        QName idlType = param.getIdltype();
        QName paramName;
        CorbaObjectHandler obj = null;
        if (param.getMode().equals(ModeType.OUT)) {
            if (wrap) {
                paramName = new QName(wrapNSUri, param.getName());
            } else {
                paramName = getMessageParamQName(outMsgInfo, param.getName(), msgIndex);
            }
            obj = CorbaHandlerUtils.initializeObjectHandler(orb, paramName, idlType, typeMap, service);
            msgIndex++;
        } else {
            obj = objs[count++];
            paramName = obj.getName();
        }
        CorbaStreamable streamable = message.createStreamableObject(obj, paramName);
        ModeType paramMode = param.getMode();
        if (paramMode.value().equals("in")) {
            streamable.setMode(org.omg.CORBA.ARG_IN.value);
        } else if (paramMode.value().equals("inout")) {
            streamable.setMode(org.omg.CORBA.ARG_INOUT.value);
        }
        // default mode is out
        message.addStreamableArgument(streamable);
    }
}
Also used : BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) OperationInfo(org.apache.cxf.service.model.OperationInfo) ArgType(org.apache.cxf.binding.corba.wsdl.ArgType) CorbaStreamable(org.apache.cxf.binding.corba.CorbaStreamable) QName(javax.xml.namespace.QName) ParamType(org.apache.cxf.binding.corba.wsdl.ParamType) MessageInfo(org.apache.cxf.service.model.MessageInfo) CorbaStreamWriter(org.apache.cxf.binding.corba.runtime.CorbaStreamWriter) XMLStreamWriter(javax.xml.stream.XMLStreamWriter) CorbaObjectHandler(org.apache.cxf.binding.corba.types.CorbaObjectHandler) ModeType(org.apache.cxf.binding.corba.wsdl.ModeType) OperationType(org.apache.cxf.binding.corba.wsdl.OperationType)

Example 42 with OperationInfo

use of org.apache.cxf.service.model.OperationInfo in project cxf by apache.

the class ReflectionServiceFactoryTest method testWrappedBuild.

@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());
}
Also used : ServiceInfo(org.apache.cxf.service.model.ServiceInfo) BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) OperationInfo(org.apache.cxf.service.model.OperationInfo) SoapOperationInfo(org.apache.cxf.binding.soap.model.SoapOperationInfo) QName(javax.xml.namespace.QName) Service(org.apache.cxf.service.Service) InterfaceInfo(org.apache.cxf.service.model.InterfaceInfo) MessagePartInfo(org.apache.cxf.service.model.MessagePartInfo) Test(org.junit.Test)

Example 43 with OperationInfo

use of org.apache.cxf.service.model.OperationInfo in project cxf by apache.

the class ServiceJavascriptBuilder method begin.

@Override
public void begin(OperationInfo op) {
    if (op.isUnwrapped()) {
        isInUnwrappedOperation = true;
        return;
    }
    currentOperation = op;
    OperationInfo conflict = localOperationsNameMap.get(op.getName().getLocalPart());
    if (conflict != null) {
        operationsWithNameConflicts.add(conflict);
        operationsWithNameConflicts.add(op);
    }
    localOperationsNameMap.put(op.getName().getLocalPart(), op);
    opFunctionPropertyName = getFunctionPropertyName(operationsWithNameConflicts, op, op.getName());
    opFunctionGlobalName = getFunctionGlobalName(op.getName(), "op");
}
Also used : OperationInfo(org.apache.cxf.service.model.OperationInfo)

Example 44 with OperationInfo

use of org.apache.cxf.service.model.OperationInfo in project cxf by apache.

the class JaxWsServiceConfigurationTest method testGetOutPartName.

@Test
public void testGetOutPartName() throws Exception {
    QName opName = new QName("http://cxf.com/", "sayHi");
    Method sayHiMethod = Hello.class.getMethod("sayHi", new Class[] {});
    ServiceInfo si = getMockedServiceModel("/wsdl/default_partname_test.wsdl");
    JaxWsServiceConfiguration jwsc = new JaxWsServiceConfiguration();
    JaxWsServiceFactoryBean bean = new JaxWsServiceFactoryBean();
    bean.setServiceClass(Hello.class);
    jwsc.setServiceFactory(bean);
    // clear the output
    OperationInfo op = si.getInterface().getOperation(opName);
    op.setOutput("output", new MessageInfo(op, MessageInfo.Type.OUTPUT, new QName("http://cxf.com/", "output")));
    QName partName = jwsc.getOutPartName(op, sayHiMethod, -1);
    assertEquals("get wrong return partName", new QName("http://cxf.com/", "return"), partName);
}
Also used : ServiceInfo(org.apache.cxf.service.model.ServiceInfo) OperationInfo(org.apache.cxf.service.model.OperationInfo) QName(javax.xml.namespace.QName) WebMethod(javax.jws.WebMethod) Method(java.lang.reflect.Method) MessageInfo(org.apache.cxf.service.model.MessageInfo) Test(org.junit.Test)

Example 45 with OperationInfo

use of org.apache.cxf.service.model.OperationInfo in project cxf by apache.

the class JaxWsServiceFactoryBeanTest method testWrappedDocLit.

@Test
public void testWrappedDocLit() throws Exception {
    ReflectionServiceFactoryBean bean = new JaxWsServiceFactoryBean();
    Bus bus = getBus();
    bean.setBus(bus);
    bean.setServiceClass(org.apache.hello_world_doc_lit.Greeter.class);
    Service service = bean.create();
    ServiceInfo si = service.getServiceInfos().get(0);
    InterfaceInfo intf = si.getInterface();
    assertEquals(4, intf.getOperations().size());
    String ns = si.getName().getNamespaceURI();
    assertEquals("http://apache.org/hello_world_doc_lit", ns);
    OperationInfo greetMeOp = intf.getOperation(new QName(ns, "greetMe"));
    assertNotNull(greetMeOp);
    assertEquals("greetMe", greetMeOp.getInput().getName().getLocalPart());
    assertEquals("http://apache.org/hello_world_doc_lit", greetMeOp.getInput().getName().getNamespaceURI());
    List<MessagePartInfo> messageParts = greetMeOp.getInput().getMessageParts();
    assertEquals(1, messageParts.size());
    MessagePartInfo inMessagePart = messageParts.get(0);
    assertEquals("http://apache.org/hello_world_doc_lit", inMessagePart.getName().getNamespaceURI());
    assertEquals("http://apache.org/hello_world_doc_lit/types", inMessagePart.getElementQName().getNamespaceURI());
    // test output
    messageParts = greetMeOp.getOutput().getMessageParts();
    assertEquals(1, messageParts.size());
    assertEquals("greetMeResponse", greetMeOp.getOutput().getName().getLocalPart());
    MessagePartInfo outMessagePart = messageParts.get(0);
    // assertEquals("result", outMessagePart.getName().getLocalPart());
    assertEquals("http://apache.org/hello_world_doc_lit", outMessagePart.getName().getNamespaceURI());
    assertEquals("http://apache.org/hello_world_doc_lit/types", outMessagePart.getElementQName().getNamespaceURI());
    OperationInfo greetMeOneWayOp = si.getInterface().getOperation(new QName(ns, "greetMeOneWay"));
    assertEquals(1, greetMeOneWayOp.getInput().getMessageParts().size());
    assertNull(greetMeOneWayOp.getOutput());
    Collection<SchemaInfo> schemas = si.getSchemas();
    assertEquals(1, schemas.size());
}
Also used : OperationInfo(org.apache.cxf.service.model.OperationInfo) Bus(org.apache.cxf.Bus) QName(javax.xml.namespace.QName) Service(org.apache.cxf.service.Service) WebService(javax.jws.WebService) MessagePartInfo(org.apache.cxf.service.model.MessagePartInfo) ServiceInfo(org.apache.cxf.service.model.ServiceInfo) InterfaceInfo(org.apache.cxf.service.model.InterfaceInfo) ReflectionServiceFactoryBean(org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean) SchemaInfo(org.apache.cxf.service.model.SchemaInfo) Test(org.junit.Test) AbstractJaxWsTest(org.apache.cxf.jaxws.AbstractJaxWsTest)

Aggregations

OperationInfo (org.apache.cxf.service.model.OperationInfo)135 BindingOperationInfo (org.apache.cxf.service.model.BindingOperationInfo)87 QName (javax.xml.namespace.QName)58 MessagePartInfo (org.apache.cxf.service.model.MessagePartInfo)44 MessageInfo (org.apache.cxf.service.model.MessageInfo)40 Test (org.junit.Test)38 ServiceInfo (org.apache.cxf.service.model.ServiceInfo)36 InterfaceInfo (org.apache.cxf.service.model.InterfaceInfo)31 Method (java.lang.reflect.Method)25 Endpoint (org.apache.cxf.endpoint.Endpoint)24 Service (org.apache.cxf.service.Service)22 BindingInfo (org.apache.cxf.service.model.BindingInfo)21 EndpointInfo (org.apache.cxf.service.model.EndpointInfo)19 SoapOperationInfo (org.apache.cxf.binding.soap.model.SoapOperationInfo)17 Exchange (org.apache.cxf.message.Exchange)17 ArrayList (java.util.ArrayList)13 UnwrappedOperationInfo (org.apache.cxf.service.model.UnwrappedOperationInfo)13 BindingMessageInfo (org.apache.cxf.service.model.BindingMessageInfo)12 Fault (org.apache.cxf.interceptor.Fault)10 Message (org.apache.cxf.message.Message)10