use of javax.jws.WebResult 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;
}
use of javax.jws.WebResult in project cxf by apache.
the class CodeGenTest method testHelloWorldSoap12.
@Test
public void testHelloWorldSoap12() throws Exception {
env.put(ToolConstants.CFG_WSDLURL, getLocation("/wsdl2java_wsdl/hello_world_soap12.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_soap12_http");
assertTrue(helloworldsoaphttp.exists());
File types = new File(helloworldsoaphttp, "types");
assertTrue(types.exists());
File[] files = helloworldsoaphttp.listFiles();
assertEquals(5, files.length);
files = types.listFiles();
assertEquals(7, files.length);
Class<?> clz = classLoader.loadClass("org.apache.cxf.w2j.hello_world_soap12_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_soap12_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("pingMe", new Class[] {});
webMethodAnno = AnnotationUtil.getPrivMethodAnnotation(method, WebMethod.class);
if (webMethodAnno.operationName() != null && !"".equals(webMethodAnno.operationName())) {
assertEquals(method.getName() + "()" + " Annotation : WebMethod.operationName ", "pingMe", webMethodAnno.operationName());
}
Class<?>[] exceptionCls = method.getExceptionTypes();
assertEquals(1, exceptionCls.length);
assertEquals("org.apache.cxf.w2j.hello_world_soap12_http.PingMeFault", exceptionCls[0].getName());
}
use of javax.jws.WebResult in project ART-TIME by Artezio.
the class IntegrationFacade method getAllSubprojects.
@WebMethod
@WebResult(name = "subprojects")
public List<Project> getAllSubprojects(@WebParam(name = "masterProjectCode") String masterProjectCode) {
Project rootProject = projectRepository.findProject(masterProjectCode);
List<Project> projects = projectService.getSubprojectsByProject(rootProject);
projects.remove(rootProject);
return projects;
}
use of javax.jws.WebResult in project cxf by apache.
the class JaxWsServiceConfiguration method getOutParameterName.
@Override
public QName getOutParameterName(OperationInfo op, Method method, int paramNumber) {
method = getDeclaredMethod(method);
if (paramNumber >= 0) {
return getParameterName(op, method, paramNumber, op.getOutput().size(), "return", false);
}
WebResult webResult = getWebResult(method);
String tns = null;
String local = null;
if (webResult != null) {
tns = webResult.targetNamespace();
local = webResult.name();
}
if (tns == null || tns.length() == 0) {
QName wrappername = getResponseWrapperName(op, method);
if (wrappername != null) {
tns = wrappername.getNamespaceURI();
}
}
if (tns == null || tns.length() == 0) {
tns = op.getName().getNamespaceURI();
}
if (local == null || local.length() == 0) {
if (Boolean.TRUE.equals(isRPC(method)) || !Boolean.FALSE.equals(isWrapped(method))) {
local = getDefaultLocalName(op, method, paramNumber, op.getOutput().size(), "return");
} else {
local = getOperationName(op.getInterface(), method).getLocalPart() + "Response";
}
}
return new QName(tns, local);
}
use of javax.jws.WebResult in project cxf by apache.
the class JaxWsServiceConfiguration method getResponseWrapperPartName.
@Override
public String getResponseWrapperPartName(OperationInfo op, Method method) {
method = getDeclaredMethod(method);
WebResult webResult = getWebResult(method);
ResponseWrapper rw = method.getAnnotation(ResponseWrapper.class);
if (rw != null) {
String pn = getWithReflection(ResponseWrapper.class, rw, "partName");
if (pn != null) {
return pn;
}
}
int countOut = 0;
int countHeaders = 0;
if (webResult != null && webResult.header()) {
countHeaders++;
} else if (method.getReturnType() != Void.TYPE) {
countOut++;
}
for (int x = 0; x < method.getParameterTypes().length; x++) {
WebParam parm = getWebParam(method, x);
if (parm != null) {
if (parm.header()) {
countHeaders++;
}
if (parm.mode() != WebParam.Mode.IN) {
countOut++;
}
}
}
if (countHeaders > 0 && countOut == 0) {
// thus return the default for an empty part of "result"
return "result";
}
return null;
}
Aggregations