Search in sources :

Example 1 with Action

use of javax.xml.ws.Action in project cxf by apache.

the class JaxWsServiceConfiguration method getAction.

@Override
public String getAction(OperationInfo op, Method method) {
    method = getDeclaredMethod(method);
    WebMethod wm = method.getAnnotation(WebMethod.class);
    String action = "";
    if (wm != null) {
        action = wm.action();
    }
    if (StringUtils.isEmpty(action)) {
        Action act = method.getAnnotation(Action.class);
        if (act != null) {
            action = act.input();
        }
    }
    return action;
}
Also used : WebMethod(javax.jws.WebMethod) Action(javax.xml.ws.Action)

Example 2 with Action

use of javax.xml.ws.Action in project cxf by apache.

the class CodeGenBugTest method testCXF5280.

@Test
public void testCXF5280() throws Exception {
    env.put(ToolConstants.CFG_ALL, "all");
    env.put(ToolConstants.CFG_COMPILE, "compile");
    env.put(ToolConstants.CFG_OUTPUTDIR, output.getCanonicalPath());
    env.put(ToolConstants.CFG_CLASSDIR, output.getCanonicalPath() + "/classes");
    env.put(ToolConstants.CFG_WSDLURL, getLocation("/wsdl2java_wsdl/cxf5280/hello_world.wsdl"));
    processor.setContext(env);
    processor.execute();
    Class<?> pcls = classLoader.loadClass("org.apache.cxf.w2j.hello_world_soap_http.Greeter");
    Class<?> acls = classLoader.loadClass("org.apache.cxf.w2j.hello_world_soap_http.types.GreetMe");
    Method m = pcls.getMethod("greetMe", new Class[] { acls });
    Action actionAnn = AnnotationUtil.getPrivMethodAnnotation(m, Action.class);
    assertNotNull(actionAnn);
    assertEquals("http://cxf.apache.org/w2j/hello_world_soap_http/greetMe", actionAnn.input());
}
Also used : Action(javax.xml.ws.Action) Method(java.lang.reflect.Method) AbstractCodeGenTest(org.apache.cxf.tools.wsdlto.AbstractCodeGenTest) Test(org.junit.Test)

Example 3 with Action

use of javax.xml.ws.Action in project cxf by apache.

the class JaxWsServiceFactoryBean method buildWSAActions.

private void buildWSAActions(OperationInfo operation, Method method) {
    // nothing
    if (method == null) {
        return;
    }
    Action action = method.getAnnotation(Action.class);
    Addressing addressing = method.getDeclaringClass().getAnnotation(Addressing.class);
    if (action == null && addressing == null) {
        return;
    }
    WebMethod wm = method.getAnnotation(WebMethod.class);
    String inputAction = "";
    if (action != null) {
        inputAction = action.input();
    }
    if (wm != null && StringUtils.isEmpty(inputAction)) {
        inputAction = wm.action();
    }
    if (StringUtils.isEmpty(inputAction)) {
        inputAction = computeAction(operation, "Request");
    }
    if (action == null && addressing != null) {
        operation.getInput().addExtensionAttribute(JAXWSAConstants.WSAM_ACTION_QNAME, inputAction);
        operation.getInput().addExtensionAttribute(JAXWSAConstants.WSAW_ACTION_QNAME, inputAction);
        if (operation.getOutput() != null) {
            operation.getOutput().addExtensionAttribute(JAXWSAConstants.WSAM_ACTION_QNAME, computeAction(operation, "Response"));
            operation.getOutput().addExtensionAttribute(JAXWSAConstants.WSAW_ACTION_QNAME, computeAction(operation, "Response"));
        }
    } else {
        MessageInfo input = operation.getInput();
        input.addExtensionAttribute(JAXWSAConstants.WSAM_ACTION_QNAME, inputAction);
        if (!StringUtils.isEmpty(action.input())) {
            input.addExtensionAttribute(JAXWSAConstants.WSAW_ACTION_QNAME, inputAction);
        }
        MessageInfo output = operation.getOutput();
        if (output != null && !StringUtils.isEmpty(action.output())) {
            output.addExtensionAttribute(JAXWSAConstants.WSAW_ACTION_QNAME, action.output());
            output.addExtensionAttribute(JAXWSAConstants.WSAM_ACTION_QNAME, action.output());
        } else if (output != null) {
            output.addExtensionAttribute(JAXWSAConstants.WSAM_ACTION_QNAME, computeAction(operation, "Response"));
        }
        FaultAction[] faultActions = action.fault();
        if (faultActions != null && faultActions.length > 0 && operation.getFaults() != null) {
            for (FaultAction faultAction : faultActions) {
                FaultInfo faultInfo = getFaultInfo(operation, faultAction.className());
                if (faultInfo != null && !StringUtils.isEmpty(faultAction.value())) {
                    faultInfo.addExtensionAttribute(JAXWSAConstants.WSAW_ACTION_QNAME, faultAction.value());
                    faultInfo.addExtensionAttribute(JAXWSAConstants.WSAM_ACTION_QNAME, faultAction.value());
                }
                if (operation.isUnwrappedCapable()) {
                    faultInfo = getFaultInfo(operation.getUnwrappedOperation(), faultAction.className());
                    if (faultInfo != null && !StringUtils.isEmpty(faultAction.value())) {
                        faultInfo.addExtensionAttribute(JAXWSAConstants.WSAW_ACTION_QNAME, faultAction.value());
                        faultInfo.addExtensionAttribute(JAXWSAConstants.WSAM_ACTION_QNAME, faultAction.value());
                    }
                }
            }
        }
    }
    for (FaultInfo fi : operation.getFaults()) {
        if (fi.getExtensionAttribute(JAXWSAConstants.WSAM_ACTION_QNAME) == null) {
            String f = "/Fault/" + fi.getName().getLocalPart();
            fi.addExtensionAttribute(JAXWSAConstants.WSAM_ACTION_QNAME, computeAction(operation, f));
            if (operation.isUnwrappedCapable()) {
                fi = operation.getUnwrappedOperation().getFault(fi.getName());
                fi.addExtensionAttribute(JAXWSAConstants.WSAM_ACTION_QNAME, computeAction(operation, f));
            }
        }
    }
}
Also used : WebMethod(javax.jws.WebMethod) FaultAction(javax.xml.ws.FaultAction) Action(javax.xml.ws.Action) FaultAction(javax.xml.ws.FaultAction) FaultInfo(org.apache.cxf.service.model.FaultInfo) Addressing(javax.xml.ws.soap.Addressing) MessageInfo(org.apache.cxf.service.model.MessageInfo)

Aggregations

Action (javax.xml.ws.Action)3 WebMethod (javax.jws.WebMethod)2 Method (java.lang.reflect.Method)1 FaultAction (javax.xml.ws.FaultAction)1 Addressing (javax.xml.ws.soap.Addressing)1 FaultInfo (org.apache.cxf.service.model.FaultInfo)1 MessageInfo (org.apache.cxf.service.model.MessageInfo)1 AbstractCodeGenTest (org.apache.cxf.tools.wsdlto.AbstractCodeGenTest)1 Test (org.junit.Test)1