Search in sources :

Example 51 with OperationInfo

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

the class ProxyTest method testCreateSequenceResponse.

@Test
public void testCreateSequenceResponse() throws NoSuchMethodException, RMException {
    Method m = Proxy.class.getDeclaredMethod("invoke", new Class[] { OperationInfo.class, ProtocolVariation.class, Object[].class, Map.class });
    Proxy proxy = EasyMock.createMockBuilder(Proxy.class).addMockedMethod(m).createMock(control);
    proxy.setReliableEndpoint(rme);
    Endpoint endpoint = control.createMock(Endpoint.class);
    EasyMock.expect(rme.getEndpoint(ProtocolVariation.RM10WSA200408)).andReturn(endpoint).anyTimes();
    EndpointInfo epi = control.createMock(EndpointInfo.class);
    EasyMock.expect(endpoint.getEndpointInfo()).andReturn(epi).anyTimes();
    ServiceInfo si = control.createMock(ServiceInfo.class);
    EasyMock.expect(epi.getService()).andReturn(si).anyTimes();
    InterfaceInfo ii = control.createMock(InterfaceInfo.class);
    EasyMock.expect(si.getInterface()).andReturn(ii).anyTimes();
    OperationInfo oi = control.createMock(OperationInfo.class);
    EasyMock.expect(ii.getOperation(RM10Constants.CREATE_SEQUENCE_RESPONSE_ONEWAY_QNAME)).andReturn(oi).anyTimes();
    org.apache.cxf.ws.rm.v200702.CreateSequenceResponseType csr = control.createMock(org.apache.cxf.ws.rm.v200702.CreateSequenceResponseType.class);
    expectInvoke(proxy, oi, null);
    control.replay();
    proxy.createSequenceResponse(csr, ProtocolVariation.RM10WSA200408);
}
Also used : ServiceInfo(org.apache.cxf.service.model.ServiceInfo) BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) OperationInfo(org.apache.cxf.service.model.OperationInfo) EndpointInfo(org.apache.cxf.service.model.EndpointInfo) Endpoint(org.apache.cxf.endpoint.Endpoint) Method(java.lang.reflect.Method) InterfaceInfo(org.apache.cxf.service.model.InterfaceInfo) Test(org.junit.Test)

Example 52 with OperationInfo

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

the class RMEndpoint method buildSequenceAckOperationInfo.

void buildSequenceAckOperationInfo(InterfaceInfo ii, ProtocolVariation protocol) {
    OperationInfo operationInfo = null;
    MessageInfo messageInfo = null;
    RMConstants consts = protocol.getConstants();
    operationInfo = ii.addOperation(consts.getSequenceAckOperationName());
    messageInfo = operationInfo.createMessage(consts.getSequenceAckOperationName(), MessageInfo.Type.INPUT);
    operationInfo.setInput(messageInfo.getName().getLocalPart(), messageInfo);
}
Also used : OperationInfo(org.apache.cxf.service.model.OperationInfo) SoapOperationInfo(org.apache.cxf.binding.soap.model.SoapOperationInfo) BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) MessageInfo(org.apache.cxf.service.model.MessageInfo)

Example 53 with OperationInfo

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

the class RMEndpoint method buildAckRequestedOperationInfo.

void buildAckRequestedOperationInfo(InterfaceInfo ii, ProtocolVariation protocol) {
    OperationInfo operationInfo = null;
    MessageInfo messageInfo = null;
    RMConstants consts = protocol.getConstants();
    operationInfo = ii.addOperation(consts.getAckRequestedOperationName());
    messageInfo = operationInfo.createMessage(consts.getAckRequestedOperationName(), MessageInfo.Type.INPUT);
    operationInfo.setInput(messageInfo.getName().getLocalPart(), messageInfo);
}
Also used : OperationInfo(org.apache.cxf.service.model.OperationInfo) SoapOperationInfo(org.apache.cxf.binding.soap.model.SoapOperationInfo) BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) MessageInfo(org.apache.cxf.service.model.MessageInfo)

