use of org.wso2.carbon.apimgt.impl.wsdl.model.WSDLOperation in project carbon-apimgt by wso2.
the class WSDL11ProcessorImpl method getHttpBindingOperations.
/**
* Retrieves all the operations defined in the provided Binding.
*
* @param binding WSDL binding
* @return a set of {@link WSDLOperation} defined in the provided Binding
*/
private Set<WSDLOperation> getHttpBindingOperations(Binding binding) {
Set<WSDLOperation> allBindingOperations = new HashSet<>();
if (binding.getExtensibilityElements() != null && binding.getExtensibilityElements().size() > 0) {
if (binding.getExtensibilityElements().get(0) instanceof HTTPBinding) {
HTTPBinding httpBinding = (HTTPBinding) binding.getExtensibilityElements().get(0);
String verb = httpBinding.getVerb();
for (Object opObj : binding.getBindingOperations()) {
if (opObj instanceof BindingOperation) {
BindingOperation bindingOperation = (BindingOperation) opObj;
WSDLOperation wsdlOperation = getOperation(bindingOperation, verb);
if (wsdlOperation != null) {
allBindingOperations.add(wsdlOperation);
}
}
}
}
}
return allBindingOperations;
}
use of org.wso2.carbon.apimgt.impl.wsdl.model.WSDLOperation in project carbon-apimgt by wso2.
the class WSDL11ProcessorImpl method getHttpBindingOperations.
/**
* Retrieves all the operations defined in the provided WSDL definition.
*
* @param definition WSDL Definition
* @return a set of {@link WSDLOperation} defined in the provided WSDL definition
*/
private Set<WSDLOperation> getHttpBindingOperations(Definition definition) {
Set<WSDLOperation> allOperations = new HashSet<>();
for (Object bindingObj : definition.getAllBindings().values()) {
if (bindingObj instanceof Binding) {
Binding binding = (Binding) bindingObj;
Set<WSDLOperation> operations = getHttpBindingOperations(binding);
allOperations.addAll(operations);
}
}
return allOperations;
}
use of org.wso2.carbon.apimgt.impl.wsdl.model.WSDLOperation in project carbon-apimgt by wso2.
the class WSDL11SOAPOperationExtractor method getSOAPOperation.
/**
* Retrieves WSDL operation given the soap binding operation
*
* @param bindingOperation {@link BindingOperation} object
* @return a set of {@link WSDLOperation} defined in the provided Binding
*/
private WSDLSOAPOperation getSOAPOperation(BindingOperation bindingOperation) throws APIMgtWSDLException {
WSDLSOAPOperation wsdlOperation = null;
for (Object boExtElement : bindingOperation.getExtensibilityElements()) {
if (boExtElement instanceof SOAPOperation) {
SOAPOperation soapOperation = (SOAPOperation) boExtElement;
wsdlOperation = new WSDLSOAPOperation();
wsdlOperation.setName(bindingOperation.getName());
wsdlOperation.setSoapAction(soapOperation.getSoapActionURI());
wsdlOperation.setTargetNamespace(getTargetNamespace(bindingOperation));
wsdlOperation.setStyle(soapOperation.getStyle());
wsdlOperation.setInputParameterModel(getSoapInputParameterModel(bindingOperation));
wsdlOperation.setOutputParameterModel(getSoapOutputParameterModel(bindingOperation));
wsdlOperation.setMessageType(getSoapMessageType(bindingOperation));
} else if (boExtElement instanceof SOAP12Operation) {
SOAP12Operation soapOperation = (SOAP12Operation) boExtElement;
wsdlOperation = new WSDLSOAPOperation();
wsdlOperation.setName(bindingOperation.getName());
wsdlOperation.setSoapAction(soapOperation.getSoapActionURI());
wsdlOperation.setTargetNamespace(getTargetNamespace(bindingOperation));
wsdlOperation.setStyle(soapOperation.getStyle());
wsdlOperation.setInputParameterModel(getSoapInputParameterModel(bindingOperation));
wsdlOperation.setOutputParameterModel(getSoapOutputParameterModel(bindingOperation));
wsdlOperation.setMessageType(getSoapMessageType(bindingOperation));
}
}
return wsdlOperation;
}
use of org.wso2.carbon.apimgt.impl.wsdl.model.WSDLOperation in project carbon-apimgt by wso2.
the class WSDL11SOAPOperationExtractor method getSoapBindingOperations.
/**
* Retrieves all the operations defined in the provided WSDL definition.
*
* @param definition WSDL Definition
* @return a set of {@link WSDLOperation} defined in the provided WSDL definition
*/
private Set<WSDLSOAPOperation> getSoapBindingOperations(Definition definition) throws APIMgtWSDLException {
Set<WSDLSOAPOperation> allOperations = new HashSet<>();
for (Object bindingObj : definition.getAllBindings().values()) {
if (bindingObj instanceof Binding) {
Binding binding = (Binding) bindingObj;
Set<WSDLSOAPOperation> operations = getSOAPBindingOperations(binding);
allOperations.addAll(operations);
}
}
return allOperations;
}
use of org.wso2.carbon.apimgt.impl.wsdl.model.WSDLOperation in project carbon-business-process by wso2.
the class SOAPUtils method handleSOAPHeaderElementsInBindingOperation.
@SuppressWarnings("unchecked")
private static void handleSOAPHeaderElementsInBindingOperation(SOAPEnvelope soapEnvelope, SOAPFactory soapFactory, org.apache.ode.bpel.iapi.Message messageFromOde, Operation wsdlOperation, final javax.wsdl.extensions.soap.SOAPHeader soapHeaderElementDefinition) throws BPELFault {
Map<String, Node> headerParts = messageFromOde.getHeaderParts();
Message responseMessageDefinition = wsdlOperation.getOutput() != null ? wsdlOperation.getOutput().getMessage() : null;
// If there isn't a message attribute in header element definition or if the
// message attribute value is equal to the response message QName, then this
// header element is part of the actual payload.
// Refer SOAP Binding specification at http://www.w3.org/TR/wsdl#_soap-b.
final boolean isHeaderElementAPartOfPayload = soapHeaderElementDefinition.getMessage() == null || ((wsdlOperation.getStyle() != OperationType.ONE_WAY) && soapHeaderElementDefinition.getMessage().equals(responseMessageDefinition.getQName()));
if (soapHeaderElementDefinition.getPart() == null) {
// Part information not found. Ignoring this header definition.
return;
}
if (isHeaderElementAPartOfPayload && (responseMessageDefinition != null && responseMessageDefinition.getPart(soapHeaderElementDefinition.getPart()) == null)) {
// we should throw a exception.
throw new BPELFault("SOAP Header Element Definition refer unknown part.");
}
Element partElement = null;
if (headerParts.size() > 0 && isHeaderElementAPartOfPayload) {
try {
partElement = (Element) headerParts.get(soapHeaderElementDefinition.getPart());
} catch (ClassCastException e) {
throw new BPELFault("SOAP Header must be a DOM Element.", e);
}
}
// message payload. This is because, some headers will provided by SOAP engine.
if (partElement == null && isHeaderElementAPartOfPayload) {
if (messageFromOde.getPart(soapHeaderElementDefinition.getPart()) != null) {
partElement = messageFromOde.getPart(soapHeaderElementDefinition.getPart());
} else {
throw new BPELFault("Missing Required part in response message.");
}
}
// and can be found and extracted from the odeMessage object
if (partElement == null && messageFromOde.getParts().size() > 0 && !isHeaderElementAPartOfPayload) {
try {
partElement = (Element) messageFromOde.getPart(soapHeaderElementDefinition.getPart());
} catch (ClassCastException e) {
throw new BPELFault("Soap header must be an element" + messageFromOde.getPart(soapHeaderElementDefinition.getPart()));
}
}
// just ignore this case.
if (partElement == null) {
return;
}
org.apache.axiom.soap.SOAPHeader soapHeader = soapEnvelope.getHeader();
if (soapHeader == null) {
soapHeader = soapFactory.createSOAPHeader(soapEnvelope);
}
OMElement omPart = OMUtils.toOM(partElement, soapFactory);
for (Iterator<OMNode> i = omPart.getChildren(); i.hasNext(); ) {
soapHeader.addChild(i.next());
}
}
Aggregations