Search in sources :

Example 1 with SOAPBinding

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

the class SoapBindingAnnotator method annotate.

public void annotate(JavaAnnotatable ja) {
    JavaMethod method;
    if (ja instanceof JavaMethod) {
        method = (JavaMethod) ja;
    } else {
        throw new RuntimeException("SOAPBindingAnnotator can only annotate JavaMethod");
    }
    if (method.getSoapStyle() == SOAPBinding.Style.DOCUMENT) {
        if (!method.isWrapperStyle() && !SOAPBinding.ParameterStyle.BARE.equals(method.getInterface().getSOAPParameterStyle())) {
            JAnnotation bindingAnnotation = new JAnnotation(SOAPBinding.class);
            bindingAnnotation.addElement(new JAnnotationElement("parameterStyle", SOAPBinding.ParameterStyle.BARE));
            method.addAnnotation("SOAPBinding", bindingAnnotation);
        } else if (method.isWrapperStyle() && SOAPBinding.ParameterStyle.BARE.equals(method.getInterface().getSOAPParameterStyle())) {
            JAnnotation bindingAnnotation = new JAnnotation(SOAPBinding.class);
            bindingAnnotation.addElement(new JAnnotationElement("parameterStyle", SOAPBinding.ParameterStyle.WRAPPED));
            method.addAnnotation("SOAPBinding", bindingAnnotation);
        }
    } else if (!SOAPBinding.Style.RPC.equals(method.getInterface().getSOAPStyle())) {
        JAnnotation bindingAnnotation = new JAnnotation(SOAPBinding.class);
        bindingAnnotation.addElement(new JAnnotationElement("style", SOAPBinding.Style.RPC));
        method.addAnnotation("SOAPBinding", bindingAnnotation);
    }
}
Also used : JAnnotation(org.apache.cxf.tools.common.model.JAnnotation) JAnnotationElement(org.apache.cxf.tools.common.model.JAnnotationElement) JavaMethod(org.apache.cxf.tools.common.model.JavaMethod) SOAPBinding(javax.jws.soap.SOAPBinding)

Example 2 with SOAPBinding

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

the class CodeGenTest method testHolderHeader.

@Test
public void testHolderHeader() throws Exception {
    env.put(ToolConstants.CFG_WSDLURL, getLocation("/wsdl2java_wsdl/hello_world_holder.wsdl"));
    // testing multiple parts in body
    env.remove(ToolConstants.CFG_VALIDATE_WSDL);
    processor.setContext(env);
    processor.execute();
    Class<?> clz = classLoader.loadClass("org.apache.cxf.w2j.hello_world_holder.Greeter");
    assertEquals(2, clz.getMethods().length);
    Class<?> para = classLoader.loadClass("org.apache.cxf.w2j.hello_world_holder.types.GreetMe");
    Method method = clz.getMethod("sayHi", new Class[] { Holder.class, para });
    assertEquals("GreetMeResponse", method.getReturnType().getSimpleName());
    SOAPBinding soapBindingAnno = AnnotationUtil.getPrivClassAnnotation(clz, SOAPBinding.class);
    if (soapBindingAnno == null) {
        soapBindingAnno = method.getAnnotation(SOAPBinding.class);
    }
    assertNotNull(soapBindingAnno);
    assertEquals("BARE", soapBindingAnno.parameterStyle().name());
    assertEquals("LITERAL", soapBindingAnno.use().name());
    assertEquals("DOCUMENT", soapBindingAnno.style().name());
    WebParam webParamAnno = AnnotationUtil.getWebParam(method, "greetMe");
    assertEquals(true, webParamAnno.header());
    webParamAnno = AnnotationUtil.getWebParam(method, "sayHi");
    assertEquals("INOUT", webParamAnno.mode().name());
    method = clz.getMethod("testInOut", Holder.class, Integer.TYPE);
}
Also used : WebParam(javax.jws.WebParam) Holder(javax.xml.ws.Holder) 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 3 with SOAPBinding

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

the class CodeGenTest method testRPCLit.

