Search in sources :

Example 61 with OperationInfo

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

the class ResponseWrapperTest method testBuildFields.

@Test
public void testBuildFields() {
    // Test String[]
    Class<?> testingClass = GreeterArray.class;
    OperationInfo opInfo = getOperation(testingClass, "sayStringArray");
    assertNotNull(opInfo);
    ResponseWrapper responseWrapper = new ResponseWrapper();
    MessageInfo message = opInfo.getUnwrappedOperation().getOutput();
    Method method = (Method) opInfo.getProperty("operation.method");
    JavaField field = responseWrapper.buildFields(method, message).get(0);
    assertEquals("_return", field.getParaName());
    assertEquals("String[]", field.getType());
    // Test int[]
    opInfo = getOperation(testingClass, "sayIntArray");
    assertNotNull(opInfo);
    message = opInfo.getUnwrappedOperation().getOutput();
    method = (Method) opInfo.getProperty("operation.method");
    field = responseWrapper.buildFields(method, message).get(0);
    assertEquals("_return", field.getParaName());
    assertEquals("int[]", field.getType());
    // Test TestDataBean[]
    opInfo = getOperation(testingClass, "sayTestDataBeanArray");
    assertNotNull(opInfo);
    message = opInfo.getUnwrappedOperation().getOutput();
    method = (Method) opInfo.getProperty("operation.method");
    field = responseWrapper.buildFields(method, message).get(0);
    assertEquals("_return", field.getParaName());
    assertEquals("org.apache.cxf.tools.fortest.withannotation.doc.TestDataBean[]", field.getType());
}
Also used : OperationInfo(org.apache.cxf.service.model.OperationInfo) JavaField(org.apache.cxf.tools.common.model.JavaField) GreeterArray(org.apache.cxf.tools.fortest.withannotation.doc.GreeterArray) Method(java.lang.reflect.Method) MessageInfo(org.apache.cxf.service.model.MessageInfo) Test(org.junit.Test)

Example 62 with OperationInfo

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

the class UniqueBodyValidator method isValidEndpoint.

private boolean isValidEndpoint(EndpointInfo endpoint) {
    BindingInfo binding = endpoint.getBinding();
    Map<QName, QName> uniqueNames = new HashMap<>();
    Map<QName, Set<String>> actions = new HashMap<>();
    Collection<BindingOperationInfo> bos = binding.getOperations();
    for (BindingOperationInfo bo : bos) {
        OperationInfo op = binding.getInterface().getOperation(bo.getName());
        if (op.getInput() != null && op.getInput().getMessagePartsNumber() == 1) {
            MessagePartInfo part = op.getInput().getFirstMessagePart();
            if (part.getElementQName() == null) {
                continue;
            }
            QName mName = part.getElementQName();
            String action = getWSAAction(op.getInput());
            QName opName = uniqueNames.get(mName);
            Set<String> opActions = actions.get(mName);
            if (opName != null && opActions != null && !opActions.contains(action)) {
                opName = null;
            }
            if (opName != null) {
                Message msg = new Message("NON_UNIQUE_BODY", LOG, endpoint.getName(), op.getName(), opName, mName);
                addErrorMessage(msg.toString());
                return false;
            }
            uniqueNames.put(mName, op.getName());
            if (action != null) {
                if (opActions == null) {
                    opActions = new HashSet<>();
                    actions.put(mName, opActions);
                }
                opActions.add(action);
            }
        }
        for (BindingFaultInfo fault : bo.getFaults()) {
            if (fault.getFaultInfo().getMessagePartsNumber() > 1) {
                Message msg = new Message("FAULT_WITH_MULTIPLE_PARTS", LOG, fault.getFaultInfo().getName().getLocalPart());
                addErrorMessage(msg.toString());
                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) Set(java.util.Set) HashSet(java.util.HashSet) Message(org.apache.cxf.common.i18n.Message) HashMap(java.util.HashMap) QName(javax.xml.namespace.QName) MessagePartInfo(org.apache.cxf.service.model.MessagePartInfo) BindingInfo(org.apache.cxf.service.model.BindingInfo) BindingFaultInfo(org.apache.cxf.service.model.BindingFaultInfo)

Example 63 with OperationInfo

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

the class MethodMapperTest method testMapOneWayOperation.

@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());
}
Also used : OperationInfo(org.apache.cxf.service.model.OperationInfo) QName(javax.xml.namespace.QName) JavaMethod(org.apache.cxf.tools.common.model.JavaMethod) MessageInfo(org.apache.cxf.service.model.MessageInfo) Test(org.junit.Test)

Example 64 with OperationInfo

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

the class JBossWSInvokerTest method getTestExchange.

// build up a fake exchange instance, the minimum required to let the flow proceed till the JBossWSInvoker
private Exchange getTestExchange() {
    Exchange exchange = new ExchangeImpl();
    Message message = new MessageImpl();
    message.setExchange(exchange);
    exchange.setInMessage(message);
    exchange.put(BindingOperationInfo.class, new BindingOperationInfo());
    Service service = new ServiceImpl();
    MethodDispatcher md = new MethodDispatcher() {

        @Override
        public Method getMethod(BindingOperationInfo op) {
            return this.getClass().getMethods()[0];
        }

        @Override
        public BindingOperationInfo getBindingOperation(Method m, Endpoint endpoint) {
            return null;
        }

        @Override
        public void bind(OperationInfo o, Method... methods) {
        }
    };
    service.put(MethodDispatcher.class.getName(), md);
    exchange.put(Service.class, service);
    return exchange;
}
Also used : Exchange(org.apache.cxf.message.Exchange) OperationInfo(org.apache.cxf.service.model.OperationInfo) BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) Message(org.apache.cxf.message.Message) Endpoint(org.apache.cxf.endpoint.Endpoint) ServiceImpl(org.apache.cxf.service.ServiceImpl) Service(org.apache.cxf.service.Service) MethodDispatcher(org.apache.cxf.service.invoker.MethodDispatcher) Method(java.lang.reflect.Method) MessageImpl(org.apache.cxf.message.MessageImpl) ExchangeImpl(org.apache.cxf.message.ExchangeImpl)

Example 65 with OperationInfo

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

the class CxfWSDLImporter method importService.

protected WSService importService(ServiceInfo service) {
    String name = service.getName().getLocalPart();
    String location = "";
    for (EndpointInfo endpoint : service.getEndpoints()) {
        location = endpoint.getAddress();
    }
    WSService wsService = new WSService(this.namespace + name, location, this.wsdlLocation);
    for (OperationInfo operation : service.getInterface().getOperations()) {
        WSOperation wsOperation = this.importOperation(operation, wsService);
        wsService.addOperation(wsOperation);
        this.wsOperations.put(this.namespace + operation.getName().getLocalPart(), wsOperation);
    }
    return wsService;
}
Also used : OperationInfo(org.apache.cxf.service.model.OperationInfo) EndpointInfo(org.apache.cxf.service.model.EndpointInfo)

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