Search in sources :

Example 11 with WebResult

use of javax.jws.WebResult 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 12 with WebResult

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

the class CustomerService method getCustomers.

@WebMethod
@WebResult(name = "customers")
public Customers getCustomers(@WebParam(name = "GetCustomers") GetCustomers req) {
    Customers cbean = new Customers();
    cbean.setCustomer(customers.values());
    if (context == null || context.getMessageContext() == null) {
        throw new WebServiceException("WebServiceContext is null!");
    }
    return cbean;
}
Also used : WebServiceException(javax.xml.ws.WebServiceException) Customers(org.apache.cxf.customer.Customers) WebMethod(javax.jws.WebMethod) WebResult(javax.jws.WebResult)

Example 13 with WebResult

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

the class CodeGenBugTest method testCXF2944.

@Test
public void testCXF2944() throws Exception {
    env.put(ToolConstants.CFG_WSDLURL, getLocation("/wsdl2java_wsdl/cxf2944/cxf2944.wsdl"));
    env.put(ToolConstants.CFG_ALLOW_ELEMENT_REFS, "true");
    processor.setContext(env);
    processor.execute();
    Class<?> clz = classLoader.loadClass("org.apache.cxf.tools.fortest.cxf2944.WebResultService");
    WebResult webResult = AnnotationUtil.getWebResult(clz.getMethods()[0]);
    assertEquals("hello/name", webResult.targetNamespace());
    assertEquals("name", webResult.name());
}
Also used : WebResult(javax.jws.WebResult) AbstractCodeGenTest(org.apache.cxf.tools.wsdlto.AbstractCodeGenTest) Test(org.junit.Test)

Example 14 with WebResult

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

the class CodeGenTest method testRefTNS.

@Test
public void testRefTNS() throws Exception {
    env.put(ToolConstants.CFG_WSDLURL, getLocation("/wsdl2java_wsdl/locator.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 locator = new File(apache, "locator");
    assertTrue(locator.exists());
    File locatorService = new File(locator, "LocatorService.java");
    assertTrue(locatorService.exists());
    Class<?> clz = classLoader.loadClass("org.apache.locator.LocatorService");
    Class<?> paraClass = classLoader.loadClass("org.apache.locator.types.QueryEndpoints");
    Method method = clz.getMethod("queryEndpoints", new Class[] { paraClass });
    WebResult webRes = AnnotationUtil.getPrivMethodAnnotation(method, WebResult.class);
    assertEquals("http://apache.org/locator/types", webRes.targetNamespace());
    assertEquals("queryEndpointsResponse", webRes.name());
    WebParam webParamAnn = AnnotationUtil.getWebParam(method, "queryEndpoints");
    assertEquals("http://apache.org/locator/types", webParamAnn.targetNamespace());
    method = clz.getMethod("deregisterPeerManager", new Class[] { String.class });
    webParamAnn = AnnotationUtil.getWebParam(method, "node_id");
    assertEquals("", webParamAnn.targetNamespace());
}
Also used : WebParam(javax.jws.WebParam) ObjectStreamClass(java.io.ObjectStreamClass) Method(java.lang.reflect.Method) WebMethod(javax.jws.WebMethod) WebResult(javax.jws.WebResult) File(java.io.File) AbstractCodeGenTest(org.apache.cxf.tools.wsdlto.AbstractCodeGenTest) Test(org.junit.Test)

Example 15 with WebResult

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

the class CodeGenTest method testHelloWorld.

@Test
public void testHelloWorld() throws Exception {
    env.put(ToolConstants.CFG_WSDLURL, getLocation("/wsdl2java_wsdl/hello_world.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_soap_http");
    assertTrue(helloworldsoaphttp.exists());
    File types = new File(helloworldsoaphttp, "types");
    assertTrue(types.exists());
    File[] files = helloworldsoaphttp.listFiles();
    assertEquals(9, files.length);
    files = types.listFiles();
    assertEquals(17, files.length);
    Class<?> clz = classLoader.loadClass("org.apache.cxf.w2j.hello_world_soap_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_soap_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("greetMe", new Class[] { String.class });
    assertEquals("String", method.getReturnType().getSimpleName());
    WebParam webParamAnn = AnnotationUtil.getWebParam(method, "requestType");
    // if is wrapped, tns should be empty
    assertEquals("http://cxf.apache.org/w2j/hello_world_soap_http/types", webParamAnn.targetNamespace());
    // assertEquals("", webParamAnn.targetNamespace());
    method = clz.getMethod("greetMeOneWay", new Class[] { String.class });
    Oneway oneWayAnn = AnnotationUtil.getPrivMethodAnnotation(method, Oneway.class);
    assertNotNull("OneWay Annotation is not generated", oneWayAnn);
    assertEquals("void", method.getReturnType().getSimpleName());
    method = clz.getMethod("greetMeSometime", new Class[] { String.class });
    assertEquals("String", method.getReturnType().getSimpleName());
    method = clz.getMethod("testDocLitFault", new Class[] { java.lang.String.class });
    assertEquals("void", method.getReturnType().getSimpleName());
    assertEquals("Exception class is not generated ", 2, method.getExceptionTypes().length);
    method = clz.getMethod("testDocLitBare", new Class[] { java.lang.String.class });
    webResultAnno = AnnotationUtil.getPrivMethodAnnotation(method, WebResult.class);
    assertEquals("out", webResultAnno.partName());
    SOAPBinding soapBindingAnno = AnnotationUtil.getPrivMethodAnnotation(method, SOAPBinding.class);
    assertNotNull(soapBindingAnno);
    assertEquals(SOAPBinding.ParameterStyle.BARE, soapBindingAnno.parameterStyle());
    assertEquals("BareDocumentResponse", method.getReturnType().getSimpleName());
}
Also used : WebService(javax.jws.WebService) Oneway(javax.jws.Oneway) ResponseWrapper(javax.xml.ws.ResponseWrapper) SOAPBinding(javax.jws.soap.SOAPBinding) Method(java.lang.reflect.Method) WebMethod(javax.jws.WebMethod) WebMethod(javax.jws.WebMethod) WebParam(javax.jws.WebParam) RequestWrapper(javax.xml.ws.RequestWrapper) ObjectStreamClass(java.io.ObjectStreamClass) WebResult(javax.jws.WebResult) File(java.io.File) AbstractCodeGenTest(org.apache.cxf.tools.wsdlto.AbstractCodeGenTest) Test(org.junit.Test)

Aggregations

WebResult (javax.jws.WebResult)20 WebMethod (javax.jws.WebMethod)14 Method (java.lang.reflect.Method)4 WebParam (javax.jws.WebParam)4 QName (javax.xml.namespace.QName)4 ResponseWrapper (javax.xml.ws.ResponseWrapper)4 AbstractCodeGenTest (org.apache.cxf.tools.wsdlto.AbstractCodeGenTest)4 Test (org.junit.Test)4 File (java.io.File)3 ObjectStreamClass (java.io.ObjectStreamClass)3 Calendar (java.util.Calendar)2 WebService (javax.jws.WebService)2 RequestWrapper (javax.xml.ws.RequestWrapper)2 Customers (org.apache.cxf.customer.Customers)2 Project (com.artezio.arttime.datamodel.Project)1 BigInteger (java.math.BigInteger)1 Oneway (javax.jws.Oneway)1 SOAPBinding (javax.jws.soap.SOAPBinding)1 POST (javax.ws.rs.POST)1 Path (javax.ws.rs.Path)1