use of org.wso2.ballerinalang.compiler.semantics.model.iterable.Operation in project carbon-business-process by wso2.
the class AxisServiceUtils method createAxisService.
/**
* Build the underlying Axis Service from Service QName and Port Name of interest using given WSDL
* for BPEL document.
* In the current implementation we are extracting service name from the soap:address' location property.
* But specified port may not contain soap:adress instead it may contains http:address. We need to handle that
* situation.
*
* @param axisConfiguration AxisConfiguration to which we should publish the service
* @param processProxy BPELProcessProxy
* @return Axis Service build using WSDL, Service and Port
* @throws org.apache.axis2.AxisFault on error
*/
public static AxisService createAxisService(AxisConfiguration axisConfiguration, BPELProcessProxy processProxy) throws AxisFault {
QName serviceName = processProxy.getServiceName();
String portName = processProxy.getPort();
Definition wsdlDefinition = processProxy.getWsdlDefinition();
ProcessConf processConfiguration = processProxy.getProcessConfiguration();
if (log.isDebugEnabled()) {
log.debug("Creating AxisService: Service=" + serviceName + " port=" + portName + " WSDL=" + wsdlDefinition.getDocumentBaseURI() + " BPEL=" + processConfiguration.getBpelDocument());
}
WSDL11ToAxisServiceBuilder serviceBuilder = createAxisServiceBuilder(processProxy);
/**
* Need to figure out a way to handle service name extractoin. According to my perspective extracting
* the service name from the EPR is not a good decision. But we need to handle JMS case properly.
* I am keeping JMS handling untouched until we figureout best solution.
*/
/* String axisServiceName = extractServiceName(processConf, wsdlServiceName, portName);*/
AxisService axisService = populateAxisService(processProxy, axisConfiguration, serviceBuilder);
Iterator operations = axisService.getOperations();
BPELMessageReceiver messageRec = new BPELMessageReceiver();
/**
* Set the corresponding BPELService to message receivers
*/
messageRec.setProcessProxy(processProxy);
while (operations.hasNext()) {
AxisOperation operation = (AxisOperation) operations.next();
// Setting WSDLAwareMessage Receiver even if operation has a message receiver specified.
// This is to fix the issue when build service configuration using services.xml(Always RPCMessageReceiver
// is set to operations).
operation.setMessageReceiver(messageRec);
axisConfiguration.getPhasesInfo().setOperationPhases(operation);
}
/**
* TODO: JMS Destination handling.
*/
return axisService;
}
use of org.wso2.ballerinalang.compiler.semantics.model.iterable.Operation 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);
}
use of org.wso2.ballerinalang.compiler.semantics.model.iterable.Operation 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.ballerinalang.compiler.semantics.model.iterable.Operation in project carbon-business-process by wso2.
the class SOAPUtils method populateSOAPBody.
@SuppressWarnings("unchecked")
private static void populateSOAPBody(SOAPEnvelope soapEnvelope, ElementExtensible bindingInput, boolean soap12, SOAPFactory soapFactory, Operation operation, Message messageDefinition, org.apache.ode.bpel.iapi.Message messageFromODE, boolean isRPC, boolean isRequest) throws BPELFault {
if (soap12) {
SOAP12Body soapBodyDefinition = getSOAP12Body(bindingInput);
if (soapBodyDefinition != null) {
SOAPBody soapBody;
if (soapEnvelope.getBody() != null) {
soapBody = soapEnvelope.getBody();
} else {
soapBody = soapFactory.createSOAPBody(soapEnvelope);
}
OMElement partHolder;
if (isRPC) {
String rpcWrapperElementName;
if (isRequest) {
rpcWrapperElementName = operation.getName();
} else {
rpcWrapperElementName = operation.getName() + "Response";
}
partHolder = createRPCWrapperElement(soapBody, soapFactory, new QName(soapBodyDefinition.getNamespaceURI(), rpcWrapperElementName));
} else {
partHolder = soapBody;
}
List<Part> parts = messageDefinition.getOrderedParts(soapBodyDefinition.getParts());
for (Part p : parts) {
Element partContent = DOMUtils.findChildByName(messageFromODE.getMessage(), new QName(null, p.getName()));
if (partContent == null) {
throw new BPELFault("Missing required part in ODE Message: " + new QName(null, p.getName()));
}
OMElement omPartContent = OMUtils.toOM(partContent, soapFactory);
if (isRPC) {
partHolder.addChild(omPartContent);
} else {
for (Iterator<OMNode> i = omPartContent.getChildren(); i.hasNext(); ) {
partHolder.addChild(i.next());
}
}
}
}
} else {
javax.wsdl.extensions.soap.SOAPBody soapBodyDefinition = getSOAP11Body(bindingInput);
if (soapBodyDefinition != null) {
SOAPBody soapBody;
if (soapEnvelope.getBody() != null) {
soapBody = soapEnvelope.getBody();
} else {
soapBody = soapFactory.createSOAPBody(soapEnvelope);
}
OMElement partHolder;
if (isRPC) {
String rpcWrapperElementName;
if (isRequest) {
rpcWrapperElementName = operation.getName();
} else {
rpcWrapperElementName = operation.getName() + "Response";
}
partHolder = createRPCWrapperElement(soapBody, soapFactory, new QName(soapBodyDefinition.getNamespaceURI(), rpcWrapperElementName));
} else {
partHolder = soapBody;
}
List<Part> parts = messageDefinition.getOrderedParts(soapBodyDefinition.getParts());
for (Part p : parts) {
Element partContent = DOMUtils.findChildByName(messageFromODE.getMessage(), new QName(null, p.getName()));
if (partContent == null) {
throw new BPELFault("Missing required part in ODE Message: " + new QName(null, p.getName()));
}
OMElement omPartContent = OMUtils.toOM(partContent, soapFactory);
if (isRPC) {
partHolder.addChild(omPartContent);
} else {
for (Iterator<OMNode> i = omPartContent.getChildren(); i.hasNext(); ) {
partHolder.addChild(i.next());
}
}
}
}
}
}
use of org.wso2.ballerinalang.compiler.semantics.model.iterable.Operation in project carbon-business-process by wso2.
the class SOAPUtils method parseSOAPResponseFromPartner.
public static org.apache.ode.bpel.iapi.Message parseSOAPResponseFromPartner(BPELMessageContext partnerInvocationContext, MessageExchange partnerRoleMessageExchange) throws BPELFault {
org.apache.ode.bpel.iapi.Message messageToODE = partnerRoleMessageExchange.createMessage(partnerRoleMessageExchange.getOperation().getOutput().getMessage().getQName());
BindingOperation bindingOp = getBindingOperation(partnerInvocationContext, partnerRoleMessageExchange.getOperationName());
BindingOutput bindingOutPut = getBindingOutPut(bindingOp);
SOAPEnvelope responseFromPartnerService = partnerInvocationContext.getOutMessageContext().getEnvelope();
if (partnerInvocationContext.isSoap12()) {
javax.wsdl.extensions.soap12.SOAP12Body soapBodyDefinition = getSOAP12Body(bindingOutPut);
if (soapBodyDefinition != null) {
if (responseFromPartnerService.getBody() != null) {
extractSOAPBodyParts(partnerRoleMessageExchange, messageToODE, responseFromPartnerService.getBody(), soapBodyDefinition.getParts(), soapBodyDefinition.getNamespaceURI(), partnerInvocationContext.isRPCStyleOperation());
} else {
throw new BPELFault("SOAP Body cannot be null for WSDL operation which " + "requires SOAP Body.");
}
}
} else {
javax.wsdl.extensions.soap.SOAPBody soapBodyDefinition = getSOAP11Body(bindingOutPut);
if (soapBodyDefinition != null) {
if (responseFromPartnerService.getBody() != null) {
extractSOAPBodyParts(partnerRoleMessageExchange, messageToODE, responseFromPartnerService.getBody(), soapBodyDefinition.getParts(), soapBodyDefinition.getNamespaceURI(), partnerInvocationContext.isRPCStyleOperation());
} else {
throw new BPELFault("SOAP Body cannot be null for WSDL operation which " + "requires SOAP Body.");
}
}
}
if (getSOAPHeaders(bindingOutPut) != null && responseFromPartnerService.getHeader() != null) {
extractSoapHeaderParts(messageToODE, partnerInvocationContext.getBpelServiceWSDLDefinition(), responseFromPartnerService.getHeader(), getSOAPHeaders(bindingOutPut), partnerRoleMessageExchange.getOperation().getOutput().getMessage());
}
return messageToODE;
}
Aggregations