Search in sources :

Example 11 with SOAPBinding

use of javax.jws.soap.SOAPBinding in project cxf by apache.

the class JaxWsServiceConfiguration method isDocumentBare.

private boolean isDocumentBare(Method method) {
    SOAPBinding ann = method.getAnnotation(SOAPBinding.class);
    if (ann != null) {
        return ann.style().equals(SOAPBinding.Style.DOCUMENT) && ann.parameterStyle().equals(SOAPBinding.ParameterStyle.BARE);
    }
    ann = implInfo.getEndpointClass().getAnnotation(SOAPBinding.class);
    if (ann != null) {
        return ann.style().equals(SOAPBinding.Style.DOCUMENT) && ann.parameterStyle().equals(SOAPBinding.ParameterStyle.BARE);
    }
    return false;
}
Also used : SOAPBinding(javax.jws.soap.SOAPBinding)

Example 12 with SOAPBinding

use of javax.jws.soap.SOAPBinding in project cxf by apache.

the class JaxWsServiceConfiguration method isWrapped.

@Override
public Boolean isWrapped(Method m) {
    // see if someone overrode the default value
    if (getServiceFactory().getWrapped() != null) {
        return getServiceFactory().getWrapped();
    }
    m = getDeclaredMethod(m);
    SOAPBinding ann = m.getAnnotation(SOAPBinding.class);
    if (ann != null) {
        if (ann.style().equals(Style.RPC)) {
            Message message = new Message("SOAPBinding_MESSAGE_RPC", LOG, m.getName());
            throw new Fault(new JaxWsConfigurationException(message));
        }
        return !(ann.parameterStyle().equals(ParameterStyle.BARE));
    }
    return isWrapped();
}
Also used : JaxWsConfigurationException(org.apache.cxf.jaxws.JaxWsConfigurationException) Message(org.apache.cxf.common.i18n.Message) SOAPBinding(javax.jws.soap.SOAPBinding) Fault(org.apache.cxf.interceptor.Fault) WebFault(javax.xml.ws.WebFault)

Example 13 with SOAPBinding

use of javax.jws.soap.SOAPBinding in project cxf by apache.

the class CodeGenTest method testSupportXMLBindingBare.

@Test
public void testSupportXMLBindingBare() throws Exception {
    env.put(ToolConstants.CFG_WSDLURL, getLocation("/wsdl2java_wsdl/xml_http_bare.wsdl"));
    processor.setContext(env);
    processor.execute();
    Class<?> clz = classLoader.loadClass("org.apache.xml_http_bare.GreetingPortType");
    Method method = clz.getMethod("sayHello", new Class[] { java.lang.String.class });
    assertNotNull("sayHello is not be generated", method);
    SOAPBinding soapBindingAnn = clz.getAnnotation(SOAPBinding.class);
    assertEquals(soapBindingAnn.parameterStyle(), SOAPBinding.ParameterStyle.BARE);
}
Also used : SOAPBinding(javax.jws.soap.SOAPBinding) Method(java.lang.reflect.Method) WebMethod(javax.jws.WebMethod) AbstractCodeGenTest(org.apache.cxf.tools.wsdlto.AbstractCodeGenTest) Test(org.junit.Test)

Example 14 with SOAPBinding

use of javax.jws.soap.SOAPBinding in project cxf by apache.

the class CodeGenTest method testSoapHeader.

@Test
public void testSoapHeader() throws Exception {
    env.put(ToolConstants.CFG_WSDLURL, getLocation("/wsdl2java_wsdl/soap_header.wsdl"));
    env.put(ToolConstants.CFG_PACKAGENAME, "org.apache");
    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[] files = apache.listFiles();
    assertEquals(12, files.length);
    Class<?> clz = classLoader.loadClass("org.apache.HeaderTester");
    assertEquals(3, clz.getMethods().length);
    SOAPBinding soapBindingAnno = AnnotationUtil.getPrivClassAnnotation(clz, SOAPBinding.class);
    assertEquals("BARE", soapBindingAnno.parameterStyle().name());
    assertEquals("LITERAL", soapBindingAnno.use().name());
    assertEquals("DOCUMENT", soapBindingAnno.style().name());
    Class<?> para = classLoader.loadClass("org.apache.InoutHeader");
    Method method = clz.getMethod("inoutHeader", new Class[] { para, Holder.class });
    // the SOAPBinding annotation on the class sets it to bare, thus, this annotation may
    // not be generated as it would be redundant
    // soapBindingAnno = AnnotationUtil.getPrivMethodAnnotation(method, SOAPBinding.class);
    // assertNotNull(soapBindingAnno);
    // assertEquals(SOAPBinding.ParameterStyle.BARE, soapBindingAnno.parameterStyle());
    WebParam webParamAnno = AnnotationUtil.getWebParam(method, "SOAPHeaderInfo");
    assertEquals("INOUT", webParamAnno.mode().name());
    assertTrue(webParamAnno.header());
    assertEquals("header_info", webParamAnno.partName());
}
Also used : WebParam(javax.jws.WebParam) SOAPBinding(javax.jws.soap.SOAPBinding) 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 15 with SOAPBinding

use of javax.jws.soap.SOAPBinding 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

SOAPBinding (javax.jws.soap.SOAPBinding)15 WebMethod (javax.jws.WebMethod)7 SoapFault11 (com.arjuna.webservices11.SoapFault11)6 Action (javax.xml.ws.Action)6 MessageContext (javax.xml.ws.handler.MessageContext)6 MAP (org.jboss.ws.api.addressing.MAP)6 Method (java.lang.reflect.Method)5 AbstractCodeGenTest (org.apache.cxf.tools.wsdlto.AbstractCodeGenTest)5 Test (org.junit.Test)5 File (java.io.File)3 Oneway (javax.jws.Oneway)3 WebParam (javax.jws.WebParam)3 WebService (javax.jws.WebService)2 ObjectStreamClass (java.io.ObjectStreamClass)1 WebResult (javax.jws.WebResult)1 RequestWrapper (javax.xml.ws.RequestWrapper)1 ResponseWrapper (javax.xml.ws.ResponseWrapper)1 WebFault (javax.xml.ws.WebFault)1 Message (org.apache.cxf.common.i18n.Message)1 Fault (org.apache.cxf.interceptor.Fault)1