use of javax.wsdl.Part in project cxf by apache.
the class WSIBPValidator method checkR2203And2204.
public boolean checkR2203And2204() {
Collection<Binding> bindings = CastUtils.cast(def.getBindings().values());
for (Binding binding : bindings) {
String style = SOAPBindingUtil.getCanonicalBindingStyle(binding);
if (binding.getPortType() == null) {
return true;
}
for (Iterator<?> ite2 = binding.getPortType().getOperations().iterator(); ite2.hasNext(); ) {
Operation operation = (Operation) ite2.next();
BindingOperation bop = wsdlHelper.getBindingOperation(def, operation.getName());
if (operation.getInput() != null && operation.getInput().getMessage() != null) {
Message inMess = operation.getInput().getMessage();
Set<String> ignorableParts = getIgnorableParts(bop.getBindingInput());
for (Iterator<?> ite3 = inMess.getParts().values().iterator(); ite3.hasNext(); ) {
Part p = (Part) ite3.next();
if (SOAPBinding.Style.RPC.name().equalsIgnoreCase(style) && p.getTypeName() == null && !isHeaderPart(bop, p) && !isIgnorablePart(p.getName(), ignorableParts)) {
addErrorMessage("An rpc-literal binding in a DESCRIPTION MUST refer, " + "in its soapbind:body element(s), only to " + "wsdl:part element(s) that have been defined " + "using the type attribute.");
return false;
}
if (SOAPBinding.Style.DOCUMENT.name().equalsIgnoreCase(style) && p.getElementName() == null && !isIgnorablePart(p.getName(), ignorableParts)) {
addErrorMessage("A document-literal binding in a DESCRIPTION MUST refer, " + "in each of its soapbind:body element(s)," + "only to wsdl:part element(s)" + " that have been defined using the element attribute.");
return false;
}
}
}
if (operation.getOutput() != null && operation.getOutput().getMessage() != null) {
Message outMess = operation.getOutput().getMessage();
Set<String> ignorableParts = getIgnorableParts(bop.getBindingOutput());
for (Iterator<?> ite3 = outMess.getParts().values().iterator(); ite3.hasNext(); ) {
Part p = (Part) ite3.next();
if (style.equalsIgnoreCase(SOAPBinding.Style.RPC.name()) && p.getTypeName() == null && !isHeaderPart(bop, p) && !isIgnorablePart(p.getName(), ignorableParts)) {
addErrorMessage("An rpc-literal binding in a DESCRIPTION MUST refer, " + "in its soapbind:body element(s), only to " + "wsdl:part element(s) that have been defined " + "using the type attribute.");
return false;
}
if (style.equalsIgnoreCase(SOAPBinding.Style.DOCUMENT.name()) && p.getElementName() == null && !isIgnorablePart(p.getName(), ignorableParts)) {
addErrorMessage("A document-literal binding in a DESCRIPTION MUST refer, " + "in each of its soapbind:body element(s)," + "only to wsdl:part element(s)" + " that have been defined using the element attribute.");
return false;
}
}
}
}
}
return true;
}
use of javax.wsdl.Part 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 javax.wsdl.Part in project cxf by apache.
the class WSDLToSoapProcessor method validate.
private void validate() throws ToolException {
if (isBindingExisted()) {
Message msg = new Message("BINDING_ALREADY_EXIST", LOG);
throw new ToolException(msg);
}
if (!isPortTypeExisted()) {
Message msg = new Message("PORTTYPE_NOT_EXIST", LOG);
throw new ToolException(msg);
}
if (!nameSpaceCheck()) {
Message msg = new Message("SOAPBINDING_STYLE_NOT_PROVIDED", LOG);
throw new ToolException(msg);
}
if (WSDLConstants.RPC.equalsIgnoreCase((String) env.get(ToolConstants.CFG_STYLE))) {
Collection<Operation> ops = CastUtils.cast(portType.getOperations());
for (Operation op : ops) {
Input input = op.getInput();
if (input != null && input.getMessage() != null) {
Collection<Part> parts = CastUtils.cast(input.getMessage().getParts().values());
for (Part part : parts) {
if (part.getTypeName() == null || "".equals(part.getTypeName().toString())) {
Message msg = new Message("RPC_PART_ILLEGAL", LOG, new Object[] { part.getName() });
throw new ToolException(msg);
}
}
}
Output output = op.getOutput();
if (output != null && output.getMessage() != null) {
Collection<Part> parts = CastUtils.cast(output.getMessage().getParts().values());
for (Part part : parts) {
if (part.getTypeName() == null || "".equals(part.getTypeName().toString())) {
Message msg = new Message("RPC_PART_ILLEGAL", LOG, new Object[] { part.getName() });
throw new ToolException(msg);
}
}
}
}
}
}
use of javax.wsdl.Part in project carbon-business-process by wso2.
the class SOAPUtils method handleSoapHeaderPartDef.
private static void handleSoapHeaderPartDef(org.apache.ode.bpel.iapi.Message odeMessage, Definition wsdl, SOAPHeader header, javax.wsdl.extensions.soap.SOAPHeader headerdef, Message msgType) throws BPELFault {
// Is this header part of the "payload" messsage?
boolean payloadMessageHeader = headerdef.getMessage() == null || headerdef.getMessage().equals(msgType.getQName());
boolean requiredHeader = payloadMessageHeader || (headerdef.getRequired() != null && headerdef.getRequired());
if (requiredHeader && header == null) {
throw new BPELFault("SOAP Header missing required element.");
}
if (header == null) {
return;
}
Message hdrMsg = wsdl.getMessage(headerdef.getMessage());
if (hdrMsg == null) {
return;
}
Part p = hdrMsg.getPart(headerdef.getPart());
if (p == null || p.getElementName() == null) {
return;
}
OMElement headerEl = header.getFirstChildWithName(p.getElementName());
if (requiredHeader && headerEl == null) {
throw new BPELFault("SOAP Header missing required element: " + p.getElementName());
}
if (headerEl == null) {
return;
}
odeMessage.setHeaderPart(p.getName(), OMUtils.toDOM(headerEl));
}
use of javax.wsdl.Part in project carbon-business-process by wso2.
the class SOAPUtils method buildSoapDetail.
private static OMElement buildSoapDetail(final BPELMessageContext bpelMessageContext, final MessageExchange odeMessageContext) throws AxisFault {
Element message = odeMessageContext.getResponse().getMessage();
QName faultName = odeMessageContext.getFault();
Operation operation = odeMessageContext.getOperation();
SOAPFactory soapFactory = bpelMessageContext.getSoapFactoryForCurrentMessageFlow();
if (faultName.getNamespaceURI() == null) {
return toFaultDetail(message, soapFactory);
}
Fault f = operation.getFault(faultName.getLocalPart());
if (f == null) {
return toFaultDetail(message, soapFactory);
}
// For faults, there will be exactly one part.
Part p = (Part) f.getMessage().getParts().values().iterator().next();
if (p == null) {
return toFaultDetail(message, soapFactory);
}
Element partEl = DOMUtils.findChildByName(message, new QName(null, p.getName()));
if (partEl == null) {
return toFaultDetail(message, soapFactory);
}
Element detail = DOMUtils.findChildByName(partEl, p.getElementName());
if (detail == null) {
return toFaultDetail(message, soapFactory);
}
return OMUtils.toOM(detail, soapFactory);
}
Aggregations