use of javax.wsdl.extensions.soap.SOAPBody in project tdi-studio-se by Talend.
the class ComponentBuilder method buildOperation.
private OperationInfo buildOperation(OperationInfo operationInfo, BindingOperation bindingOper) {
Operation oper = bindingOper.getOperation();
operationInfo.setTargetMethodName(oper.getName());
Vector operElems = findExtensibilityElement(bindingOper.getExtensibilityElements(), "operation");
ExtensibilityElement operElem = (ExtensibilityElement) operElems.elementAt(0);
if (operElem != null && operElem instanceof SOAPOperation) {
SOAPOperation soapOperation = (SOAPOperation) operElem;
operationInfo.setSoapActionURI(soapOperation.getSoapActionURI());
} else if (operElem != null && operElem instanceof SOAP12Operation) {
SOAP12Operation soapOperation = (SOAP12Operation) operElem;
operationInfo.setSoapActionURI(soapOperation.getSoapActionURI());
}
BindingInput bindingInput = bindingOper.getBindingInput();
BindingOutput bindingOutput = bindingOper.getBindingOutput();
Vector bodyElems = findExtensibilityElement(bindingInput.getExtensibilityElements(), "body");
ExtensibilityElement bodyElem = (ExtensibilityElement) bodyElems.elementAt(0);
if (bodyElem != null && bodyElem instanceof SOAPBody) {
SOAPBody soapBody = (SOAPBody) bodyElem;
List styles = soapBody.getEncodingStyles();
String encodingStyle = null;
if (styles != null) {
encodingStyle = styles.get(0).toString();
}
if (encodingStyle == null) {
encodingStyle = DEFAULT_SOAP_ENCODING_STYLE;
}
operationInfo.setEncodingStyle(encodingStyle.toString());
operationInfo.setTargetObjectURI(soapBody.getNamespaceURI());
} else if (bodyElem != null && bodyElem instanceof SOAP12Body) {
SOAP12Body soapBody = (SOAP12Body) bodyElem;
String encodingStyle = null;
if (soapBody.getEncodingStyle() != null) {
encodingStyle = soapBody.getEncodingStyle().toString();
}
if (encodingStyle == null) {
encodingStyle = DEFAULT_SOAP_ENCODING_STYLE;
}
operationInfo.setEncodingStyle(encodingStyle.toString());
operationInfo.setTargetObjectURI(soapBody.getNamespaceURI());
}
Input inDef = oper.getInput();
if (inDef != null) {
Message inMsg = inDef.getMessage();
if (inMsg != null) {
operationInfo.setInputMessageName(inMsg.getQName().getLocalPart());
getParameterFromMessage(operationInfo, inMsg, 1);
operationInfo.setInmessage(inMsg);
}
}
Output outDef = oper.getOutput();
if (outDef != null) {
Message outMsg = outDef.getMessage();
if (outMsg != null) {
operationInfo.setOutputMessageName(outMsg.getQName().getLocalPart());
getParameterFromMessage(operationInfo, outMsg, 2);
operationInfo.setOutmessage(outMsg);
}
}
return operationInfo;
}
use of javax.wsdl.extensions.soap.SOAPBody in project carbon-business-process by wso2.
the class WSDLAwareSOAPProcessor method processMessageParts.
private WSDLAwareMessage processMessageParts(BindingInput bindingInput) throws AxisFault {
WSDLAwareMessage message = new WSDLAwareMessage();
message.setBinding(wsdlBinding);
List parts;
String namespace;
if (soap12) {
SOAP12Body soapBodyDef = getFirstExtensibilityElement(bindingInput, SOAP12Body.class);
if (soapBodyDef == null) {
String errMessage = "SOAPBody null for binding input.";
log.error(errMessage);
throw new AxisFault(errMessage);
}
parts = soapBodyDef.getParts();
namespace = soapBodyDef.getNamespaceURI();
} else {
SOAPBody soapBodyDef = getFirstExtensibilityElement(bindingInput, SOAPBody.class);
if (soapBodyDef == null) {
String errMessage = "SOAPBody null for binding input.";
log.error(errMessage);
throw new AxisFault(errMessage);
}
parts = soapBodyDef.getParts();
namespace = soapBodyDef.getNamespaceURI();
}
QName axisOperationName = inMessageCtx.getAxisOperation().getName();
/**
* Local part of the axis Operation's name equals to WSDL Operation name.
*/
Operation op = wsdlBinding.getPortType().getOperation(axisOperationName.getLocalPart(), null, null);
String rpcWrapper = op.getName();
List bodyParts = op.getInput().getMessage().getOrderedParts(parts);
if (isRPC) {
message.setRPC(true);
QName rpWrapperQName = new QName(namespace, rpcWrapper);
OMElement partWrapper = inMessageCtx.getEnvelope().getBody().getFirstChildWithName(rpWrapperQName);
if (partWrapper == null) {
String errMsg = "SOAP Body doesn't contain expected part wrapper.";
log.error(errMsg);
throw new AxisFault(errMsg);
}
/* In RPC the body element is the operation name, wrapping parts. Order doesn't really
* matter as far as we're concerned. All we need to do is copy the soap:body children,
* since doc-lit rpc looks the same in ode and soap.*/
for (Object partDef : bodyParts) {
OMElement srcPart = partWrapper.getFirstChildWithName(new QName(null, ((Part) partDef).getName()));
if (srcPart == null) {
throw new AxisFault("SOAP Body doesn't contain required part " + ((Part) partDef).getName() + ".");
}
message.addBodyPart(srcPart.getLocalName(), srcPart);
}
} else {
/**
* In doc-literal style, we expect the elements in the body to correspond (in order) to
* the parts defined in the binding. All the parts should be element-typed, otherwise
* it is a mess.
*/
message.setRPC(false);
Iterator srcParts = inMessageCtx.getEnvelope().getBody().getChildElements();
for (Object partDef : bodyParts) {
if (!srcParts.hasNext()) {
throw new AxisFault("SOAP Body does not contain required part" + ((Part) partDef).getName() + ".");
}
OMElement srcPart = (OMElement) srcParts.next();
if (((Part) partDef).getElementName() == null) {
throw new AxisFault("Binding defines non-element document literal part(s)");
}
if (!srcPart.getQName().equals(((Part) partDef).getElementName())) {
throw new AxisFault("Unexpected element in SOAP body.");
}
message.addBodyPart(((Part) partDef).getName(), srcPart);
}
}
processSoapHeaderParts(message, bindingInput, op);
return message;
}
use of javax.wsdl.extensions.soap.SOAPBody in project carbon-business-process by wso2.
the class WSDLAwareSOAPProcessor method processMessageParts.
private WSDLAwareMessage processMessageParts(BindingInput bindingInput) throws AxisFault {
WSDLAwareMessage message = new WSDLAwareMessage();
message.setTenantId(this.tenantId);
SOAPBody soapBodyDef = getFirstExtensibilityElement(bindingInput, SOAPBody.class);
if (soapBodyDef == null) {
String errMessage = "SOAPBody null for binding input.";
log.error(errMessage);
throw new AxisFault(errMessage);
}
QName axisOperationName = inMessageCtx.getAxisOperation().getName();
/**
* Local part of the axis Operation's name equals to WSDL Operation name.
*/
Operation op = wsdlBinding.getPortType().getOperation(axisOperationName.getLocalPart(), null, null);
message.setPortTypeName(wsdlBinding.getPortType().getQName());
message.setOperationName(op.getName());
String rpcWrapper = op.getName();
List bodyParts = op.getInput().getMessage().getOrderedParts(soapBodyDef.getParts());
if (isRPC) {
// message.setRPC(true);
QName rpWrapperQName = new QName(wsdlBinding.getQName().getNamespaceURI(), rpcWrapper);
OMElement partWrapper = inMessageCtx.getEnvelope().getBody().getFirstChildWithName(rpWrapperQName);
if (partWrapper == null) {
String errMsg = "SOAP Body doesn't contain expected part wrapper.";
log.error(errMsg);
throw new AxisFault(errMsg);
}
/* In RPC the body element is the operation name, wrapping parts. Order doesn't really
* matter as far as we're concerned. All we need to do is copy the soap:body children,
* since doc-lit rpc looks the same in ode and soap.*/
for (Object partDef : bodyParts) {
OMElement srcPart = partWrapper.getFirstChildWithName(new QName(null, ((Part) partDef).getName()));
if (srcPart == null) {
throw new AxisFault("SOAP Body doesn't contain required part " + ((Part) partDef).getName() + ".");
}
message.addBodyPart(srcPart.getLocalName(), srcPart);
}
} else {
/**
* In doc-literal style, we expect the elements in the body to correspond (in order) to
* the parts defined in the binding. All the parts should be element-typed, otherwise
* it is a mess.
*/
// message.setRPC(false);
Iterator srcParts = inMessageCtx.getEnvelope().getBody().getChildElements();
for (Object partDef : bodyParts) {
if (!srcParts.hasNext()) {
throw new AxisFault("SOAP Body does not contain required part" + ((Part) partDef).getName() + ".");
}
OMElement srcPart = (OMElement) srcParts.next();
if (((Part) partDef).getElementName() == null) {
throw new AxisFault("Binding defines non-element document literal part(s)");
}
if (!srcPart.getQName().equals(((Part) partDef).getElementName())) {
throw new AxisFault("Unexpected element in SOAP body: " + srcPart.getQName() + " \nExpected: " + ((Part) partDef).getElementName());
}
message.addBodyPart(((Part) partDef).getName(), srcPart);
}
}
processSoapHeaderParts(message, bindingInput, op);
return message;
}
use of javax.wsdl.extensions.soap.SOAPBody in project tomee by apache.
the class LightWeightMappingValidator method visit.
@Override
protected void visit(BindingFault bindingFault) {
SOAPBody body = getSOAPBody(bindingFault.getExtensibilityElements());
String encoding = body.getUse();
if (encoding == null || !encoding.equals("encoded")) {
context.addFailure(new ValidationFailure("The use attribute of the binding fault operation must be 'encoded': " + bindingFault.getName()));
}
}
use of javax.wsdl.extensions.soap.SOAPBody in project cxf by apache.
the class PartialWSDLProcessor method getSoapBody.
private static SOAPBody getSoapBody(Class<?> parent, ExtensionRegistry extReg) throws Exception {
SOAPBody soapBody = SOAPBindingUtil.createSoapBody(extReg, parent, false);
soapBody.setUse(useLiteral);
return soapBody;
}
Aggregations