use of org.wso2.carbon.humantask.core.integration.utils.ServiceInvocationContext in project carbon-business-process by wso2.
the class CallBackServiceImpl method sendProtocolMessage.
private void sendProtocolMessage(long taskID, String headerValue, String value) throws AxisFault {
final MessageContext mctx = new MessageContext();
ServiceInvocationContext invocationContext = new ServiceInvocationContext();
invocationContext.setInMessageContext(mctx);
invocationContext.setUep(uep);
invocationContext.setService(serviceName);
invocationContext.setPort(portName);
invocationContext.setCaller(taskName.getLocalPart());
invocationContext.setWsdlBindingForCurrentMessageFlow(binding);
invocationContext.setOperationName(operation);
if (mctx.getEnvelope() == null) {
mctx.setEnvelope(getSoapFactory().createSOAPEnvelope());
}
if (mctx.getEnvelope().getBody() == null) {
getSoapFactory().createSOAPBody(mctx.getEnvelope());
}
if (mctx.getEnvelope().getHeader() == null) {
getSoapFactory().createSOAPHeader(mctx.getEnvelope());
}
// Creating Dummy Element
// Extracting MessageName
List bindingOperations = binding.getBindingOperations();
String messageName = "";
OMNamespace serviceNS = null;
BindingOperation oper;
for (int i = 0; i < bindingOperations.size(); i++) {
oper = (BindingOperation) bindingOperations.get(i);
if (operation.equals(oper.getName())) {
Message message = oper.getOperation().getInput().getMessage();
messageName = message.getQName().getLocalPart();
for (Object ob : message.getParts().keySet()) {
// Here we don't support RPC messages.
Part part = (Part) message.getParts().get(ob);
serviceNS = OMAbstractFactory.getSOAP11Factory().createOMNamespace(part.getElementName().getNamespaceURI(), part.getElementName().getPrefix());
break;
}
break;
}
}
OMElement payload = OMAbstractFactory.getOMFactory().createOMElement(messageName, serviceNS);
mctx.getEnvelope().getBody().addChild(payload);
OMNamespace htpNS = OMAbstractFactory.getSOAP11Factory().createOMNamespace(HumanTaskConstants.HT_PROTOCOL_NAMESPACE, HumanTaskConstants.HT_PROTOCOL_DEFAULT_PREFIX);
SOAPHeaderBlock protocolHeader = mctx.getEnvelope().getHeader().addHeaderBlock(headerValue, htpNS);
protocolHeader.setText(value);
protocolHeader.addAttribute(HumanTaskConstants.B4P_CORRELATION_HEADER_ATTRIBUTE, Long.toString(taskID), htpNS);
OMNamespace b4pNS = OMAbstractFactory.getSOAP11Factory().createOMNamespace(HumanTaskConstants.B4P_NAMESPACE, "b4p");
SOAPHeaderBlock header = mctx.getEnvelope().getHeader().addHeaderBlock(HumanTaskConstants.B4P_CORRELATION_HEADER, b4pNS);
header.addAttribute(HumanTaskConstants.B4P_CORRELATION_HEADER_ATTRIBUTE, Long.toString(taskID), b4pNS);
AxisServiceUtils.invokeService(invocationContext, HumanTaskServiceComponent.getHumanTaskServer().getTaskStoreManager().getHumanTaskStore(tenantId).getConfigContext());
}
use of org.wso2.carbon.humantask.core.integration.utils.ServiceInvocationContext in project carbon-business-process by wso2.
the class CallBackServiceImpl method invoke.
@Override
public void invoke(OMElement payload, long taskId) throws AxisFault {
final MessageContext mctx = new MessageContext();
ServiceInvocationContext invocationContext = new ServiceInvocationContext();
invocationContext.setInMessageContext(mctx);
invocationContext.setUep(uep);
invocationContext.setService(serviceName);
invocationContext.setPort(portName);
invocationContext.setCaller(taskName.getLocalPart());
invocationContext.setWsdlBindingForCurrentMessageFlow(binding);
invocationContext.setOperationName(operation);
if (mctx.getEnvelope() == null) {
mctx.setEnvelope(getSoapFactory().createSOAPEnvelope());
}
if (mctx.getEnvelope().getBody() == null) {
getSoapFactory().createSOAPBody(mctx.getEnvelope());
}
if (mctx.getEnvelope().getHeader() == null) {
getSoapFactory().createSOAPHeader(mctx.getEnvelope());
}
mctx.getEnvelope().getBody().addChild(payload);
OMNamespace ns = OMAbstractFactory.getSOAP11Factory().createOMNamespace(HumanTaskConstants.B4P_NAMESPACE, "b4p");
SOAPHeaderBlock header = mctx.getEnvelope().getHeader().addHeaderBlock(HumanTaskConstants.B4P_CORRELATION_HEADER, ns);
header.addAttribute(HumanTaskConstants.B4P_CORRELATION_HEADER_ATTRIBUTE, Long.toString(taskId), ns);
AxisServiceUtils.invokeService(invocationContext, HumanTaskServiceComponent.getHumanTaskServer().getTaskStoreManager().getHumanTaskStore(tenantId).getConfigContext());
}
Aggregations