Search in sources :

Example 81 with OperationInfo

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

the class XMLMessageInInterceptorTest method testHandleMessageOnBareMultiParam.

@Test
public void testHandleMessageOnBareMultiParam() throws Exception {
    String ns = "http://apache.org/hello_world_xml_http/bare";
    prepareMessage("/message-bare-multi-param.xml");
    common("/wsdl/hello_world_xml_bare.wsdl", new QName(ns, "XMLPort"), MyComplexStructType.class);
    OperationInfo op = serviceInfo.getInterface().getOperation(new QName(ns, "testMultiParamPart"));
    op.getInput().getMessagePartByIndex(0).setTypeClass(String.class);
    op.getInput().getMessagePartByIndex(1).setTypeClass(MyComplexStructType.class);
    in.handleMessage(xmlMessage);
    docLitIn.handleMessage(xmlMessage);
    List<?> list = xmlMessage.getContent(List.class);
    assertNotNull(list);
    assertEquals("expect 2 param", 2, list.size());
    assertEquals("method input in2 is MyComplexStructType", true, list.get(1) instanceof MyComplexStructType);
    assertEquals("method input in1 is String tli", true, ((String) list.get(0)).indexOf("tli") >= 0);
}
Also used : OperationInfo(org.apache.cxf.service.model.OperationInfo) QName(javax.xml.namespace.QName) MyComplexStructType(org.apache.hello_world_xml_http.bare.types.MyComplexStructType) Test(org.junit.Test)

Example 82 with OperationInfo

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

the class XMLMessageInInterceptorTest method testHandleMessageOnBareSingleChild.

@Test
public void testHandleMessageOnBareSingleChild() throws Exception {
    String ns = "http://apache.org/hello_world_xml_http/bare";
    prepareMessage("/message-bare-single-param-element.xml");
    common("/wsdl/hello_world_xml_bare.wsdl", new QName(ns, "XMLPort"));
    OperationInfo op = serviceInfo.getInterface().getOperation(new QName(ns, "greetMe"));
    op.getInput().getMessagePartByIndex(0).setTypeClass(String.class);
    in.handleMessage(xmlMessage);
    docLitIn.handleMessage(xmlMessage);
    List<?> list = xmlMessage.getContent(List.class);
    assertNotNull(list);
    assertEquals("expect 1 param", 1, list.size());
    assertEquals("method input me is String tli", true, ((String) list.get(0)).indexOf("tli") >= 0);
}
Also used : OperationInfo(org.apache.cxf.service.model.OperationInfo) QName(javax.xml.namespace.QName) Test(org.junit.Test)

Example 83 with OperationInfo

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

the class XMLMessageInInterceptorTest method testHandleMessageWrapped.

@Test
public void testHandleMessageWrapped() throws Exception {
    String ns = "http://apache.org/hello_world_xml_http/wrapped";
    prepareMessage("/message-wrap.xml");
    common("/wsdl/hello_world_xml_wrapped.wsdl", new QName(ns, "XMLPort"), GreetMe.class);
    OperationInfo op = serviceInfo.getInterface().getOperation(new QName(ns, "greetMe"));
    op.getInput().getMessagePartByIndex(0).setTypeClass(GreetMe.class);
    in.handleMessage(xmlMessage);
    docLitIn.handleMessage(xmlMessage);
    List<?> list = xmlMessage.getContent(List.class);
    assertNotNull(list);
    assertEquals("expect 1 param", 1, list.size());
    assertEquals("method input me is String tli", true, list.get(0) instanceof GreetMe);
}
Also used : OperationInfo(org.apache.cxf.service.model.OperationInfo) GreetMe(org.apache.hello_world_xml_http.wrapped.types.GreetMe) QName(javax.xml.namespace.QName) Test(org.junit.Test)

Example 84 with OperationInfo

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

the class AegisDatabinding method initialize.

/**
 * {@inheritDoc} Set up the data binding for a service.
 */
