use of org.wso2.carbon.apimgt.core.models.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.core.models.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.core.models.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());
}
}
use of org.wso2.carbon.apimgt.core.models.WSDLOperation in project carbon-apimgt by wso2.
the class WSDL11ProcessorImpl method getWsdlInfo.
@Override
public WSDLInfo getWsdlInfo() throws APIMgtWSDLException {
WSDLInfo wsdlInfo = new WSDLInfo();
Map<String, String> endpointsMap = getEndpoints();
Set<WSDLOperation> operations = getHttpBindingOperations();
wsdlInfo.setEndpoints(endpointsMap);
wsdlInfo.setVersion(APIMgtConstants.WSDLConstants.WSDL_VERSION_11);
if (!operations.isEmpty()) {
wsdlInfo.setHasHttpBindingOperations(true);
wsdlInfo.setHttpBindingOperations(operations);
} else {
wsdlInfo.setHasHttpBindingOperations(false);
}
wsdlInfo.setHasSoapBindingOperations(hasSoapBindingOperations());
return wsdlInfo;
}
use of org.wso2.carbon.apimgt.core.models.WSDLOperation in project carbon-apimgt by wso2.
the class WSDL11ProcessorImpl method getHttpBindingOperations.
/**
* Retrieves all the operations defined in WSDL(s).
*
* @return a set of {@link WSDLOperation} defined in WSDL(s)
*/
private Set<WSDLOperation> getHttpBindingOperations() {
if (wsdlDefinition != null) {
return getHttpBindingOperations(wsdlDefinition);
} else {
Set<WSDLOperation> allOperations = new HashSet<>();
for (Definition definition : pathToDefinitionMap.values()) {
Set<WSDLOperation> operations = getHttpBindingOperations(definition);
allOperations.addAll(operations);
}
return allOperations;
}
}
Aggregations