use of org.apache.cxf.binding.soap.wsdl.extensions.SoapHeader in project cxf by apache.
the class ServiceProcessor method isNonWrappable.
private int isNonWrappable(BindingOperationInfo bop) {
QName operationName = bop.getName();
MessageInfo bodyMessage = null;
QName headerMessage = null;
SoapHeader header = null;
boolean containParts = false;
boolean isSameMessage = false;
boolean isNonWrappable = false;
boolean allPartsHeader = false;
int result = this.noHEADER;
// begin process input
if (bop.getInput() != null && bop.getInput().getExtensors(ExtensibilityElement.class) != null) {
List<ExtensibilityElement> extensors = bop.getInput().getExtensors(ExtensibilityElement.class);
if (extensors != null) {
for (ExtensibilityElement ext : extensors) {
if (SOAPBindingUtil.isSOAPBody(ext)) {
bodyMessage = getMessage(operationName, true);
}
if (SOAPBindingUtil.isSOAPHeader(ext)) {
header = SOAPBindingUtil.getSoapHeader(ext);
headerMessage = header.getMessage();
if (header.getPart().length() > 0) {
containParts = true;
}
}
}
}
if (headerMessage != null && bodyMessage != null && headerMessage.getNamespaceURI().equalsIgnoreCase(bodyMessage.getName().getNamespaceURI()) && headerMessage.getLocalPart().equalsIgnoreCase(bodyMessage.getName().getLocalPart())) {
isSameMessage = true;
}
isNonWrappable = isSameMessage && containParts;
// if is nonwrapple then return
if (isNonWrappable) {
result = this.inHEADER;
}
}
isSameMessage = false;
containParts = false;
// process output
if (bop.getOutput() != null && bop.getOutput().getExtensors(ExtensibilityElement.class) != null) {
List<ExtensibilityElement> extensors = bop.getOutput().getExtensors(ExtensibilityElement.class);
if (extensors != null) {
for (ExtensibilityElement ext : extensors) {
if (SOAPBindingUtil.isSOAPBody(ext)) {
bodyMessage = getMessage(operationName, false);
}
if (SOAPBindingUtil.isSOAPHeader(ext)) {
header = SOAPBindingUtil.getSoapHeader(ext);
headerMessage = header.getMessage();
if (header.getPart().length() > 0) {
containParts = true;
}
}
}
}
if (headerMessage != null && bodyMessage != null && headerMessage.getNamespaceURI().equalsIgnoreCase(bodyMessage.getName().getNamespaceURI()) && headerMessage.getLocalPart().equalsIgnoreCase(bodyMessage.getName().getLocalPart())) {
isSameMessage = true;
if (bodyMessage.getMessagePartsNumber() == 1) {
allPartsHeader = true;
}
}
isNonWrappable = isSameMessage && containParts;
if (isNonWrappable && allPartsHeader) {
result = this.resultHeader;
}
if (isNonWrappable && !allPartsHeader) {
result = this.outHEADER;
}
}
return result;
}
use of org.apache.cxf.binding.soap.wsdl.extensions.SoapHeader in project cxf by apache.
the class WSIBPValidator method checkR2201Output.
private boolean checkR2201Output(final Operation operation, final BindingOperation bop) {
int outmessagePartsCount = wsdlHelper.getOutMessageParts(operation).size();
SoapBody soapBody = SOAPBindingUtil.getBindingOutputSOAPBody(bop);
if (soapBody != null) {
List<?> parts = soapBody.getParts();
int boundPartSize = parts == null ? outmessagePartsCount : parts.size();
SoapHeader soapHeader = SOAPBindingUtil.getBindingOutputSOAPHeader(bop);
boundPartSize = soapHeader != null && soapHeader.getMessage().equals(operation.getOutput().getMessage().getQName()) ? boundPartSize - 1 : boundPartSize;
if (parts != null) {
Iterator<?> partsIte = parts.iterator();
while (partsIte.hasNext()) {
String partName = (String) partsIte.next();
boolean isDefined = false;
for (Part part : wsdlHelper.getOutMessageParts(operation)) {
if (partName.equalsIgnoreCase(part.getName())) {
isDefined = true;
break;
}
}
if (!isDefined) {
addErrorMessage(getErrorPrefix("WSI-BP-1.0 R2201") + "Operation '" + operation.getName() + "' soapBody parts : " + partName + " not found in the message, wrong WSDL");
return false;
}
}
} else {
if (wsdlHelper.getOutMessageParts(operation).size() > 1) {
addErrorMessage(getErrorPrefix("WSI-BP-1.0 R2210") + "Operation '" + operation.getName() + "' more than one part bound to body");
return false;
}
}
if (boundPartSize > 1) {
addErrorMessage(getErrorPrefix("WSI-BP-1.0 R2201") + "Operation '" + operation.getName() + "' more than one part bound to body");
return false;
}
}
return true;
}
use of org.apache.cxf.binding.soap.wsdl.extensions.SoapHeader in project cxf by apache.
the class WSIBPValidator method checkR2717AndR2726.
private boolean checkR2717AndR2726(final BindingOperation bop) {
if (null == bop) {
return true;
}
SoapBody inSoapBody = SOAPBindingUtil.getBindingInputSOAPBody(bop);
SoapBody outSoapBody = SOAPBindingUtil.getBindingOutputSOAPBody(bop);
if (inSoapBody != null && StringUtils.isEmpty(inSoapBody.getNamespaceURI()) || outSoapBody != null && StringUtils.isEmpty(outSoapBody.getNamespaceURI())) {
addErrorMessage(getErrorPrefix("WSI-BP-1.0 R2717") + "soapBody in the input/output of the binding operation '" + bop.getName() + "' MUST have namespace attribute");
return false;
}
SoapHeader inSoapHeader = SOAPBindingUtil.getBindingInputSOAPHeader(bop);
SoapHeader outSoapHeader = SOAPBindingUtil.getBindingOutputSOAPHeader(bop);
if (inSoapHeader != null && !StringUtils.isEmpty(inSoapHeader.getNamespaceURI()) || outSoapHeader != null && !StringUtils.isEmpty(outSoapHeader.getNamespaceURI())) {
addErrorMessage(getErrorPrefix("WSI-BP-1.0 R2726") + "Operation '" + bop.getName() + "' soapHeader MUST NOT have namespace attribute");
return false;
}
List<SoapFault> soapFaults = SOAPBindingUtil.getBindingOperationSoapFaults(bop);
for (SoapFault fault : soapFaults) {
if (!StringUtils.isEmpty(fault.getNamespaceURI())) {
addErrorMessage(getErrorPrefix("WSI-BP-1.0 R2726") + "Operation '" + bop.getName() + "' soapFault MUST NOT have namespace attribute");
return false;
}
}
return true;
}
use of org.apache.cxf.binding.soap.wsdl.extensions.SoapHeader in project cxf by apache.
the class ServiceProcessor method processParameter.
private void processParameter(JavaMethod jm, BindingOperationInfo operation) throws ToolException {
// process input
List<ExtensibilityElement> inbindings = null;
if (operation.getInput() != null) {
inbindings = operation.getInput().getExtensors(ExtensibilityElement.class);
}
if (inbindings == null) {
inbindings = new ArrayList<>();
}
String use = null;
for (ExtensibilityElement ext : inbindings) {
if (SOAPBindingUtil.isSOAPBody(ext)) {
SoapBody soapBody = SOAPBindingUtil.getSoapBody(ext);
use = soapBody.getUse();
} else if (SOAPBindingUtil.isSOAPHeader(ext)) {
processSoapHeader(jm, operation, ext);
}
if (ext instanceof MIMEMultipartRelated && jm.enableMime()) {
processMultipart(jm, operation, (MIMEMultipartRelated) ext, JavaType.Style.IN);
}
}
// process output
if (operation.getOutput() != null) {
List<ExtensibilityElement> outbindings = operation.getOutput().getExtensors(ExtensibilityElement.class);
if (outbindings == null) {
outbindings = new ArrayList<>();
}
for (ExtensibilityElement ext : outbindings) {
if (SOAPBindingUtil.isSOAPHeader(ext)) {
SoapHeader soapHeader = SOAPBindingUtil.getSoapHeader(ext);
if (isOutOfBandHeader(operation.getOutput(), ext)) {
continue;
}
boolean found = false;
for (JavaParameter parameter : jm.getParameters()) {
if (soapHeader.getPart().equals(parameter.getPartName())) {
setParameterAsHeader(parameter);
found = true;
}
}
if (jm.getReturn().getName() != null && jm.getReturn().getName().equals(soapHeader.getPart())) {
found = true;
}
if (Boolean.valueOf((String) context.get(ToolConstants.CFG_EXTRA_SOAPHEADER)) && !found) {
// Header can't be found in java method parameters, in
// different message
// other than messages used in porttype operation
ParameterProcessor processor = new ParameterProcessor(context);
MessagePartInfo exPart = service.getMessage(soapHeader.getMessage()).getMessagePart(new QName(soapHeader.getMessage().getNamespaceURI(), soapHeader.getPart()));
JavaParameter jp = processor.addParameterFromBinding(jm, exPart, JavaType.Style.OUT);
setParameterAsHeader(jp);
}
}
if (ext instanceof MIMEMultipartRelated && jm.enableMime()) {
processMultipart(jm, operation, (MIMEMultipartRelated) ext, JavaType.Style.OUT);
}
}
}
jm.setSoapUse(SOAPBindingUtil.getSoapUse(use));
if (javax.jws.soap.SOAPBinding.Style.RPC == jm.getSoapStyle() && javax.jws.soap.SOAPBinding.Use.ENCODED == jm.getSoapUse()) {
System.err.println("** Unsupported RPC-Encoded Style Use **");
}
if (javax.jws.soap.SOAPBinding.Style.RPC == jm.getSoapStyle() && javax.jws.soap.SOAPBinding.Use.LITERAL == jm.getSoapUse()) {
return;
}
if (javax.jws.soap.SOAPBinding.Style.DOCUMENT == jm.getSoapStyle() && javax.jws.soap.SOAPBinding.Use.LITERAL == jm.getSoapUse()) {
return;
}
}
use of org.apache.cxf.binding.soap.wsdl.extensions.SoapHeader in project cxf by apache.
the class WSIBPValidator method isHeaderPart.
private boolean isHeaderPart(final BindingOperation bop, final Part part) {
QName elementName = part.getElementName();
if (elementName != null) {
String partName = elementName.getLocalPart();
SoapHeader inSoapHeader = SOAPBindingUtil.getBindingInputSOAPHeader(bop);
if (inSoapHeader != null) {
return partName.equals(inSoapHeader.getPart());
}
SoapHeader outSoapHeader = SOAPBindingUtil.getBindingOutputSOAPHeader(bop);
if (outSoapHeader != null) {
return partName.equals(outSoapHeader.getPart());
}
}
return false;
}
Aggregations