public void initialize(Service s) {
    // We want to support some compatibility configuration properties.
    if (aegisContext == null) {
        aegisContext = new AegisContext();
        Object val = s.get("mtom-enabled");
        if ("true".equals(val) || Boolean.TRUE.equals(val) || mtomEnabled) {
            setMtomEnabled(true);
            aegisContext.setMtomEnabled(true);
        }
        if (mtomUseXmime) {
            aegisContext.setMtomUseXmime(true);
        }
        Map<Class<?>, String> implMap = new HashMap<>();
        // now for a really annoying case, the .implementation objects.
        for (String key : s.keySet()) {
            if (key.endsWith(".implementation")) {
                String className = key.substring(0, key.length() - ".implementation".length());
                Class<?> clazz = null;
                try {
                    clazz = ClassLoaderUtils.loadClass(className, getClass());
                } catch (ClassNotFoundException e) {
                    Message message = new Message("MAPPED_CLASS_NOT_FOUND", LOG, className, key);
                    LOG.warning(message.toString());
                    continue;
                }
                String implClassName = (String) s.get(key);
                implMap.put(clazz, implClassName);
            }
        }
        if (overrideTypes != null) {
            aegisContext.setRootClassNames(overrideTypes);
        }
        if (configuration != null) {
            aegisContext.setTypeCreationOptions(configuration);
        }
        if (!implMap.isEmpty()) {
            aegisContext.setBeanImplementationMap(implMap);
        }
    }
    aegisContext.setMappingNamespaceURI(s.getServiceInfos().get(0).getInterface().getName().getNamespaceURI());
    aegisContext.initialize();
    this.service = s;
    s.getInInterceptors().add(new StaxSchemaValidationInInterceptor());
    Set<AegisType> deps = new HashSet<>();
    for (ServiceInfo info : s.getServiceInfos()) {
        for (OperationInfo opInfo : info.getInterface().getOperations()) {
            if (opInfo.isUnwrappedCapable()) {
                initializeOperation(s, aegisContext.getTypeMapping(), opInfo.getUnwrappedOperation(), deps);
            } else {
                initializeOperation(s, aegisContext.getTypeMapping(), opInfo, deps);
            }
        }
    }
    Collection<AegisType> additional = aegisContext.getRootTypes();
    if (additional != null) {
        for (AegisType t : additional) {
            if (!deps.contains(t)) {
                deps.add(t);
            }
            addDependencies(deps, t);
        }
    }
    createSchemas(s, deps);
    for (ServiceInfo info : s.getServiceInfos()) {
        for (OperationInfo opInfo : info.getInterface().getOperations()) {
            if (opInfo.isUnwrappedCapable()) {
                initializeOperationTypes(info, opInfo.getUnwrappedOperation());
            } else {
                initializeOperationTypes(info, opInfo);
            }
        }
    }
}
Also used : OperationInfo(org.apache.cxf.service.model.OperationInfo) Message(org.apache.cxf.common.i18n.Message) HashMap(java.util.HashMap) AegisType(org.apache.cxf.aegis.type.AegisType) AegisContext(org.apache.cxf.aegis.AegisContext) StaxSchemaValidationInInterceptor(org.apache.cxf.staxutils.validation.StaxSchemaValidationInInterceptor) ServiceInfo(org.apache.cxf.service.model.ServiceInfo) HashSet(java.util.HashSet)

Example 85 with OperationInfo

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

the class XMLFormatValidator method checkXMLFormat.

private boolean checkXMLFormat(BindingInfo binding) {
    Collection<BindingOperationInfo> bos = binding.getOperations();
    boolean result = true;
    boolean needRootNode = false;
    for (BindingOperationInfo bo : bos) {
        OperationInfo op = binding.getInterface().getOperation(bo.getName());
        needRootNode = false;
        final int inputPartsNum = op.getInput().getMessagePartsNumber();
        if (inputPartsNum == 0 || inputPartsNum > 1) {
            needRootNode = true;
        }
        if (needRootNode) {
            String path = "Binding(" + binding.getName().getLocalPart() + "):BindingOperation(" + bo.getName() + ")";
            List<XMLBindingMessageFormat> inExtensors = bo.getInput().getExtensors(XMLBindingMessageFormat.class);
            Iterator<XMLBindingMessageFormat> itIn = null;
            if (inExtensors != null) {
                itIn = inExtensors.iterator();
            }
            if (!findXMLFormatRootNode(itIn, bo, path + "-input")) {
                return false;
            }
            // Input check correct, continue to check output binding
            if (op.getOutput() != null) {
                needRootNode = false;
                final int outputPartsNum = op.getOutput().getMessagePartsNumber();
                if (outputPartsNum == 0 || outputPartsNum > 1) {
                    needRootNode = true;
                }
                if (needRootNode) {
                    List<XMLBindingMessageFormat> outExtensors = bo.getOutput().getExtensors(XMLBindingMessageFormat.class);
                    Iterator<XMLBindingMessageFormat> itOut = null;
                    if (outExtensors != null) {
                        itOut = outExtensors.iterator();
                    }
                    result = result && findXMLFormatRootNode(itOut, bo, path + "-Output");
                    if (!result) {
                        return false;
                    }
                }
            }
        }
    }
    return true;
}
Also used : OperationInfo(org.apache.cxf.service.model.OperationInfo) BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) XMLBindingMessageFormat(org.apache.cxf.bindings.xformat.XMLBindingMessageFormat)

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