Search in sources :

Example 51 with MessageInfo

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

the class ColocUtil method isAssignableOperationInfo.

public static boolean isAssignableOperationInfo(OperationInfo oi, Class<?> cls) {
    MessageInfo mi = oi.getInput();
    List<MessagePartInfo> mpis = mi.getMessageParts();
    return mpis.size() == 1 && cls.isAssignableFrom(mpis.get(0).getTypeClass());
}
Also used : MessagePartInfo(org.apache.cxf.service.model.MessagePartInfo) MessageInfo(org.apache.cxf.service.model.MessageInfo)

Example 52 with MessageInfo

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

the class ColocUtilTest method testIsSameMessageInfo.

@Test
public void testIsSameMessageInfo() {
    OperationInfo oi = control.createMock(OperationInfo.class);
    boolean match = ColocUtil.isSameMessageInfo(null, null);
    assertEquals("Should return true", true, match);
    QName mn1 = new QName("A", "B");
    QName mn2 = new QName("C", "D");
    MessageInfo mi1 = new MessageInfo(oi, MessageInfo.Type.INPUT, mn1);
    MessageInfo mi2 = new MessageInfo(oi, MessageInfo.Type.INPUT, mn2);
    match = ColocUtil.isSameMessageInfo(mi1, null);
    assertEquals("Should not find a match", false, match);
    match = ColocUtil.isSameMessageInfo(null, mi2);
    assertEquals("Should not find a match", false, match);
    MessagePartInfo mpi = new MessagePartInfo(new QName("", "B"), null);
    mpi.setTypeClass(InHeaderT.class);
    mi1.addMessagePart(mpi);
    mpi = new MessagePartInfo(new QName("", "D"), null);
    mpi.setTypeClass(OutHeaderT.class);
    mi2.addMessagePart(mpi);
    match = ColocUtil.isSameMessageInfo(mi1, mi2);
    assertEquals("Should not find a match", false, match);
    mpi.setTypeClass(InHeaderT.class);
    match = ColocUtil.isSameMessageInfo(mi1, mi2);
    assertEquals("Should find a match", true, match);
}
Also used : OperationInfo(org.apache.cxf.service.model.OperationInfo) QName(javax.xml.namespace.QName) MessagePartInfo(org.apache.cxf.service.model.MessagePartInfo) MessageInfo(org.apache.cxf.service.model.MessageInfo) Test(org.junit.Test)

Example 53 with MessageInfo

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

the class CorbaStreamInInterceptor method prepareDIIArgsList.

protected NVList prepareDIIArgsList(CorbaMessage corbaMsg, BindingOperationInfo boi, CorbaStreamable[] streamables, List<ParamType> paramTypes, CorbaTypeMap map, ORB orb, ServiceInfo service) {
    try {
        // Build the list of DII arguments, returns, and exceptions
        NVList list = orb.create_list(streamables.length);
        OperationInfo opInfo = boi.getOperationInfo();
        MessageInfo input = opInfo.getInput();
        MessageInfo output = opInfo.getOutput();
        String inWrapNSUri = null;
        String outWrapNSUri = null;
        boolean wrap = false;
        if (boi.isUnwrappedCapable()) {
            wrap = true;
            if (input != null) {
                inWrapNSUri = getWrappedParamNamespace(input);
                if (!CorbaUtils.isElementFormQualified(service, inWrapNSUri)) {
                    inWrapNSUri = "";
                }
            }
            if (output != null) {
                outWrapNSUri = getWrappedParamNamespace(output);
                if (!CorbaUtils.isElementFormQualified(service, outWrapNSUri)) {
                    outWrapNSUri = "";
                }
            }
        }
        int inMsgIndex = 0;
        int outMsgIndex = 0;
        for (int i = 0; i < paramTypes.size(); i++) {
            ParamType param = paramTypes.get(i);
            QName paramIdlType = param.getIdltype();
            QName paramName;
            ModeType paramMode = param.getMode();
            if (paramMode.value().equals("in")) {
                if (wrap) {
                    paramName = new QName(inWrapNSUri, param.getName());
                } else {
                    paramName = getMessageParamQName(input, param.getName(), inMsgIndex);
                    inMsgIndex++;
                }
            } else {
                if (wrap) {
                    paramName = new QName(outWrapNSUri, param.getName());
                } else {
                    paramName = getMessageParamQName(output, param.getName(), outMsgIndex);
                    outMsgIndex++;
                }
            }
            CorbaObjectHandler obj = CorbaHandlerUtils.initializeObjectHandler(orb, paramName, paramIdlType, map, service);
            streamables[i] = corbaMsg.createStreamableObject(obj, paramName);
            Any value = CorbaAnyHelper.createAny(orb);
            if (paramMode.value().equals("in")) {
                streamables[i].setMode(org.omg.CORBA.ARG_IN.value);
                streamables[i].getObject().setIntoAny(value, streamables[i], false);
            } else if (paramMode.value().equals("out")) {
                streamables[i].setMode(org.omg.CORBA.ARG_OUT.value);
                streamables[i].getObject().setIntoAny(value, streamables[i], true);
            } else {
                streamables[i].setMode(org.omg.CORBA.ARG_INOUT.value);
                streamables[i].getObject().setIntoAny(value, streamables[i], false);
            }
            list.add_value(streamables[i].getName(), value, streamables[i].getMode());
            corbaMsg.addStreamableArgument(streamables[i]);
        }
        return list;
    } catch (Exception ex) {
        throw new RuntimeException(ex);
    }
}
Also used : BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) OperationInfo(org.apache.cxf.service.model.OperationInfo) QName(javax.xml.namespace.QName) Any(org.omg.CORBA.Any) Endpoint(org.apache.cxf.endpoint.Endpoint) ParamType(org.apache.cxf.binding.corba.wsdl.ParamType) MessageInfo(org.apache.cxf.service.model.MessageInfo) BindingMessageInfo(org.apache.cxf.service.model.BindingMessageInfo) ModeType(org.apache.cxf.binding.corba.wsdl.ModeType) CorbaObjectHandler(org.apache.cxf.binding.corba.types.CorbaObjectHandler) NVList(org.omg.CORBA.NVList)