Example 54 with OperationInfo

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

the class ServiceProcessor method processOperation.

private void processOperation(JavaModel model, BindingOperationInfo bop, BindingInfo binding) throws ToolException {
    boolean enableOpMime = false;
    JAXWSBinding bind = binding.getExtensor(JAXWSBinding.class);
    if (bind != null && bind.isEnableMime()) {
        enableOpMime = true;
    }
    JAXWSBinding bopBinding = bop.getExtensor(JAXWSBinding.class);
    if (bopBinding != null && bopBinding.isEnableMime()) {
        enableOpMime = true;
        if (bopBinding.getJaxwsParas() != null) {
            jaxwsBinding.setJaxwsParas(bopBinding.getJaxwsParas());
        }
    }
    JavaInterface jf = null;
    for (JavaInterface jf2 : model.getInterfaces().values()) {
        if (binding.getInterface().getName().getLocalPart().equals(jf2.getWebServiceName())) {
            jf = jf2;
        }
    }
    if (jf == null) {
        throw new ToolException("No Java Interface available");
    }
    if (isSoapBinding()) {
        SoapBinding soapBinding = (SoapBinding) bindingObj;
        if (SOAPBindingUtil.getSoapStyle(soapBinding.getStyle()) == null) {
            jf.setSOAPStyle(javax.jws.soap.SOAPBinding.Style.DOCUMENT);
        } else {
            jf.setSOAPStyle(SOAPBindingUtil.getSoapStyle(soapBinding.getStyle()));
        }
    } else {
        // REVISIT: fix for xml binding
        jf.setSOAPStyle(javax.jws.soap.SOAPBinding.Style.DOCUMENT);
    }
    Object[] methods = jf.getMethods().toArray();
    for (int i = 0; i < methods.length; i++) {
        JavaMethod jm = (JavaMethod) methods[i];
        if (jm.getOperationName() != null && jm.getOperationName().equals(bop.getName().getLocalPart())) {
            if (isSoapBinding()) {
                // TODO: add customize here
                // doCustomizeOperation(jf, jm, bop);
                Map<String, Object> prop = getSoapOperationProp(bop);
                String soapAction = prop.get(soapOPAction) == null ? "" : (String) prop.get(soapOPAction);
                String soapStyle = prop.get(soapOPStyle) == null ? "" : (String) prop.get(soapOPStyle);
                jm.setSoapAction(soapAction);
                if (SOAPBindingUtil.getSoapStyle(soapStyle) == null && this.bindingObj == null) {
                    org.apache.cxf.common.i18n.Message msg = new org.apache.cxf.common.i18n.Message("BINDING_STYLE_NOT_DEFINED", LOG);
                    throw new ToolException(msg);
                }
                if (SOAPBindingUtil.getSoapStyle(soapStyle) == null) {
                    jm.setSoapStyle(jf.getSOAPStyle());
                } else {
                    jm.setSoapStyle(SOAPBindingUtil.getSoapStyle(soapStyle));
                }
            } else {
                // REVISIT: fix for xml binding
                jm.setSoapStyle(jf.getSOAPStyle());
            }
            if (jm.getSoapStyle().equals(javax.jws.soap.SOAPBinding.Style.RPC)) {
                jm.getAnnotationMap().remove("SOAPBinding");
            }
            OperationProcessor processor = new OperationProcessor(context);
            int headerType = isNonWrappable(bop);
            OperationInfo opinfo = bop.getOperationInfo();
            JAXWSBinding opBinding = opinfo.getExtensor(JAXWSBinding.class);
            JAXWSBinding infBinding = opinfo.getInterface().getExtensor(JAXWSBinding.class);
            boolean enableMime = enableOpMime;
            boolean enableWrapperStyle = true;
            if (infBinding != null && infBinding.isSetEnableWrapperStyle()) {
                enableWrapperStyle = infBinding.isEnableWrapperStyle();
            }
            if (infBinding != null && infBinding.isSetEnableMime()) {
                enableMime = infBinding.isEnableMime();
            }
            if (opBinding != null && opBinding.isSetEnableWrapperStyle()) {
                enableWrapperStyle = opBinding.isEnableWrapperStyle();
            }
            if (opBinding != null && opBinding.isSetEnableMime()) {
                enableMime = opBinding.isEnableMime();
            }
            if (jaxwsBinding.isEnableMime() || enableMime) {
                jm.setMimeEnable(true);
            }
            if ((jm.isWrapperStyle() && headerType > this.noHEADER) || !jaxwsBinding.isEnableWrapperStyle() || (jm.enableMime() && jm.isWrapperStyle()) || !enableWrapperStyle) {
                // changed wrapper style
                jm.setWrapperStyle(false);
                processor.processMethod(jm, bop.getOperationInfo());
                jm.getAnnotationMap().remove("ResponseWrapper");
                jm.getAnnotationMap().remove("RequestWrapper");
            } else {
                processor.processMethod(jm, bop.getOperationInfo());
            }
            if (headerType == this.resultHeader) {
                JAnnotation resultAnno = jm.getAnnotationMap().get("WebResult");
                if (resultAnno != null) {
                    resultAnno.addElement(new JAnnotationElement("header", true, true));
                }
            }
            processParameter(jm, bop);
        }
    }
}
Also used : BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) OperationInfo(org.apache.cxf.service.model.OperationInfo) JavaInterface(org.apache.cxf.tools.common.model.JavaInterface) Message(org.apache.cxf.common.i18n.Message) JAnnotation(org.apache.cxf.tools.common.model.JAnnotation) JAnnotationElement(org.apache.cxf.tools.common.model.JAnnotationElement) Message(org.apache.cxf.common.i18n.Message) SoapBinding(org.apache.cxf.binding.soap.wsdl.extensions.SoapBinding) JavaMethod(org.apache.cxf.tools.common.model.JavaMethod) JAXWSBinding(org.apache.cxf.tools.wsdlto.frontend.jaxws.customization.JAXWSBinding) ToolException(org.apache.cxf.tools.common.ToolException)

