Search in sources :

Example 11 with WebMethod

use of javax.jws.WebMethod 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 12 with WebMethod

use of javax.jws.WebMethod in project cxf by apache.

the class JaxWsServiceConfiguration method getRequestWrapperName.

@Override
public QName getRequestWrapperName(OperationInfo op, Method method) {
    Method m = getDeclaredMethod(method);
    RequestWrapper rw = m.getAnnotation(RequestWrapper.class);
    String nm = null;
    String lp = null;
    if (rw != null) {
        nm = rw.targetNamespace();
        lp = rw.localName();
    }
    WebMethod meth = m.getAnnotation(WebMethod.class);
    if (meth != null && StringUtils.isEmpty(lp)) {
        lp = meth.operationName();
    }
    if (StringUtils.isEmpty(nm)) {
        nm = op.getName().getNamespaceURI();
    }
    if (!StringUtils.isEmpty(nm) && !StringUtils.isEmpty(lp)) {
        return new QName(nm, lp);
    }
    return null;
}
Also used : WebMethod(javax.jws.WebMethod) QName(javax.xml.namespace.QName) RequestWrapper(javax.xml.ws.RequestWrapper) Method(java.lang.reflect.Method) WebMethod(javax.jws.WebMethod)

Example 13 with WebMethod

use of javax.jws.WebMethod in project cxf by apache.

the class JaxWsServiceConfiguration method isOperation.

@Override
public Boolean isOperation(final Method method) {
    if (Object.class.equals(method.getDeclaringClass())) {
        return false;
    }
    if (method.getDeclaringClass() == implInfo.getSEIClass()) {
        WebMethod wm = method.getAnnotation(WebMethod.class);
        if (wm != null && wm.exclude()) {
            Message message = new Message("WEBMETHOD_EXCLUDE_NOT_ALLOWED", LOG, method.getName());
            throw new JaxWsConfigurationException(message);
        }
    }
    Class<?> implClz = implInfo.getImplementorClass();
    Method m = getDeclaredMethod(implClz, method);
    if (m != null) {
        WebMethod wm = m.getAnnotation(WebMethod.class);
        if (wm != null && wm.exclude()) {
            return Boolean.FALSE;
        }
    }
    if (isWebMethod(m)) {
        return true;
    }
    return isWebMethod(getDeclaredMethod(method));
}
Also used : WebMethod(javax.jws.WebMethod) JaxWsConfigurationException(org.apache.cxf.jaxws.JaxWsConfigurationException) Message(org.apache.cxf.common.i18n.Message) Method(java.lang.reflect.Method) WebMethod(javax.jws.WebMethod)

Example 14 with WebMethod

use of javax.jws.WebMethod in project cxf by apache.

the class JaxWsServiceConfiguration method isWebMethod.

public Boolean isWebMethod(final Method method) {
    if (method == null || method.getReturnType().equals(Future.class) || method.getReturnType().equals(Response.class) || method.isSynthetic()) {
        return Boolean.FALSE;
    }
    WebMethod wm = method.getAnnotation(WebMethod.class);
    Class<?> cls = method.getDeclaringClass();
    if ((wm != null) && wm.exclude()) {
        return Boolean.FALSE;
    }
    if ((wm != null && !wm.exclude()) || (implInfo.getSEIClass() != null && cls.isInterface() && cls.isAssignableFrom(implInfo.getSEIClass()))) {
        return Boolean.TRUE;
    }
    if (method.getDeclaringClass().isInterface()) {
        return hasWebServiceAnnotation(method);
    }
    if (implInfo.getSEIClass() == null) {
        return hasWebServiceAnnotation(method) && !Modifier.isFinal(method.getModifiers()) && !Modifier.isStatic(method.getModifiers());
    }
    return implInfo.getSEIClass().isAssignableFrom(method.getDeclaringClass());
}
Also used : WebMethod(javax.jws.WebMethod) Future(java.util.concurrent.Future)

Example 15 with WebMethod

use of javax.jws.WebMethod in project cxf by apache.

the class CodeGenTest method testAsyncMethod.

@Test
public void testAsyncMethod() throws Exception {
    env.put(ToolConstants.CFG_WSDLURL, getLocation("/wsdl2java_wsdl/hello_world_async.wsdl"));
    processor.setContext(env);
    processor.execute();
    assertNotNull(output);
    File org = new File(output, "org");
    assertTrue(org.exists());
    File apache = new File(org, "apache");
    assertTrue(apache.exists());
    File cxf = new File(apache, "cxf");
    assertTrue(cxf.exists());
    File w2j = new File(cxf, "w2j");
    assertTrue(w2j.exists());
    File async = new File(w2j, "hello_world_async_soap_http");
    assertTrue(async.exists());
    File[] files = async.listFiles();
    assertEquals(4, files.length);
    Class<?> clz = classLoader.loadClass("org.apache.cxf.w2j.hello_world_async_soap_http.GreeterAsync");
    Method method1 = clz.getMethod("greetMeSometimeAsync", new Class[] { java.lang.String.class, javax.xml.ws.AsyncHandler.class });
    WebMethod webMethodAnno1 = AnnotationUtil.getPrivMethodAnnotation(method1, WebMethod.class);
    assertEquals(method1.getName() + "()" + " Annotation : WebMethod.operationName ", "greetMeSometime", webMethodAnno1.operationName());
    java.lang.reflect.Method method2 = clz.getMethod("greetMeSometimeAsync", new Class[] { java.lang.String.class });
    WebMethod webMethodAnno2 = AnnotationUtil.getPrivMethodAnnotation(method2, WebMethod.class);
    assertEquals(method2.getName() + "()" + " Annotation : WebMethod.operationName ", "greetMeSometime", webMethodAnno2.operationName());
}
Also used : WebMethod(javax.jws.WebMethod) Method(java.lang.reflect.Method) WebMethod(javax.jws.WebMethod) File(java.io.File) Method(java.lang.reflect.Method) AbstractCodeGenTest(org.apache.cxf.tools.wsdlto.AbstractCodeGenTest) Test(org.junit.Test)

Aggregations

WebMethod (javax.jws.WebMethod)48 Method (java.lang.reflect.Method)13 WebResult (javax.jws.WebResult)12 Test (org.junit.Test)7 File (java.io.File)6 IOException (java.io.IOException)6 AbstractCodeGenTest (org.apache.cxf.tools.wsdlto.AbstractCodeGenTest)6 ActionExecutionException (com.axway.ats.agent.core.exceptions.ActionExecutionException)5 AgentException (com.axway.ats.agent.core.exceptions.AgentException)5 InternalComponentException (com.axway.ats.agent.core.exceptions.InternalComponentException)5 NoCompatibleMethodFoundException (com.axway.ats.agent.core.exceptions.NoCompatibleMethodFoundException)5 NoSuchActionException (com.axway.ats.agent.core.exceptions.NoSuchActionException)5 NoSuchComponentException (com.axway.ats.agent.core.exceptions.NoSuchComponentException)5 Path (javax.ws.rs.Path)5 ServiceException (com.netsteadfast.greenstep.base.exception.ServiceException)4 QName (javax.xml.namespace.QName)4 ByteArrayOutputStream (java.io.ByteArrayOutputStream)3 ObjectOutputStream (java.io.ObjectOutputStream)3 ArrayList (java.util.ArrayList)3 GET (javax.ws.rs.GET)3