use of javax.jws.WebMethod in project cxf by apache.
the class JaxWsServiceConfiguration method getOperationName.
@Override
public QName getOperationName(InterfaceInfo intf, Method method) {
method = getDeclaredMethod(method);
WebMethod wm = method.getAnnotation(WebMethod.class);
if (wm != null) {
String name = wm.operationName();
if (name.length() == 0) {
name = method.getName();
}
return new QName(intf.getName().getNamespaceURI(), name);
}
return new QName(intf.getName().getNamespaceURI(), method.getName());
}
use of javax.jws.WebMethod in project cxf by apache.
the class JaxWsServiceConfiguration method getResponseWrapperName.
@Override
public QName getResponseWrapperName(OperationInfo op, Method method) {
Method m = getDeclaredMethod(method);
ResponseWrapper rw = m.getAnnotation(ResponseWrapper.class);
String nm = null;
String lp = null;
if (rw != null) {
nm = rw.targetNamespace();
lp = rw.localName();
}
WebMethod meth = m.getAnnotation(WebMethod.class);
if (meth != null && StringUtils.isEmpty(lp)) {
lp = meth.operationName();
if (!StringUtils.isEmpty(lp)) {
lp += "Response";
}
}
if (StringUtils.isEmpty(nm)) {
nm = op.getName().getNamespaceURI();
}
if (!StringUtils.isEmpty(nm) && !StringUtils.isEmpty(lp)) {
return new QName(nm, lp);
}
return null;
}
use of javax.jws.WebMethod in project cxf by apache.
the class JaxWsServiceFactoryBean method buildWSAActions.
private void buildWSAActions(OperationInfo operation, Method method) {
// nothing
if (method == null) {
return;
}
Action action = method.getAnnotation(Action.class);
Addressing addressing = method.getDeclaringClass().getAnnotation(Addressing.class);
if (action == null && addressing == null) {
return;
}
WebMethod wm = method.getAnnotation(WebMethod.class);
String inputAction = "";
if (action != null) {
inputAction = action.input();
}
if (wm != null && StringUtils.isEmpty(inputAction)) {
inputAction = wm.action();
}
if (StringUtils.isEmpty(inputAction)) {
inputAction = computeAction(operation, "Request");
}
if (action == null && addressing != null) {
operation.getInput().addExtensionAttribute(JAXWSAConstants.WSAM_ACTION_QNAME, inputAction);
operation.getInput().addExtensionAttribute(JAXWSAConstants.WSAW_ACTION_QNAME, inputAction);
if (operation.getOutput() != null) {
operation.getOutput().addExtensionAttribute(JAXWSAConstants.WSAM_ACTION_QNAME, computeAction(operation, "Response"));
operation.getOutput().addExtensionAttribute(JAXWSAConstants.WSAW_ACTION_QNAME, computeAction(operation, "Response"));
}
} else {
MessageInfo input = operation.getInput();
input.addExtensionAttribute(JAXWSAConstants.WSAM_ACTION_QNAME, inputAction);
if (!StringUtils.isEmpty(action.input())) {
input.addExtensionAttribute(JAXWSAConstants.WSAW_ACTION_QNAME, inputAction);
}
MessageInfo output = operation.getOutput();
if (output != null && !StringUtils.isEmpty(action.output())) {
output.addExtensionAttribute(JAXWSAConstants.WSAW_ACTION_QNAME, action.output());
output.addExtensionAttribute(JAXWSAConstants.WSAM_ACTION_QNAME, action.output());
} else if (output != null) {
output.addExtensionAttribute(JAXWSAConstants.WSAM_ACTION_QNAME, computeAction(operation, "Response"));
}
FaultAction[] faultActions = action.fault();
if (faultActions != null && faultActions.length > 0 && operation.getFaults() != null) {
for (FaultAction faultAction : faultActions) {
FaultInfo faultInfo = getFaultInfo(operation, faultAction.className());
if (faultInfo != null && !StringUtils.isEmpty(faultAction.value())) {
faultInfo.addExtensionAttribute(JAXWSAConstants.WSAW_ACTION_QNAME, faultAction.value());
faultInfo.addExtensionAttribute(JAXWSAConstants.WSAM_ACTION_QNAME, faultAction.value());
}
if (operation.isUnwrappedCapable()) {
faultInfo = getFaultInfo(operation.getUnwrappedOperation(), faultAction.className());
if (faultInfo != null && !StringUtils.isEmpty(faultAction.value())) {
faultInfo.addExtensionAttribute(JAXWSAConstants.WSAW_ACTION_QNAME, faultAction.value());
faultInfo.addExtensionAttribute(JAXWSAConstants.WSAM_ACTION_QNAME, faultAction.value());
}
}
}
}
}
for (FaultInfo fi : operation.getFaults()) {
if (fi.getExtensionAttribute(JAXWSAConstants.WSAM_ACTION_QNAME) == null) {
String f = "/Fault/" + fi.getName().getLocalPart();
fi.addExtensionAttribute(JAXWSAConstants.WSAM_ACTION_QNAME, computeAction(operation, f));
if (operation.isUnwrappedCapable()) {
fi = operation.getUnwrappedOperation().getFault(fi.getName());
fi.addExtensionAttribute(JAXWSAConstants.WSAM_ACTION_QNAME, computeAction(operation, f));
}
}
}
}
use of javax.jws.WebMethod in project cxf by apache.
the class CustomerService method getCustomers.
@WebMethod
@WebResult(name = "customers")
public Customers getCustomers(@WebParam(name = "GetCustomers") GetCustomers req) {
Customers cbean = new Customers();
cbean.setCustomer(customers.values());
if (context == null || context.getMessageContext() == null) {
throw new WebServiceException("WebServiceContext is null!");
}
return cbean;
}
use of javax.jws.WebMethod in project cxf by apache.
the class CodeGenTest method testAsyncMethodFromCommandLine.
@Test
public void testAsyncMethodFromCommandLine() throws Exception {
env.put(ToolConstants.CFG_WSDLURL, getLocation("/wsdl2java_wsdl/hello_world.wsdl"));
env.put(ToolConstants.CFG_ASYNCMETHODS, new String[0]);
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 async = new File(w2j, "hello_world_soap_http");
assertTrue(async.exists());
File[] files = async.listFiles();
assertEquals(9, files.length);
Class<?> clz = classLoader.loadClass("org.apache.cxf.w2j.hello_world_soap_http.Greeter");
Method method1 = clz.getMethod("greetMeSometimeAsync", new Class[] { java.lang.String.class, javax.xml.ws.AsyncHandler.class });
WebMethod webMethodAnno1 = AnnotationUtil.getPrivMethodAnnotation(method1, WebMethod.class);
assertEquals(method1.getName() + "()" + " Annotation : WebMethod.operationName ", "greetMeSometime", webMethodAnno1.operationName());
java.lang.reflect.Method method2 = clz.getMethod("greetMeSometimeAsync", new Class[] { java.lang.String.class });
WebMethod webMethodAnno2 = AnnotationUtil.getPrivMethodAnnotation(method2, WebMethod.class);
assertEquals(method2.getName() + "()" + " Annotation : WebMethod.operationName ", "greetMeSometime", webMethodAnno2.operationName());
}
Aggregations