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);
}
}
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);
}
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());
}
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);
}
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);
}
Aggregations