@Test
public void testRPCLit() throws Exception {
    env.put(ToolConstants.CFG_WSDLURL, getLocation("/wsdl2java_wsdl/hello_world_rpc_lit.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_rpclit");
    assertTrue(helloworldsoaphttp.exists());
    File types = new File(helloworldsoaphttp, "types");
    assertTrue(types.exists());
    File[] files = helloworldsoaphttp.listFiles();
    assertEquals(4, files.length);
    files = types.listFiles();
    assertEquals(files.length, 3);
    Class<?> clz = classLoader.loadClass("org.apache.cxf.w2j.hello_world_rpclit.GreeterRPCLit");
    javax.jws.WebService ws = AnnotationUtil.getPrivClassAnnotation(clz, javax.jws.WebService.class);
    SOAPBinding soapBindingAnno = AnnotationUtil.getPrivClassAnnotation(clz, SOAPBinding.class);
    assertEquals("LITERAL", soapBindingAnno.use().toString());
    assertEquals("RPC", soapBindingAnno.style().toString());
    assertEquals("Generate operation error", 3, clz.getMethods().length);
    Class<?> paraClass = classLoader.loadClass("org.apache.cxf.w2j.hello_world_rpclit.types.MyComplexStruct");
    Method method = clz.getMethod("sendReceiveData", new Class[] { paraClass });
    assertEquals("MyComplexStruct", method.getReturnType().getSimpleName());
    clz = classLoader.loadClass("org.apache.cxf.w2j.hello_world_rpclit.SoapPortRPCLitImpl");
    assertNotNull(clz);
    ws = AnnotationUtil.getPrivClassAnnotation(clz, javax.jws.WebService.class);
    assertNotNull(ws);
    assertTrue("Webservice annotation wsdlLocation should begin with file", ws.wsdlLocation().startsWith("file"));
    assertEquals("org.apache.cxf.w2j.hello_world_rpclit.GreeterRPCLit", ws.endpointInterface());
}
Also used : WebService(javax.jws.WebService) WebService(javax.jws.WebService) 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 4 with SOAPBinding

use of javax.jws.soap.SOAPBinding in project narayana by jbosstm.

the class ParticipantPortTypeImpl method completionRollback.

/**
 * @param parameters
 */
@WebMethod(operationName = "CompletionRollback", action = "http://fabrikam123.com/CompletionRollback")
@Oneway
@Action(input = "http://fabrikam123.com/CompletionRollback")
@SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.BARE)
public void completionRollback(@WebParam(name = "CompletionRollback", targetNamespace = "http://fabrikam123.com", partName = "parameters") String parameters) {
    MessageContext ctx = webServiceCtx.getMessageContext();
    MAP inboundMap = AddressingHelper.inboundMap(ctx);
    try {
        ATParticipantProcessor.getParticipant().completionRollback(parameters, inboundMap);
    } catch (SoapFault11 sf) {
        sendSoapFault(inboundMap, sf);
        return;
    }
    sendResponse(inboundMap);
}
Also used : SoapFault11(com.arjuna.webservices11.SoapFault11) MessageContext(javax.xml.ws.handler.MessageContext) MAP(org.jboss.ws.api.addressing.MAP) Action(javax.xml.ws.Action) SOAPBinding(javax.jws.soap.SOAPBinding)

Example 5 with SOAPBinding

use of javax.jws.soap.SOAPBinding in project narayana by jbosstm.

the class ParticipantPortTypeImpl method completionCommit.

/**
 * @param parameters
 */
@WebMethod(operationName = "CompletionCommit", action = "http://www.wstf.org/docs/scenarios/sc007/CompletionCommit")
@Oneway
@Action(input = "http://www.wstf.org/docs/scenarios/sc007/CompletionCommit")
@SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.BARE)
public void completionCommit(@WebParam(name = "CompletionCommit", targetNamespace = "http://www.wstf.org/sc007", partName = "parameters") String parameters) {
    MessageContext ctx = webServiceCtx.getMessageContext();
    MAP inboundMap = AddressingHelper.inboundMap(ctx);
    try {
        ParticipantProcessor.getParticipant().completionCommit(parameters, inboundMap);
    } catch (SoapFault11 sf) {
        sendSoapFault(inboundMap, sf);
        return;
    }
    sendResponse(inboundMap);
}
Also used : SoapFault11(com.arjuna.webservices11.SoapFault11) MessageContext(javax.xml.ws.handler.MessageContext) MAP(org.jboss.ws.api.addressing.MAP) Action(javax.xml.ws.Action) SOAPBinding(javax.jws.soap.SOAPBinding)

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 Holder (javax.xml.ws.Holder)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