method.getInterface().addImport("javax.jws.WebMethod");
}
private void addWebResultAnnotation(JavaMethod method) {
if (method.isOneWay()) {
JavaAnnotation oneWayAnnotation = new JavaAnnotation("Oneway");
method.addAnnotation("Oneway", oneWayAnnotation);
method.getInterface().addImport("javax.jws.Oneway");
return;
}
if ("void".equals(method.getReturn().getType())) {
return;
}
JavaAnnotation resultAnnotation = new JavaAnnotation("WebResult");
String targetNamespace = method.getReturn().getTargetNamespace();
String name = "return";
if (method.getSoapStyle() == SOAPBinding.Style.DOCUMENT
&& !method.isWrapperStyle()) {
name = method.getName() + "Response";
}
if (method.getSoapStyle() == SOAPBinding.Style.RPC) {
name = method.getReturn().getName();
targetNamespace = method.getInterface().getNamespace();
}
if (method.getSoapStyle() == SOAPBinding.Style.DOCUMENT) {
if (method.getReturn().getQName() != null) {
name = method.getReturn().getQName().getLocalPart();
}
targetNamespace = method.getReturn().getTargetNamespace();
}
resultAnnotation.addArgument("name", name);
resultAnnotation.addArgument("targetNamespace", targetNamespace);
if (method.getSoapStyle() == SOAPBinding.Style.RPC
|| (method.getSoapStyle() == SOAPBinding.Style.DOCUMENT && !method.isWrapperStyle())) {
resultAnnotation.addArgument("partName", method.getReturn().getName());
}
method.addAnnotation("WebResult", resultAnnotation);
method.getInterface().addImport("javax.jws.WebResult");
}