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;
}
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;
}
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;
}
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;
}
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);
}
Aggregations