Search in sources :

Example 1 with RequestWrapper

use of javax.xml.ws.RequestWrapper in project camel by apache.

the class ServiceInterfaceStrategy method getInInfo.

private List<TypeInfo> getInInfo(Method method) {
    List<TypeInfo> typeInfos = new ArrayList<TypeInfo>();
    RequestWrapper requestWrapper = method.getAnnotation(RequestWrapper.class);
    // parameter types are returned in declaration order
    Class<?>[] types = method.getParameterTypes();
    if (types.length == 0) {
        return typeInfos;
    }
    if (requestWrapper != null && requestWrapper.className() != null) {
        typeInfos.add(new TypeInfo(requestWrapper.className(), new QName(requestWrapper.targetNamespace(), requestWrapper.localName())));
        return typeInfos;
    }
    // annotations are returned in declaration order
    Annotation[][] annotations = method.getParameterAnnotations();
    List<WebParam> webParams = new ArrayList<WebParam>();
    for (Annotation[] singleParameterAnnotations : annotations) {
        for (Annotation annotation : singleParameterAnnotations) {
            if (annotation instanceof WebParam) {
                webParams.add((WebParam) annotation);
            }
        }
    }
    if (webParams.size() != types.length) {
        throw new IllegalArgumentException("The number of @WebParam annotations for Method " + method.getName() + " does not match the number of parameters. This is not supported.");
    }
    Iterator<WebParam> webParamIter = webParams.iterator();
    int paramCounter = -1;
    while (webParamIter.hasNext()) {
        WebParam webParam = webParamIter.next();
        typeInfos.add(new TypeInfo(types[++paramCounter].getName(), new QName(webParam.targetNamespace(), webParam.name())));
    }
    return typeInfos;
}
Also used : QName(javax.xml.namespace.QName) ArrayList(java.util.ArrayList) Annotation(java.lang.annotation.Annotation) WebParam(javax.jws.WebParam) RequestWrapper(javax.xml.ws.RequestWrapper)

Example 2 with RequestWrapper

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

the class JaxWsServiceConfiguration method getRequestWrapperPartName.

@Override
public String getRequestWrapperPartName(OperationInfo op, Method method) {
    method = getDeclaredMethod(method);
    RequestWrapper rw = method.getAnnotation(RequestWrapper.class);
    if (rw != null) {
        return getWithReflection(RequestWrapper.class, rw, "partName");
    }
    return null;
}
Also used : RequestWrapper(javax.xml.ws.RequestWrapper)

Example 3 with RequestWrapper

use of javax.xml.ws.RequestWrapper 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 4 with RequestWrapper

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

the class JaxWsServiceConfiguration method getRequestWrapper.

@Override
public Class<?> getRequestWrapper(Method selected) {
    if (this.requestMethodClassNotFoundCache.contains(selected)) {
        return null;
    }
    Class<?> cachedClass = requestMethodClassCache.get(selected);
    if (cachedClass != null) {
        return cachedClass;
    }
    Method m = getDeclaredMethod(selected);
    RequestWrapper rw = m.getAnnotation(RequestWrapper.class);
    String clsName = "";
    if (rw == null) {
        clsName = getPackageName(selected) + ".jaxws." + StringUtils.capitalize(selected.getName());
    } else {
        clsName = rw.className();
    }
    if (clsName.length() > 0) {
        cachedClass = requestMethodClassCache.get(clsName);
        if (cachedClass != null) {
            requestMethodClassCache.put(selected, cachedClass);
            return cachedClass;
        }
        try {
            Class<?> r = ClassLoaderUtils.loadClass(clsName, implInfo.getEndpointClass());
            requestMethodClassCache.put(clsName, r);
            requestMethodClassCache.put(selected, r);
            if (m.getParameterTypes().length == 1 && r.equals(m.getParameterTypes()[0])) {
                LOG.log(Level.WARNING, "INVALID_REQUEST_WRAPPER", new Object[] { clsName, m.getParameterTypes()[0].getName() });
            }
            return r;
        } catch (ClassNotFoundException e) {
        // do nothing, we will mock a schema for wrapper bean later on
        }
    }
    requestMethodClassNotFoundCache.add(selected);
    return null;
}
Also used : RequestWrapper(javax.xml.ws.RequestWrapper) Method(java.lang.reflect.Method) WebMethod(javax.jws.WebMethod)

Example 5 with RequestWrapper

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

the class CodeGenTest method testExtensionWrapper.

@Test
public void testExtensionWrapper() throws Exception {
    env.put(ToolConstants.CFG_WSDLURL, getLocation("/wsdl2java_wsdl/cxf2193/hello_world_extension_wrapped.wsdl"));
    processor.setContext(env);
    processor.execute();
    File infFile = new File(output, "org/apache/cxf/w2j/extension_wrapped/Greeter.java");
    assertTrue(infFile.exists());
    Class<?> interfaceClass = classLoader.loadClass("org.apache.cxf.w2j.extension_wrapped.Greeter");
    Method method = interfaceClass.getMethod("greetMe", new Class[] { Holder.class, Holder.class, Holder.class, Holder.class, Holder.class });
    assertTrue("greetMe operation is NOT generated correctly as excepted", method != null);
    RequestWrapper reqWrapper = method.getAnnotation(RequestWrapper.class);
    assertNotNull("@RequestWrapper is expected", reqWrapper);
}
Also used : RequestWrapper(javax.xml.ws.RequestWrapper) Method(java.lang.reflect.Method) WebMethod(javax.jws.WebMethod) File(java.io.File) AbstractCodeGenTest(org.apache.cxf.tools.wsdlto.AbstractCodeGenTest) Test(org.junit.Test)

Aggregations

RequestWrapper (javax.xml.ws.RequestWrapper)49 Action (javax.xml.ws.Action)41 MessageContext (javax.xml.ws.handler.MessageContext)41 MAP (org.jboss.ws.api.addressing.MAP)41 SoapFault11 (com.arjuna.webservices11.SoapFault11)38 CoordinationContextType (org.oasis_open.docs.ws_tx.wscoor._2006._06.CoordinationContextType)38 WebMethod (javax.jws.WebMethod)9 Method (java.lang.reflect.Method)6 Oneway (javax.jws.Oneway)4 File (java.io.File)3 AbstractCodeGenTest (org.apache.cxf.tools.wsdlto.AbstractCodeGenTest)3 Test (org.junit.Test)3 ObjectStreamClass (java.io.ObjectStreamClass)2 WebParam (javax.jws.WebParam)2 WebResult (javax.jws.WebResult)2 WebService (javax.jws.WebService)2 QName (javax.xml.namespace.QName)2 ResponseWrapper (javax.xml.ws.ResponseWrapper)2 Annotation (java.lang.annotation.Annotation)1 ArrayList (java.util.ArrayList)1