use of javax.jws.WebParam in project cxf by apache.
the class CodeGenTest method testHeaderFromAnotherMessage1.
@Test
public void testHeaderFromAnotherMessage1() throws Exception {
env.put(ToolConstants.CFG_WSDLURL, getLocation("/wsdl2java_wsdl/pizza.wsdl"));
env.put(ToolConstants.CFG_EXTRA_SOAPHEADER, "TRUE");
env.remove(ToolConstants.CFG_VALIDATE_WSDL);
processor.setContext(env);
processor.execute();
assertNotNull(output);
Class<?> clz = classLoader.loadClass("com.mypizzaco.pizza.PizzaPortType");
Method[] meths = clz.getMethods();
for (Method m : meths) {
if ("orderPizzaBroken".equals(m.getName())) {
Annotation[][] annotations = m.getParameterAnnotations();
assertEquals(2, annotations.length);
for (int i = 0; i < 2; i++) {
assertTrue(annotations[i][0] instanceof WebParam);
WebParam parm = (WebParam) annotations[i][0];
if ("OrderPizza".equals(parm.name())) {
assertEquals("http://mypizzaco.com/pizza/types", parm.targetNamespace());
assertEquals("OrderPizza", parm.name());
assertTrue(!parm.header());
} else if ("CallerIDHeader".equals(parm.name())) {
assertEquals("http://mypizzaco.com/pizza/types", parm.targetNamespace());
assertEquals("callerID", parm.partName());
assertEquals("CallerIDHeader", parm.name());
assertTrue(parm.header());
} else {
fail("No WebParam found!");
}
}
}
if ("orderPizza".equals(m.getName())) {
Annotation[][] annotations = m.getParameterAnnotations();
assertEquals(2, annotations.length);
for (int i = 0; i < 2; i++) {
assertTrue(annotations[i][0] instanceof WebParam);
WebParam parm = (WebParam) annotations[i][0];
if ("OrderPizza".equals(parm.name())) {
assertEquals("http://mypizzaco.com/pizza/types", parm.targetNamespace());
assertEquals("OrderPizza", parm.name());
assertTrue(!parm.header());
} else if ("CallerIDHeader".equals(parm.name())) {
assertEquals("http://mypizzaco.com/pizza/types", parm.targetNamespace());
assertEquals("callerID", parm.partName());
assertEquals("CallerIDHeader", parm.name());
assertTrue(parm.header());
} else {
fail("No WebParam found!");
}
}
}
}
}
use of javax.jws.WebParam in project cxf by apache.
the class CodeGenTest method testRPCHeader.
@Test
public void testRPCHeader() throws Exception {
env.put(ToolConstants.CFG_WSDLURL, getLocation("/wsdl2java_wsdl/soapheader_rpc.wsdl"));
// headers must be element, but validation
env.remove(ToolConstants.CFG_VALIDATE_WSDL);
// doesn't fully process the entire soap:binding information to
// to figure out which parts are headers and which are body for rpc/lit
processor.setContext(env);
processor.execute();
Class<?> cls = classLoader.loadClass("org.apache.header_test.rpc.TestRPCHeaderPort");
Method[] meths = cls.getMethods();
for (Method m : meths) {
if ("testHeader1".equals(m.getName())) {
Annotation[][] annotations = m.getParameterAnnotations();
assertEquals(2, annotations.length);
assertEquals(1, annotations[1].length);
assertTrue(annotations[1][0] instanceof WebParam);
WebParam parm = (WebParam) annotations[1][0];
assertEquals("http://apache.org/header_test/rpc/types", parm.targetNamespace());
assertEquals("inHeader", parm.partName());
assertEquals("headerMessage", parm.name());
assertTrue(parm.header());
}
}
for (Method m : meths) {
if ("testInOutHeader".equals(m.getName())) {
Annotation[][] annotations = m.getParameterAnnotations();
assertEquals(2, annotations.length);
assertEquals(1, annotations[1].length);
assertTrue(annotations[1][0] instanceof WebParam);
WebParam parm = (WebParam) annotations[1][0];
assertEquals("http://apache.org/header_test/rpc/types", parm.targetNamespace());
assertEquals("inOutHeader", parm.partName());
assertEquals("headerMessage", parm.name());
assertTrue(parm.header());
}
}
}
use of javax.jws.WebParam in project cxf by apache.
the class CodeGenTest method testCXF1950.
@Test
public void testCXF1950() throws Exception {
env.put(ToolConstants.CFG_WSDLURL, getLocation("/wsdl2java_wsdl/helloworld-noservice-header.wsdl"));
processor.setContext(env);
processor.execute();
File seif = new File(output, "org/apache/cxf/helloworld/HelloWorldServiceImpl.java");
assertTrue(seif.exists());
Class<?> sei = classLoader.loadClass("org.apache.cxf.helloworld.HelloWorldServiceImpl");
Method[] m = sei.getDeclaredMethods();
assertEquals(1, m.length);
assertTrue(m[0].getParameterAnnotations()[1][0] instanceof WebParam);
WebParam wp = (WebParam) m[0].getParameterAnnotations()[1][0];
assertTrue(wp.header());
}
use of javax.jws.WebParam in project cxf by apache.
the class CodeGenTest method testHeaderFromAnotherMessage4.
@Test
public void testHeaderFromAnotherMessage4() throws Exception {
env.put(ToolConstants.CFG_WSDLURL, getLocation("/wsdl2java_wsdl/pizza_wrapped.wsdl"));
env.put(ToolConstants.CFG_EXTRA_SOAPHEADER, "TRUE");
processor.setContext(env);
processor.execute();
assertNotNull(output);
Class<?> clz = classLoader.loadClass("org.apache.cxf.pizza_wrapped.Pizza");
Method[] meths = clz.getMethods();
for (Method m : meths) {
if ("orderPizza".equals(m.getName())) {
Annotation[][] annotations = m.getParameterAnnotations();
assertEquals(2, annotations.length);
for (int i = 0; i < 2; i++) {
assertTrue(annotations[i][0] instanceof WebParam);
WebParam parm = (WebParam) annotations[i][0];
if ("Toppings".equals(parm.name())) {
assertEquals("http://cxf.apache.org/pizza_wrapped/types", parm.targetNamespace());
assertTrue(!parm.header());
} else if ("CallerIDHeader".equals(parm.name())) {
assertEquals("http://cxf.apache.org/pizza_wrapped/types", parm.targetNamespace());
assertTrue(parm.header());
} else {
fail("No WebParam found!");
}
}
}
}
}
use of javax.jws.WebParam 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());
}
}
}
}
Aggregations