//adding new operation for the receive
Iterator<WsdlPortType> portTypes = wsdl.portTypes().iterator();
if(portTypes.hasNext()){
WsdlPortType newOperationPortType = portTypes.next();
WsdlPortTypeOperation newOp = newOperationPortType.addOperation(node.getOperationName());
XmlNamespace wsaNS = BUILDER.newNamespace("http://www.w3.org/2006/05/addressing/wsdl");
newOp.setInput(newInputMessage.getName(),newInputMessage);
String inputAction = serviceOperation.getInput().xml().attributeValue(wsaNS, "Action");
newInputMessage.xml().setAttributeValue(wsaNS, "Action", inputAction);
if(newOutputMessage != null){
newOp.setOutput(newOutputMessage.getName(), newOutputMessage);
String outputAction = serviceOperation.getOutput().xml().attributeValue(wsaNS, "Action");
newOutputMessage.xml().setAttributeValue(wsaNS, "Action", outputAction);
}
}
servicePortType = wsdlPortType;
}
addreceive(workflow.getOdeProcess(null, null), wsdl, operationName, newInputMessage.getName() ) ;
}
// find the binding for the operation in the service wsdl
Iterable<WsdlBinding> serviceBindings = serviceWSDL.bindings();
WsdlBinding serviceBinding = null;
for (WsdlBinding wsdlBinding : serviceBindings) {
if(wsdlBinding.getPortType().equals(servicePortType.getQName())){
serviceBinding = wsdlBinding;
break;
}
}
WsdlBindingOperation serviceBindingOperation = serviceBinding.getOperation(node.getOperationName());
//find the binding in the final wsdl
Iterator<WsdlPortType> portTypeItr = wsdl.portTypes().iterator();
if(portTypeItr.hasNext()){
WsdlPortType portType = portTypeItr.next();
Iterable<WsdlBinding> bindings = wsdl.bindings();
for (WsdlBinding wsdlBinding : bindings) {
if(wsdlBinding.getPortType().equals(portType.getQName())){
WsdlBindingOperation newBindingOperation = wsdlBinding.addOperation(node.getOperationName());
Iterable serviceBindingChildren = serviceBindingOperation.xml().children();
for (Object object : serviceBindingChildren) {
if(object instanceof XmlElement){
XmlElement newBindingOperationChild = ((XmlElement)object).clone();
newBindingOperation.xml().addElement(newBindingOperationChild);
//if this is the input element add a header binding because that is missing in the
// wsdl that this was copied from
if("input".equals(newBindingOperationChild.getName())){
XmlElement bindingBody = newBindingOperationChild.element("body");
bindingBody.setAttributeValue("parts", "input");
XmlNamespace soapNS = XmlConstants.BUILDER.newNamespace("http://schemas.xmlsoap.org/wsdl/soap/");
XmlElement bindingHeader = newBindingOperationChild.addElement(soapNS, "header");
bindingHeader.setAttributeValue("part", "leadHeader");
bindingHeader.setAttributeValue("use", "literal");
bindingHeader.setAttributeValue("message", "tns:"+newInputMessage.getName());