Example 55 with OperationInfo

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

the class RequestWrapperTest method testBuildRequestFields.

@Test
public void testBuildRequestFields() {
    // Test String[]
    Class<?> testingClass = GreeterArray.class;
    OperationInfo opInfo = getOperation(testingClass, "sayStringArray");
    assertNotNull(opInfo);
    RequestWrapper requestWrapper = new RequestWrapper();
    MessageInfo message = opInfo.getUnwrappedOperation().getInput();
    Method method = (Method) opInfo.getProperty("operation.method");
    List<JavaField> fields = requestWrapper.buildFields(method, message);
    assertEquals(1, fields.size());
    JavaField field = fields.get(0);
    assertEquals("arg0", field.getName());
    assertEquals("String[]", field.getType());
    // Test int[]
    opInfo = getOperation(testingClass, "sayIntArray");
    assertNotNull(opInfo);
    message = opInfo.getUnwrappedOperation().getInput();
    method = (Method) opInfo.getProperty("operation.method");
    fields = requestWrapper.buildFields(method, message);
    assertEquals(1, fields.size());
    field = fields.get(0);
    assertEquals("arg0", field.getName());
    assertEquals("int[]", field.getType());
    // Test TestDataBean[]
    opInfo = getOperation(testingClass, "sayTestDataBeanArray");
    assertNotNull(opInfo);
    message = opInfo.getUnwrappedOperation().getInput();
    method = (Method) opInfo.getProperty("operation.method");
    fields = requestWrapper.buildFields(method, message);
    assertEquals(1, fields.size());
    field = fields.get(0);
    assertEquals("arg0", field.getName());
    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) JavaMethod(org.apache.cxf.tools.common.model.JavaMethod) Method(java.lang.reflect.Method) MessageInfo(org.apache.cxf.service.model.MessageInfo) Test(org.junit.Test)

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