Search in sources :

Example 51 with WebMethod

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<>(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());
            }
        }
    }
}
Also used : WebMethod(javax.jws.WebMethod) WebParam(javax.jws.WebParam) Holder(javax.xml.ws.Holder) TradePriceData(org.apache.hello_world_doc_lit_bare.types.TradePriceData) WebMethod(javax.jws.WebMethod) Method(java.lang.reflect.Method) PutLastTradedPricePortType(org.apache.hello_world_doc_lit_bare.PutLastTradedPricePortType) Annotation(java.lang.annotation.Annotation) Test(org.junit.Test)

Example 52 with WebMethod

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

the class BaseGreeterImpl method testDocLitBare.

@WebMethod
public BareDocumentResponse testDocLitBare(String in) {
    invocationCount++;
    BareDocumentResponse res = new BareDocumentResponse();
    res.setCompany("CXF");
    res.setId(1);
    return res;
}
Also used : BareDocumentResponse(org.apache.hello_world_soap_http.types.BareDocumentResponse) WebMethod(javax.jws.WebMethod)

Example 53 with WebMethod

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

the class CustomerService method getCustomers.

@WebMethod
@WebResult(name = "customers")
public Customers getCustomers() {
    Customers cbean = new Customers();
    cbean.setCustomer(customers.values());
    return cbean;
}
Also used : Customers(org.apache.cxf.customer.Customers) WebMethod(javax.jws.WebMethod) WebResult(javax.jws.WebResult)

Example 54 with WebMethod

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;
}
Also used : Customer(org.apache.cxf.customer.Customer) CustomerNotFoundFault(org.apache.cxf.customer.CustomerNotFoundFault) CustomerNotFoundDetails(org.apache.cxf.customer.CustomerNotFoundDetails) WebMethod(javax.jws.WebMethod) WebResult(javax.jws.WebResult)

Example 55 with WebMethod

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());
    clz.getMethod("greetMeSometimeAsync", new Class[] { java.lang.String.class, javax.xml.ws.AsyncHandler.class });
    try {
        clz.getMethod("testIntAsync", new Class[] { Integer.TYPE, javax.xml.ws.AsyncHandler.class });
        fail("Should not have generated testIntAsync");
    } catch (NoSuchMethodException ex) {
    // expected
    }
    clz = classLoader.loadClass("org.apache.cxf.w2j.hello_world_async_soap_http.GreeterDAsync");
    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 {
        clz.getMethod("greetMeSometimeAsync", new Class[] { java.lang.String.class, javax.xml.ws.AsyncHandler.class });
        fail("Should not have generated greetMeSometimeAsync");
    } catch (NoSuchMethodException ex) {
    // expected
    }
    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 {
        clz.getMethod("greetMeSometimeAsync", new Class[] { java.lang.String.class, javax.xml.ws.AsyncHandler.class });
        fail("Should not have generated greetMeSometimeAsync");
    } catch (NoSuchMethodException ex) {
    // expected
    }
    clz.getMethod("testIntAsync", new Class[] { Integer.TYPE, javax.xml.ws.AsyncHandler.class });
}
Also used : WebMethod(javax.jws.WebMethod) Method(java.lang.reflect.Method) WebMethod(javax.jws.WebMethod) File(java.io.File) Method(java.lang.reflect.Method) AbstractCodeGenTest(org.apache.cxf.tools.wsdlto.AbstractCodeGenTest) Test(org.junit.Test)

Aggregations

WebMethod (javax.jws.WebMethod)107 Method (java.lang.reflect.Method)18 Path (javax.ws.rs.Path)17 IOException (java.io.IOException)16 WebResult (javax.jws.WebResult)13 MessageContext (javax.xml.ws.handler.MessageContext)12 WebServiceException (javax.xml.ws.WebServiceException)11 Test (org.junit.Test)10 DataHandler (javax.activation.DataHandler)9 GET (javax.ws.rs.GET)9 Action (javax.xml.ws.Action)9 ArrayList (java.util.ArrayList)8 Oneway (javax.jws.Oneway)8 POST (javax.ws.rs.POST)8 File (java.io.File)7 InputStream (java.io.InputStream)6 HttpServletRequest (javax.servlet.http.HttpServletRequest)6 QName (javax.xml.namespace.QName)6 RequestWrapper (javax.xml.ws.RequestWrapper)6 AbstractCodeGenTest (org.apache.cxf.tools.wsdlto.AbstractCodeGenTest)6