Search in sources :

Example 16 with WebParam

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

the class CodeGenTest method testDocLitHolder.

@Test
public void testDocLitHolder() throws Exception {
    env.put(ToolConstants.CFG_WSDLURL, getLocation("/wsdl2java_wsdl/mapping-doc-literal.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 mapping = new File(apache, "mapping");
    assertTrue(mapping.exists());
    File[] files = mapping.listFiles();
    assertEquals(9, files.length);
    Class<?> clz = classLoader.loadClass("org.apache.mapping.SomethingServer");
    Method method = clz.getMethod("doSomething", new Class[] { int.class, javax.xml.ws.Holder.class, javax.xml.ws.Holder.class });
    assertEquals("boolean", method.getReturnType().getSimpleName());
    WebParam webParamAnno = AnnotationUtil.getWebParam(method, "y");
    assertEquals("INOUT", webParamAnno.mode().name());
    webParamAnno = AnnotationUtil.getWebParam(method, "z");
    assertEquals("OUT", webParamAnno.mode().name());
}
Also used : WebParam(javax.jws.WebParam) Method(java.lang.reflect.Method) WebMethod(javax.jws.WebMethod) File(java.io.File) AbstractCodeGenTest(org.apache.cxf.tools.wsdlto.AbstractCodeGenTest) Test(org.junit.Test)

Example 17 with WebParam

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

the class JaxWsServiceConfiguration method isInParam.

@Override
public Boolean isInParam(Method method, int j) {
    if (j < 0) {
        return Boolean.FALSE;
    }
    method = getDeclaredMethod(method);
    WebParam webParam = getWebParam(method, j);
    return webParam == null || (webParam.mode().equals(Mode.IN) || webParam.mode().equals(Mode.INOUT));
}
Also used : WebParam(javax.jws.WebParam)

Example 18 with WebParam

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

the class JaxWsServiceConfiguration method isHeader.

@Override
public Boolean isHeader(Method method, int j) {
    method = getDeclaredMethod(method);
    if (j >= 0) {
        WebParam webParam = getWebParam(method, j);
        return webParam != null && webParam.header();
    }
    WebResult webResult = getWebResult(method);
    return webResult != null && webResult.header();
}
Also used : WebParam(javax.jws.WebParam) WebResult(javax.jws.WebResult)

Example 19 with WebParam

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

the class JaxWsServiceConfiguration method getWebParam.

private WebParam getWebParam(Method method, int parameter) {
    // we could really use a centralized location for this.
    Annotation[][] annotations = methodAnnotationCache.get(method);
    if (annotations == null) {
        annotations = method.getParameterAnnotations();
        methodAnnotationCache.put(method, annotations);
    }
    if (parameter >= annotations.length) {
        return null;
    }
    for (int i = 0; i < annotations[parameter].length; i++) {
        Annotation annotation = annotations[parameter][i];
        // == operator seems to give the desired result.
        if (annotation instanceof WebParam) {
            return (WebParam) annotation;
        }
    }
    return null;
}
Also used : WebParam(javax.jws.WebParam) Annotation(java.lang.annotation.Annotation)

Example 20 with WebParam

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

the class JaxWsServiceConfiguration method getResponseWrapperPartName.

@Override
public String getResponseWrapperPartName(OperationInfo op, Method method) {
    method = getDeclaredMethod(method);
    WebResult webResult = getWebResult(method);
    ResponseWrapper rw = method.getAnnotation(ResponseWrapper.class);
    if (rw != null) {
        String pn = getWithReflection(ResponseWrapper.class, rw, "partName");
        if (pn != null) {
            return pn;
        }
    }
    int countOut = 0;
    int countHeaders = 0;
    if (webResult != null && webResult.header()) {
        countHeaders++;
    } else if (method.getReturnType() != Void.TYPE) {
        countOut++;
    }
    for (int x = 0; x < method.getParameterTypes().length; x++) {
        WebParam parm = getWebParam(method, x);
        if (parm != null) {
            if (parm.header()) {
                countHeaders++;
            }
            if (parm.mode() != WebParam.Mode.IN) {
                countOut++;
            }
        }
    }
    if (countHeaders > 0 && countOut == 0) {
        // thus return the default for an empty part of "result"
        return "result";
    }
    return null;
}
Also used : WebParam(javax.jws.WebParam) ResponseWrapper(javax.xml.ws.ResponseWrapper) WebResult(javax.jws.WebResult)

Aggregations

WebParam (javax.jws.WebParam)28 Test (org.junit.Test)15 Method (java.lang.reflect.Method)14 WebMethod (javax.jws.WebMethod)12 AbstractCodeGenTest (org.apache.cxf.tools.wsdlto.AbstractCodeGenTest)12 Annotation (java.lang.annotation.Annotation)7 File (java.io.File)5 WebResult (javax.jws.WebResult)5 ArrayList (java.util.ArrayList)4 QName (javax.xml.namespace.QName)4 SOAPBinding (javax.jws.soap.SOAPBinding)3 ObjectStreamClass (java.io.ObjectStreamClass)2 Type (java.lang.reflect.Type)2 Holder (javax.xml.ws.Holder)2 RequestWrapper (javax.xml.ws.RequestWrapper)2 ResponseWrapper (javax.xml.ws.ResponseWrapper)2 MessagePartInfo (org.apache.cxf.service.model.MessagePartInfo)2 JavaField (org.apache.cxf.tools.common.model.JavaField)2 ParameterizedType (java.lang.reflect.ParameterizedType)1 Oneway (javax.jws.Oneway)1