Package xsul5.wsdl

Examples of xsul5.wsdl.WsdlDocumentation


        } else {
            throw new IllegalStateException("NO Service found in the workflow WSDL:" + workflowName);
        }

        Iterator<WsdlPort> ports = service.ports().iterator();
        WsdlPort port = null;
        if (ports.hasNext()) {
            port = ports.next();
        } else {
            throw new IllegalStateException("NO Port found in the workflow WSDL:" + workflowName);
        }
        String targetNamespace = gpelProcess.getTargetNamespace();
        String targetNamespacePrefix = "wfns";

        XmlNamespace odeNs = builder.newNamespace("http://www.apache.org/ode/schemas/dd/2007/03");
        XmlElement deploy = builder.newFragment(odeNs, "deploy");
        deploy.declareNamespace(PROCESS, targetNamespace);
        deploy.declareNamespace(targetNamespacePrefix, workflowWSDL.getTargetNamespace());

        XmlElement process = deploy.addElement(odeNs, PROCESS);
        process.setAttributeValue(NAME, PROCESS + ":" + workflowName);
        // active
        XmlElement active = process.addElement(odeNs, "active");
        active.addChild("true");

        // provide
        XmlElement provide = process.addElement(odeNs, "provide");
        provide.setAttributeValue("partnerLink", "workflowUserPartner");
        XmlElement providerService = provide.addElement(odeNs, "service");
        providerService.setAttributeValue("port", port.getName());
        providerService.setAttributeValue(NAME, targetNamespacePrefix + ":" + service.getName());

        org.xmlpull.infoset.XmlElement wsdlXml = workflowWSDL.xml();
        Iterable<org.xmlpull.infoset.XmlElement> partnerLinkTypes = wsdlXml.elements(null, "partnerLinkType");
View Full Code Here


    private void addReceive(ReceiveNode node, GpelSequence sequence) {
        String id = node.getID();
        String operationName = id;

        // Create this operation and type in WSDL.
        WsdlPortType portType = this.workflowWSDL.addReceivePortType(
                operationName, node);
        QName portTypeQName = portType.getQName();

        // Partner link
        String partnerLinkName = createPartnerLinkName(id);
        XmlNamespace partnerLinkTypeNS = this.targetNamespace;
        String partnerLinkTypeName = id + PARTNER_LINK_TYPE_SUFFIX;
View Full Code Here

                }
            }
            this.description = buf.toString();
        }

        WsdlPortType portType = this.wsdl.getPortType(this.portTypeQName
                .getLocalPart());
        if (portType == null) {
            throw new ComponentException("portType, " + this.portTypeQName
                    + " is not defined.");
        }