Example 54 with MessageInfo

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

the class CorbaStreamOutEndingInterceptor method handleInBoundMessage.

private void handleInBoundMessage(CorbaMessage message, BindingOperationInfo boi) {
    OperationInfo opInfo = boi.getOperationInfo();
    OperationType opType = boi.getExtensor(OperationType.class);
    List<ParamType> paramTypes = opType.getParam();
    MessageInfo msgInInfo = opInfo.getInput();
    String wrapNSUri = null;
    boolean wrap = false;
    if (boi.isUnwrappedCapable()) {
        wrap = true;
        if (msgInInfo != null) {
            wrapNSUri = getWrappedParamNamespace(msgInInfo);
            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) {
        CorbaObjectHandler obj = objs[count++];
        QName retName = obj.getName();
        CorbaStreamable streamable = message.createStreamableObject(obj, retName);
        message.setStreamableReturn(streamable);
    }
    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.IN)) {
            if (wrap) {
                paramName = new QName(wrapNSUri, param.getName());
            } else {
                paramName = getMessageParamQName(msgInInfo, 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);
        } else if (paramMode.value().equals("out")) {
            streamable.setMode(org.omg.CORBA.ARG_OUT.value);
        }
        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 55 with MessageInfo

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

the class ReflectionServiceFactoryTest method testDocLiteralPartWithType.

@Test(expected = ServiceConstructionException.class)
public void testDocLiteralPartWithType() throws Exception {
    serviceFactory = new ReflectionServiceFactoryBean();
    serviceFactory.setBus(getBus());
    serviceFactory.setServiceClass(NoBodyPartsImpl.class);
    serviceFactory.getServiceConfigurations().add(0, new AbstractServiceConfiguration() {

        @Override
        public Boolean isWrapped() {
            return Boolean.FALSE;
        }

        @Override
        public Boolean isWrapped(Method m) {
            return Boolean.FALSE;
        }
    });
    Service service = serviceFactory.create();
    ServiceInfo serviceInfo = service.getServiceInfos().get(0);
    QName qname = new QName("urn:org:apache:cxf:no_body_parts/wsdl", "operation1");
    MessageInfo mi = serviceInfo.getMessage(qname);
    qname = new QName("urn:org:apache:cxf:no_body_parts/wsdl", "mimeAttachment");
    MessagePartInfo mpi = mi.getMessagePart(qname);
    QName elementQName = mpi.getElementQName();
    XmlSchemaElement element = serviceInfo.getXmlSchemaCollection().getElementByQName(elementQName);
    assertNotNull(element);
}
Also used : ServiceInfo(org.apache.cxf.service.model.ServiceInfo) AbstractServiceConfiguration(org.apache.cxf.wsdl.service.factory.AbstractServiceConfiguration) QName(javax.xml.namespace.QName) XmlSchemaElement(org.apache.ws.commons.schema.XmlSchemaElement) Service(org.apache.cxf.service.Service) Method(java.lang.reflect.Method) ReflectionServiceFactoryBean(org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean) MessagePartInfo(org.apache.cxf.service.model.MessagePartInfo) MessageInfo(org.apache.cxf.service.model.MessageInfo) Test(org.junit.Test)

Aggregations

MessageInfo (org.apache.cxf.service.model.MessageInfo)69 QName (javax.xml.namespace.QName)41 OperationInfo (org.apache.cxf.service.model.OperationInfo)39 BindingOperationInfo (org.apache.cxf.service.model.BindingOperationInfo)36 MessagePartInfo (org.apache.cxf.service.model.MessagePartInfo)36 BindingMessageInfo (org.apache.cxf.service.model.BindingMessageInfo)19 SoapOperationInfo (org.apache.cxf.binding.soap.model.SoapOperationInfo)15 ServiceInfo (org.apache.cxf.service.model.ServiceInfo)14 Test (org.junit.Test)14 Endpoint (org.apache.cxf.endpoint.Endpoint)13 Method (java.lang.reflect.Method)9 ArrayList (java.util.ArrayList)9 Service (org.apache.cxf.service.Service)9 MessageContentsList (org.apache.cxf.message.MessageContentsList)8 Fault (org.apache.cxf.interceptor.Fault)7 Exchange (org.apache.cxf.message.Exchange)7 BindingInfo (org.apache.cxf.service.model.BindingInfo)7 FaultInfo (org.apache.cxf.service.model.FaultInfo)7 Message (org.apache.cxf.message.Message)6 UnwrappedOperationInfo (org.apache.cxf.service.model.UnwrappedOperationInfo)6