use of org.apache.cxf.tools.wsdlto.frontend.jaxws.customization.JAXWSBinding in project cxf by apache.
the class OperationProcessor method processMethod.
void processMethod(JavaMethod method, OperationInfo operation) throws ToolException {
if (isAsyncMethod(method)) {
return;
}
MessageInfo inputMessage = operation.getInput();
MessageInfo outputMessage = operation.getOutput();
if (inputMessage == null) {
LOG.log(Level.WARNING, "NO_INPUT_MESSAGE", new Object[] { operation.getName() });
org.apache.cxf.common.i18n.Message msg = new org.apache.cxf.common.i18n.Message("INVALID_MEP", LOG, new Object[] { operation.getName() });
throw new ToolException(msg);
}
ParameterProcessor paramProcessor = new ParameterProcessor(context);
method.clear();
JAXWSBinding opBinding = operation.getExtensor(JAXWSBinding.class);
JAXWSBinding ptBinding = operation.getInterface().getExtensor(JAXWSBinding.class);
JAXWSBinding defBinding = operation.getInterface().getService().getDescription().getExtensor(JAXWSBinding.class);
boolean enableAsync = false;
boolean enableMime = false;
boolean enableWrapper = method.isWrapperStyle();
if (defBinding != null) {
if (defBinding.isSetEnableMime()) {
enableMime = defBinding.isEnableMime();
}
if (defBinding.isSetEnableAsyncMapping()) {
enableAsync = defBinding.isEnableAsyncMapping();
}
if (defBinding.isSetEnableWrapperStyle()) {
enableWrapper = defBinding.isEnableWrapperStyle();
}
}
if (ptBinding != null) {
if (ptBinding.isSetEnableMime()) {
enableMime = ptBinding.isEnableMime();
}
if (ptBinding.isSetEnableAsyncMapping()) {
enableAsync = ptBinding.isEnableAsyncMapping();
}
if (ptBinding.isSetEnableWrapperStyle()) {
enableWrapper = ptBinding.isEnableWrapperStyle();
}
}
if (opBinding != null) {
if (opBinding.isSetEnableMime()) {
enableMime = opBinding.isEnableMime();
}
if (opBinding.isSetEnableAsyncMapping()) {
enableAsync = opBinding.isEnableAsyncMapping();
}
if (opBinding.isSetEnableWrapperStyle()) {
enableWrapper = opBinding.isEnableWrapperStyle();
}
}
enableWrapper = checkEnableWrapper(enableWrapper, method);
enableAsync = checkEnableAsync(enableAsync, method);
enableMime = checkEnableMime(enableMime, method);
method.setWrapperStyle(enableWrapper && method.isWrapperStyle());
paramProcessor.process(method, inputMessage, outputMessage, operation.getParameterOrdering());
if (method.isWrapperStyle()) {
setWrapper(operation);
method.annotate(new WrapperAnnotator(wrapperRequest, wrapperResponse));
}
method.annotate(new WebMethodAnnotator());
method.annotate(new WebResultAnnotator());
if (!method.isOneWay() && enableAsync && !isAddedAsycMethod(method)) {
addAsyncMethod(method);
}
if (enableMime) {
method.setMimeEnable(true);
}
}
use of org.apache.cxf.tools.wsdlto.frontend.jaxws.customization.JAXWSBinding in project cxf by apache.
the class ParameterProcessor method processInput.
private void processInput(JavaMethod method, MessageInfo inputMessage) throws ToolException {
if (requireOutOfBandHeader()) {
try {
Class.forName("org.apache.cxf.binding.soap.SoapBindingFactory");
} catch (Exception e) {
LOG.log(Level.WARNING, new Message("SOAP_MISSING", LOG).toString());
}
}
JAXWSBinding mBinding = inputMessage.getOperation().getExtensor(JAXWSBinding.class);
for (MessagePartInfo part : inputMessage.getMessageParts()) {
if (isOutOfBandHeader(part) && !requireOutOfBandHeader()) {
continue;
}
JavaParameter param = getParameterFromPart(method, part, JavaType.Style.IN);
if (mBinding != null && mBinding.getJaxwsParas() != null) {
for (JAXWSParameter jwp : mBinding.getJaxwsParas()) {
if (part.getName().getLocalPart().equals(jwp.getPart())) {
param.setName(jwp.getName());
}
}
}
addParameter(part, method, param);
}
}
use of org.apache.cxf.tools.wsdlto.frontend.jaxws.customization.JAXWSBinding in project cxf by apache.
the class PortTypeProcessor method getInterface.
public static JavaInterface getInterface(ToolContext context, ServiceInfo serviceInfo, InterfaceInfo interfaceInfo) throws ToolException {
JavaInterface intf = interfaceInfo.getProperty("JavaInterface", JavaInterface.class);
if (intf == null) {
intf = new InterfaceMapper(context).map(interfaceInfo);
JAXWSBinding jaxwsBinding = null;
if (serviceInfo.getDescription() != null) {
jaxwsBinding = serviceInfo.getDescription().getExtensor(JAXWSBinding.class);
}
JAXWSBinding infBinding = interfaceInfo.getExtensor(JAXWSBinding.class);
if (infBinding != null && infBinding.getPackage() != null) {
intf.setPackageName(infBinding.getPackage());
} else if (jaxwsBinding != null && jaxwsBinding.getPackage() != null) {
intf.setPackageName(jaxwsBinding.getPackage());
}
if (infBinding != null && !infBinding.getPackageJavaDoc().equals("")) {
intf.setPackageJavaDoc(infBinding.getPackageJavaDoc());
} else if (jaxwsBinding != null && !jaxwsBinding.getPackageJavaDoc().equals("")) {
intf.setPackageJavaDoc(jaxwsBinding.getPackageJavaDoc());
}
String name = intf.getName();
if (infBinding != null && infBinding.getJaxwsClass() != null && infBinding.getJaxwsClass().getClassName() != null) {
name = infBinding.getJaxwsClass().getClassName();
if (name.contains(".")) {
intf.setPackageName(name.substring(0, name.lastIndexOf('.')));
name = name.substring(name.lastIndexOf('.') + 1);
}
intf.setClassJavaDoc(infBinding.getJaxwsClass().getComments());
}
if (StringUtils.isEmpty(intf.getClassJavaDoc())) {
intf.setClassJavaDoc(interfaceInfo.getDocumentation());
}
ClassCollector collector = context.get(ClassCollector.class);
if (context.optionSet(ToolConstants.CFG_AUTORESOLVE)) {
int count = 0;
String checkName = name;
while (collector.isReserved(intf.getPackageName(), checkName)) {
checkName = name + "_" + (++count);
}
name = checkName;
} else if (collector.isReserved(intf.getPackageName(), name)) {
throw new ToolException("RESERVED_SEI_NAME", LOG, name);
}
interfaceInfo.setProperty("InterfaceName", name);
intf.setName(name);
collector.addSeiClassName(intf.getPackageName(), intf.getName(), intf.getPackageName() + "." + intf.getName());
interfaceInfo.setProperty("JavaInterface", intf);
if (context.containsKey(ToolConstants.CFG_SEI_SUPER)) {
String[] supers = context.getArray(ToolConstants.CFG_SEI_SUPER);
for (String s : supers) {
intf.addSuperInterface(s);
}
}
}
return intf;
}
use of org.apache.cxf.tools.wsdlto.frontend.jaxws.customization.JAXWSBinding in project cxf by apache.
the class ServiceProcessor method processOperation.
private void processOperation(JavaModel model, BindingOperationInfo bop, BindingInfo binding) throws ToolException {
boolean enableOpMime = false;
JAXWSBinding bind = binding.getExtensor(JAXWSBinding.class);
if (bind != null && bind.isEnableMime()) {
enableOpMime = true;
}
JAXWSBinding bopBinding = bop.getExtensor(JAXWSBinding.class);
if (bopBinding != null && bopBinding.isEnableMime()) {
enableOpMime = true;
if (bopBinding.getJaxwsParas() != null) {
jaxwsBinding.setJaxwsParas(bopBinding.getJaxwsParas());
}
}
JavaInterface jf = null;
for (JavaInterface jf2 : model.getInterfaces().values()) {
if (binding.getInterface().getName().getLocalPart().equals(jf2.getWebServiceName())) {
jf = jf2;
}
}
if (jf == null) {
throw new ToolException("No Java Interface available");
}
if (isSoapBinding()) {
SoapBinding soapBinding = (SoapBinding) bindingObj;
if (SOAPBindingUtil.getSoapStyle(soapBinding.getStyle()) == null) {
jf.setSOAPStyle(javax.jws.soap.SOAPBinding.Style.DOCUMENT);
} else {
jf.setSOAPStyle(SOAPBindingUtil.getSoapStyle(soapBinding.getStyle()));
}
} else {
// REVISIT: fix for xml binding
jf.setSOAPStyle(javax.jws.soap.SOAPBinding.Style.DOCUMENT);
}
Object[] methods = jf.getMethods().toArray();
for (int i = 0; i < methods.length; i++) {
JavaMethod jm = (JavaMethod) methods[i];
if (jm.getOperationName() != null && jm.getOperationName().equals(bop.getName().getLocalPart())) {
if (isSoapBinding()) {
// TODO: add customize here
// doCustomizeOperation(jf, jm, bop);
Map<String, Object> prop = getSoapOperationProp(bop);
String soapAction = prop.get(soapOPAction) == null ? "" : (String) prop.get(soapOPAction);
String soapStyle = prop.get(soapOPStyle) == null ? "" : (String) prop.get(soapOPStyle);
jm.setSoapAction(soapAction);
if (SOAPBindingUtil.getSoapStyle(soapStyle) == null && this.bindingObj == null) {
org.apache.cxf.common.i18n.Message msg = new org.apache.cxf.common.i18n.Message("BINDING_STYLE_NOT_DEFINED", LOG);
throw new ToolException(msg);
}
if (SOAPBindingUtil.getSoapStyle(soapStyle) == null) {
jm.setSoapStyle(jf.getSOAPStyle());
} else {
jm.setSoapStyle(SOAPBindingUtil.getSoapStyle(soapStyle));
}
} else {
// REVISIT: fix for xml binding
jm.setSoapStyle(jf.getSOAPStyle());
}
if (jm.getSoapStyle().equals(javax.jws.soap.SOAPBinding.Style.RPC)) {
jm.getAnnotationMap().remove("SOAPBinding");
}
OperationProcessor processor = new OperationProcessor(context);
int headerType = isNonWrappable(bop);
OperationInfo opinfo = bop.getOperationInfo();
JAXWSBinding opBinding = opinfo.getExtensor(JAXWSBinding.class);
JAXWSBinding infBinding = opinfo.getInterface().getExtensor(JAXWSBinding.class);
boolean enableMime = enableOpMime;
boolean enableWrapperStyle = true;
if (infBinding != null && infBinding.isSetEnableWrapperStyle()) {
enableWrapperStyle = infBinding.isEnableWrapperStyle();
}
if (infBinding != null && infBinding.isSetEnableMime()) {
enableMime = infBinding.isEnableMime();
}
if (opBinding != null && opBinding.isSetEnableWrapperStyle()) {
enableWrapperStyle = opBinding.isEnableWrapperStyle();
}
if (opBinding != null && opBinding.isSetEnableMime()) {
enableMime = opBinding.isEnableMime();
}
if (jaxwsBinding.isEnableMime() || enableMime) {
jm.setMimeEnable(true);
}
if ((jm.isWrapperStyle() && headerType > this.noHEADER) || !jaxwsBinding.isEnableWrapperStyle() || (jm.enableMime() && jm.isWrapperStyle()) || !enableWrapperStyle) {
// changed wrapper style
jm.setWrapperStyle(false);
processor.processMethod(jm, bop.getOperationInfo());
jm.getAnnotationMap().remove("ResponseWrapper");
jm.getAnnotationMap().remove("RequestWrapper");
} else {
processor.processMethod(jm, bop.getOperationInfo());
}
if (headerType == this.resultHeader) {
JAnnotation resultAnno = jm.getAnnotationMap().get("WebResult");
if (resultAnno != null) {
resultAnno.addElement(new JAnnotationElement("header", true, true));
}
}
processParameter(jm, bop);
}
}
}
use of org.apache.cxf.tools.wsdlto.frontend.jaxws.customization.JAXWSBinding in project cxf by apache.
the class MethodMapper method map.
public JavaMethod map(OperationInfo operation) {
JavaMethod method = new JavaMethod();
// set default Document Bare style
method.setSoapStyle(javax.jws.soap.SOAPBinding.Style.DOCUMENT);
String operationName = operation.getName().getLocalPart();
method.setName(ProcessorUtil.mangleNameToVariableName(operationName));
method.setOperationName(operationName);
JAXWSBinding opBinding = operation.getExtensor(JAXWSBinding.class);
if (opBinding != null && opBinding.getMethodName() != null) {
method.setName(opBinding.getMethodName());
}
if (opBinding != null && opBinding.getMethodJavaDoc() != null) {
method.setJavaDoc(opBinding.getMethodJavaDoc());
} else {
method.setJavaDoc(operation.getDocumentation());
}
if (operation.isOneWay()) {
method.setStyle(OperationType.ONE_WAY);
} else {
method.setStyle(OperationType.REQUEST_RESPONSE);
}
method.setWrapperStyle(operation.isUnwrappedCapable());
return method;
}
Aggregations