Search in sources :

Example 76 with WebMethod

use of javax.jws.WebMethod 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)

Example 77 with WebMethod

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

the class CodeGenTest method testVoidInOutMethod.

@Test
public void testVoidInOutMethod() throws Exception {
    env.put(ToolConstants.CFG_WSDLURL, getLocation("/wsdl2java_wsdl/interoptestdoclit.wsdl"));
    env.remove(ToolConstants.CFG_VALIDATE_WSDL);
    processor.setContext(env);
    processor.execute();
    assertNotNull(output);
    File org = new File(output, "org");
    assertTrue(org.exists());
    File soapinterop = new File(org, "soapinterop");
    assertTrue(soapinterop.exists());
    File wsdlinterop = new File(soapinterop, "wsdlinteroptestdoclit");
    assertTrue(wsdlinterop.exists());
    File xsd = new File(soapinterop, "xsd");
    assertTrue(xsd.exists());
    File[] files = wsdlinterop.listFiles();
    assertEquals(3, files.length);
    files = xsd.listFiles();
    assertEquals(4, files.length);
    Class<?> clz = classLoader.loadClass("org.soapinterop.wsdlinteroptestdoclit.WSDLInteropTestDocLitPortType");
    Method method = clz.getMethod("echoVoid", new Class[] {});
    WebMethod webMethodAnno = AnnotationUtil.getPrivMethodAnnotation(method, WebMethod.class);
    if (webMethodAnno.operationName() != null && !"".equals(webMethodAnno.operationName())) {
        assertEquals(method.getName() + "()" + " Annotation : WebMethod.operationName ", "echoVoid", webMethodAnno.operationName());
    }
}
Also used : WebMethod(javax.jws.WebMethod) Method(java.lang.reflect.Method) WebMethod(javax.jws.WebMethod) File(java.io.File) AbstractCodeGenTest(org.apache.cxf.tools.wsdlto.AbstractCodeGenTest) Test(org.junit.Test)

Example 78 with WebMethod

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

the class AbstractNotificationBroker method getCurrentMessage.

/**
 * @param getCurrentMessageRequest
 * @return returns org.oasis_open.docs.wsn.b_1.GetCurrentMessageResponse
 * @throws MultipleTopicsSpecifiedFault
 * @throws TopicNotSupportedFault
 * @throws InvalidTopicExpressionFault
 * @throws ResourceUnknownFault
 * @throws TopicExpressionDialectUnknownFault
 * @throws NoCurrentMessageOnTopicFault
 */
@WebMethod(operationName = "GetCurrentMessage")
@WebResult(name = "GetCurrentMessageResponse", targetNamespace = "http://docs.oasis-open.org/wsn/b-1", partName = "GetCurrentMessageResponse")
public GetCurrentMessageResponse getCurrentMessage(@WebParam(name = "GetCurrentMessage", targetNamespace = "http://docs.oasis-open.org/wsn/b-1", partName = "GetCurrentMessageRequest") GetCurrentMessage getCurrentMessageRequest) throws // CHECKSTYLE:OFF - WS-Notification spec throws a lot of faults
InvalidTopicExpressionFault, MultipleTopicsSpecifiedFault, NoCurrentMessageOnTopicFault, ResourceUnknownFault, TopicExpressionDialectUnknownFault, TopicNotSupportedFault {
    // CHECKSTYLE:ON
    LOGGER.finest("GetCurrentMessage");
    NoCurrentMessageOnTopicFaultType fault = new NoCurrentMessageOnTopicFaultType();
    throw new NoCurrentMessageOnTopicFault("There is no current message on this topic.", fault);
}
Also used : NoCurrentMessageOnTopicFaultType(org.oasis_open.docs.wsn.b_2.NoCurrentMessageOnTopicFaultType) NoCurrentMessageOnTopicFault(org.oasis_open.docs.wsn.bw_2.NoCurrentMessageOnTopicFault) WebMethod(javax.jws.WebMethod) WebResult(javax.jws.WebResult)

Example 79 with WebMethod

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

the class AbstractPullPoint method getMessages.

/**
 * @param getMessagesRequest
 * @return returns org.oasis_open.docs.wsn.b_1.GetMessagesResponse
 * @throws ResourceUnknownFault
 * @throws UnableToGetMessagesFault
 */
@WebMethod(operationName = "GetMessages")
@WebResult(name = "GetMessagesResponse", targetNamespace = "http://docs.oasis-open.org/wsn/b-1", partName = "GetMessagesResponse")
public GetMessagesResponse getMessages(@WebParam(name = "GetMessages", targetNamespace = "http://docs.oasis-open.org/wsn/b-1", partName = "GetMessagesRequest") GetMessages getMessagesRequest) throws ResourceUnknownFault, UnableToGetMessagesFault {
    LOGGER.finest("GetMessages");
    BigInteger max = getMessagesRequest.getMaximumNumber();
    List<NotificationMessageHolderType> messages = getMessages(max != null ? max.intValue() : 0);
    GetMessagesResponse response = new GetMessagesResponse();
    response.getNotificationMessage().addAll(messages);
    return response;
}
Also used : GetMessagesResponse(org.oasis_open.docs.wsn.b_2.GetMessagesResponse) BigInteger(java.math.BigInteger) NotificationMessageHolderType(org.oasis_open.docs.wsn.b_2.NotificationMessageHolderType) WebMethod(javax.jws.WebMethod) WebResult(javax.jws.WebResult)

Example 80 with WebMethod

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

the class AbstractSubscription method renew.

/**
 * @param renewRequest
 * @return returns org.oasis_open.docs.wsn.b_1.RenewResponse
 * @throws UnacceptableTerminationTimeFault
 * @throws ResourceUnknownFault
 */
@WebMethod(operationName = "Renew")
@WebResult(name = "RenewResponse", targetNamespace = "http://docs.oasis-open.org/wsn/b-2", partName = "RenewResponse")
public RenewResponse renew(@WebParam(name = "Renew", targetNamespace = "http://docs.oasis-open.org/wsn/b-2", partName = "RenewRequest") Renew renewRequest) throws ResourceUnknownFault, UnacceptableTerminationTimeFault {
    XMLGregorianCalendar time = validateTerminationTime(renewRequest.getTerminationTime());
    this.setTerminationTime(time);
    renew(time);
    RenewResponse response = new RenewResponse();
    response.setTerminationTime(time);
    response.setCurrentTime(getCurrentTime());
    return response;
}
Also used : XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) RenewResponse(org.oasis_open.docs.wsn.b_2.RenewResponse) WebMethod(javax.jws.WebMethod) WebResult(javax.jws.WebResult)

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