View Full Code Here

    public WorkflowComponent(WsdlDefinitions wsdl, QName portTypeQName,
            String operationName) throws ComponentException {
        super(wsdl, portTypeQName, operationName);
        try {
            // Get template ID from WSDL
            WsdlPortType portType = this.wsdl.getPortType(portTypeQName
                    .getLocalPart());
            XmlElement templateIDElement = portType.xml().element(
                    GPEL_NAMESPACE, WORKFLOW_TEMPLATE_ID_TAG);
            String templateIDString = templateIDElement.requiredText();
            this.templateID = new URI(templateIDString);
        } catch (URISyntaxException e) {
            throw new ComponentException(e);
View Full Code Here

     */
    public static URI getWorkflowTemplateID(WsdlDefinitions definitions)
            throws ComponentException {
        try {
            // Get template ID from WSDL
            WsdlPortType portType = WSDLUtil.getFirstPortType(definitions);
            XmlElement templateIDElement = portType.xml().element(
                    GPEL_NAMESPACE, WORKFLOW_TEMPLATE_ID_TAG);
            if (templateIDElement == null) {
                // Not a workflow
                return null;
            } else {
View Full Code Here

     * @throws ComponentException
     */
    public static List<WSComponent> createComponents(WsdlDefinitions wsdl)
            throws ComponentException {
        QName portTypeQName = WSDLUtil.getFirstPortTypeQName(wsdl);
        WsdlPortType portType = wsdl.getPortType(portTypeQName.getLocalPart());
        List<WSComponent> components = new ArrayList<WSComponent>();
        for (WsdlPortTypeOperation operation : portType.operations()) {
            String operationName = operation.getOperationName();
            WSComponent component = createComponent(wsdl, portTypeQName,
                    operationName);
            components.add(component);
        }
View Full Code Here

                operationName = WSDLUtil.getFirstOperationName(wsdl,
                        portTypeQName);
            }

            // check if it's WSComponent or WorkflowComponent
            WsdlPortType portType = wsdl.getPortType(portTypeQName
                    .getLocalPart());
            XmlElement templateIDElement = portType.xml().element(
                    WorkflowComponent.GPEL_NAMESPACE,
                    WorkflowComponent.WORKFLOW_TEMPLATE_ID_TAG);
            WSComponent component;
            if (templateIDElement == null) {
                component = new WSComponent(wsdl, portTypeQName, operationName);
View Full Code Here

  private QName findMessage(GpelProcess gpelProcess, QName portType, String opName, boolean input, Map<String, WsdlDefinitions> wsdls) {
    Iterator<String> iterator = wsdls.keySet().iterator();
    while (iterator.hasNext()) {
      String key = (String) iterator.next();
      WsdlDefinitions wsdlDefinitions = wsdls.get(key);
      WsdlPortType pType = wsdlDefinitions.getPortType(portType.getLocalPart());
      WsdlPortTypeOperation operation = null;
      if(null != pType && null != (operation = pType.getOperation(opName))){
       
        if(input){
          WsdlPortTypeInput messageRef = operation.getInput();
          if(null != messageRef &&
              null != messageRef.getMessage()){
View Full Code Here

          Iterator<String> keys = wsdls.keySet().iterator();
         
          while(keys.hasNext()){
            String key = keys.next();
            WsdlDefinitions wsdl = wsdls.get(key);
            WsdlPortType portType = wsdl.getPortType(portTypeName);
            if( null != portType){
              WsdlPortTypeOperation wsdlOperation = portType.getOperation(operation);
              WsdlMessagePart part  = wsdl.getMessage(wsdlOperation.getInput().getMessage().getLocalPart()).parts().iterator().next();
              XmlElement childElement = container.addElement(part.getElement().getLocalPart());
              Iterator<GpelAssignCopy> copyItr = assign.copyOperations().iterator();
              while(copyItr.hasNext()){
                GpelAssignCopy copyItm = copyItr.next();
                childElement.addElement(getElementName(copyItm.getTo().getQuery()));
                if(messagePartName == null){
                  messagePartName = copyItm.getTo().xml().attributeValue(PART_STR);
                }
              }
              break;
            }
          }
        }else {
          //reply
         
         
            WsdlPortType portType = workflowWSDL.getPortType(portTypeName);
            if( null != portType){
              WsdlPortTypeOperation wsdlOperation = portType.getOperation(operation);
              WsdlMessagePart part  = workflowWSDL.getMessage(wsdlOperation.getOutput().getMessage().getLocalPart()).parts().iterator().next();
              XmlElement childElement = container.addElement(part.getElement().getLocalPart());
              Iterator<GpelAssignCopy> copyItr = assign.copyOperations().iterator();
              while(copyItr.hasNext()){
                GpelAssignCopy copyItm = copyItr.next();
View Full Code Here

    boolean introduceNewNS = false;
    String operationName = node.getOperationName();
    WsdlMessage newInputMessage = null;
    Iterable<WsdlPortType> servicePortTypes = serviceWSDL.portTypes();
    WsdlPortTypeOperation serviceOperation = null;
    WsdlPortType servicePortType = null;
    for (WsdlPortType wsdlPortType : servicePortTypes) {
     
      serviceOperation = wsdlPortType.getOperation(operationName);
      if(serviceOperation != null){
        QName inputMessageName = serviceOperation.getInput().getMessage();
        WsdlMessagePart part = WSDLUtil.getfirst(serviceWSDL.getMessage(inputMessageName.getLocalPart()).parts());
       
        nsPrefix = part.getElement().getPrefix();
        oldNSPrefix = nsPrefix;
        introduceNewNS = false;
        while( null != wsdl.xml().lookupNamespaceByPrefix(nsPrefix)){
          //this namespace is already there so keep adding control at the end and check for
          //its existance
          nsPrefix += "_control";
          introduceNewNS = true;
        }
       
        wsdl.xml().declareNamespace(BUILDER.newNamespace(nsPrefix, serviceTns));
       
       
        WsdlMessage inputMessage = serviceWSDL.getMessage(inputMessageName.getLocalPart());
        newInputMessage = wsdl.addMessage(inputMessageName.getLocalPart());
        Iterable<WsdlMessagePart> parts = inputMessage.parts();
        for (WsdlMessagePart wsdlMessagePart : parts) {
          XmlElement newPart = null;
          if(introduceNewNS){
            XmlElement clone = wsdlMessagePart.xml().clone();
            String xmlAsString = BUILDER.serializeToString(clone).replaceAll(oldNSPrefix+":", nsPrefix+":");
            newPart= BUILDER.parseFragmentFromString(xmlAsString);
          }else{
            newPart = wsdlMessagePart.xml().clone();
          }
          newInputMessage.xml().addElement(newPart);
        }
        //add lead header part to the new input messag because this message is copied from the service wsdl.
       
        XmlElement newLeadHeaderPart = newInputMessage.xml().addElement(newInputMessage.xml().getNamespace(), "part");
        newLeadHeaderPart.setAttributeValue("name", "leadHeader");
        newLeadHeaderPart.setAttributeValue("element", "lc:context");
       
        WsdlMessage newOutputMessage = null;
        if(null != serviceOperation.getOutput()){
          QName outputMessageName = serviceOperation.getOutput().getMessage();
          WsdlMessage outputMessage = serviceWSDL.getMessage(outputMessageName.getLocalPart());
          newOutputMessage = wsdl.addMessage(outputMessageName.getLocalPart());
          Iterable<WsdlMessagePart> parts2 = outputMessage.parts();
          for (WsdlMessagePart wsdlMessagePart : parts2) {
            XmlElement newPart = null;
            if(introduceNewNS){
              XmlElement clone = wsdlMessagePart.xml().clone();
              String xmlAsString = BUILDER.serializeToString(clone).replaceAll(oldNSPrefix+":", nsPrefix+":");
              newPart = BUILDER.parseFragmentFromString(xmlAsString);
            }else{
              newPart = wsdlMessagePart.xml().clone();
            }
            newOutputMessage.xml().addElement(newPart);
          }
        }
       
       
       
       
        if(introduceNewNS){
          List<XmlNamespace> namespacesPresentInSchema = WSDLUtil.getNamespaces(serviceSchema);
          WSDLUtil.print(serviceSchema);
          for (XmlNamespace shouldBeDefinedNamespaces : namespacesPresentInSchema) {
            if(shouldBeDefinedNamespaces.getPrefix() != null &&
                null == wsdl.xml().lookupNamespaceByPrefix(shouldBeDefinedNamespaces.getPrefix())){
              wsdl.xml().declareNamespace(shouldBeDefinedNamespaces);
            }
           
          }
          XmlElement clone = serviceSchema.clone();
          String xmlAsString = BUILDER.serializeToString(clone).replaceAll(oldNSPrefix+":", nsPrefix+":");
          XmlElement newSchema= BUILDER.parseFragmentFromString(xmlAsString);
          types.addChild(newSchema);
         
          XmlElement crosscutImport = BUILDER.newFragment(newSchema.getNamespace(), "import");
          crosscutImport.setAttributeValue("namespace", "http://lead.extreme.indiana.edu/namespaces/2006/lead-crosscut-parameters/");
          crosscutImport.setAttributeValue("schemaLocation", "lead-crosscut-parameters.xsd");
          newSchema.addChild(0, crosscutImport);
        }else{
          types.addChild(serviceSchema.clone());
        }
        //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());
               
              }
             
            }
          }
          break;
        }
      }
    }
   
   
    WsdlPortType portType = WSDLUtil.getfirst(wsdl.portTypes());
    //Thinking that the first operation is the the one that is workflow input
    QName workflowInputMessage = WSDLUtil.getfirst(portType.operations()).getInput().getMessage();
    addCorrelationProperties(wsdl, wsdl.getMessage(workflowInputMessage.getLocalPart()),
        newInputMessage);

  }
View Full Code Here

TOP

Related Classes of xsul5.wsdl.WsdlDocumentation

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.