use of javax.jws.WebMethod in project cxf by apache.
the class CodeGenTest method testHelloWorldSoap12.
@Test
public void testHelloWorldSoap12() throws Exception {
env.put(ToolConstants.CFG_WSDLURL, getLocation("/wsdl2java_wsdl/hello_world_soap12.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 helloworldsoaphttp = new File(w2j, "hello_world_soap12_http");
assertTrue(helloworldsoaphttp.exists());
File types = new File(helloworldsoaphttp, "types");
assertTrue(types.exists());
File[] files = helloworldsoaphttp.listFiles();
assertEquals(5, files.length);
files = types.listFiles();
assertEquals(7, files.length);
Class<?> clz = classLoader.loadClass("org.apache.cxf.w2j.hello_world_soap12_http.Greeter");
assertTrue("class " + clz.getName() + " modifier is not public", Modifier.isPublic(clz.getModifiers()));
assertTrue("class " + clz.getName() + " modifier is interface", Modifier.isInterface(clz.getModifiers()));
WebService webServiceAnn = AnnotationUtil.getPrivClassAnnotation(clz, WebService.class);
assertEquals("Greeter", webServiceAnn.name());
Method method = clz.getMethod("sayHi", new Class[] {});
WebMethod webMethodAnno = AnnotationUtil.getPrivMethodAnnotation(method, WebMethod.class);
if (webMethodAnno.operationName() != null && !"".equals(webMethodAnno.operationName())) {
assertEquals(method.getName() + "()" + " Annotation : WebMethod.operationName ", "sayHi", webMethodAnno.operationName());
}
RequestWrapper requestWrapperAnn = AnnotationUtil.getPrivMethodAnnotation(method, RequestWrapper.class);
assertEquals("org.apache.cxf.w2j.hello_world_soap12_http.types.SayHi", requestWrapperAnn.className());
ResponseWrapper resposneWrapperAnn = AnnotationUtil.getPrivMethodAnnotation(method, ResponseWrapper.class);
assertEquals("sayHiResponse", resposneWrapperAnn.localName());
WebResult webResultAnno = AnnotationUtil.getPrivMethodAnnotation(method, WebResult.class);
assertEquals("responseType", webResultAnno.name());
method = clz.getMethod("pingMe", new Class[] {});
webMethodAnno = AnnotationUtil.getPrivMethodAnnotation(method, WebMethod.class);
if (webMethodAnno.operationName() != null && !"".equals(webMethodAnno.operationName())) {
assertEquals(method.getName() + "()" + " Annotation : WebMethod.operationName ", "pingMe", webMethodAnno.operationName());
}
Class<?>[] exceptionCls = method.getExceptionTypes();
assertEquals(1, exceptionCls.length);
assertEquals("org.apache.cxf.w2j.hello_world_soap12_http.PingMeFault", exceptionCls[0].getName());
}
use of javax.jws.WebMethod in project cxf by apache.
the class CodeGenTest method testAsyncMethodNoService.
@Test
public void testAsyncMethodNoService() throws Exception {
env.put(ToolConstants.CFG_WSDLURL, getLocation("/wsdl2java_wsdl/hello_world_async_noservice.wsdl"));
// no binding so all the tests that check bindings fail
env.remove(ToolConstants.CFG_VALIDATE_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(Arrays.asList(files).toString(), 9, 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());
method1 = clz.getMethod("greetMeSometimeAsync", new Class[] { java.lang.String.class, javax.xml.ws.AsyncHandler.class });
try {
method1 = clz.getMethod("testIntAsync", new Class[] { Integer.TYPE, javax.xml.ws.AsyncHandler.class });
fail("Should not have generated testIntAsync");
} catch (NoSuchMethodException ex) {
// ignore
}
clz = classLoader.loadClass("org.apache.cxf.w2j.hello_world_async_soap_http.GreeterDAsync");
method1 = clz.getMethod("greetMeSometimeAsync", new Class[] { java.lang.String.class, javax.xml.ws.AsyncHandler.class });
clz = classLoader.loadClass("org.apache.cxf.w2j.hello_world_async_soap_http.GreeterCAsync");
try {
method1 = clz.getMethod("greetMeSometimeAsync", new Class[] { java.lang.String.class, javax.xml.ws.AsyncHandler.class });
fail("Should not have generated greetMeSometimeAsync");
} catch (NoSuchMethodException ex) {
// ignore
}
method1 = clz.getMethod("testIntAsync", new Class[] { Integer.TYPE, javax.xml.ws.AsyncHandler.class });
clz = classLoader.loadClass("org.apache.cxf.w2j.hello_world_async_soap_http.GreeterBAsync");
try {
method1 = clz.getMethod("greetMeSometimeAsync", new Class[] { java.lang.String.class, javax.xml.ws.AsyncHandler.class });
fail("Should not have generated greetMeSometimeAsync");
} catch (NoSuchMethodException ex) {
// ignore
}
method1 = clz.getMethod("testIntAsync", new Class[] { Integer.TYPE, javax.xml.ws.AsyncHandler.class });
}
use of javax.jws.WebMethod in project cxf by apache.
the class FrontendFactory method isJAXWSAnnotationExists.
private boolean isJAXWSAnnotationExists() {
for (Method method : wsMethods) {
if (WrapperUtil.isWrapperClassExists(method)) {
return true;
}
WebMethod m = AnnotationUtil.getPrivMethodAnnotation(method, WebMethod.class);
if (m != null) {
return true;
}
WebResult res = AnnotationUtil.getPrivMethodAnnotation(method, WebResult.class);
if (res != null) {
return true;
}
}
return false;
}
use of javax.jws.WebMethod in project cxf by apache.
the class DOCBareClientServerTest method testAnnotation.
@Test
public void testAnnotation() throws Exception {
Class<PutLastTradedPricePortType> claz = PutLastTradedPricePortType.class;
TradePriceData priceData = new TradePriceData();
Holder<TradePriceData> holder = new Holder<TradePriceData>(priceData);
Method method = claz.getMethod("sayHi", holder.getClass());
assertNotNull("Can not find SayHi method in generated class ", method);
Annotation ann = method.getAnnotation(WebMethod.class);
WebMethod webMethod = (WebMethod) ann;
assertEquals(webMethod.operationName(), "SayHi");
Annotation[][] paraAnns = method.getParameterAnnotations();
for (Annotation[] paraType : paraAnns) {
for (Annotation an : paraType) {
if (an.annotationType() == WebParam.class) {
WebParam webParam = (WebParam) an;
assertNotSame("", webParam.targetNamespace());
}
}
}
}
use of javax.jws.WebMethod in project cxf by apache.
the class CustomerService method getCustomer.
@WebMethod
@WebResult(name = "customer")
public Customer getCustomer(@WebParam(name = "getCustomer") GetCustomer getCustomer) throws CustomerNotFoundFault {
Customer c = customers.get(getCustomer.getId());
if (c == null) {
CustomerNotFoundDetails details = new CustomerNotFoundDetails();
details.setId(getCustomer.getId());
throw new CustomerNotFoundFault(details);
}
return c;
}
Aggregations