Package xsul5.wsdl

Examples of xsul5.wsdl.WsdlDocumentation


    String oldNSPrefix = null;
    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;
View Full Code Here


      while (iterator.hasNext()) {
        WsdlPortType portType = iterator.next();
        Iterator<WsdlPortTypeOperation> operations = portType
            .operations().iterator();
        while (operations.hasNext()) {
          WsdlPortTypeOperation operation = operations.next();
          WsdlMessagePart leadHeaderPart = new WsdlMessagePart(
              LEAD_HEADER);
          leadHeaderPart.setName(LEAD_HEADER);
          // we hand set this element to xml because when you use the
          // API it doent add the namespace correctly
          leadHeaderPart.xml().setAttributeValue(ELEMENT,
              LC_CONTEXT);

          wsdl.getMessage(
              operation.getInput().getMessage().getLocalPart())
              .addPart(leadHeaderPart);
        }
      }

      Iterator<WsdlBinding> bindingItr = wsdl.bindings().iterator();
View Full Code Here

  private QName findInputMessaQname(
      WsdlBindingOperation wsdlBindingOperation, WsdlDefinitions wsdl) {
    String operationName = wsdlBindingOperation.getName();
    WsdlPortType portType = wsdl.getPortType(wsdlBindingOperation
        .getBinding().getPortType().getLocalPart());
    WsdlPortTypeOperation operation = portType.getOperation(operationName);
    QName message = operation.getInput().getMessage();
    return message;
  }
View Full Code Here

        if (input != null) {
            WsdlMessage inputMessage = input.lookupMessage();
            this.inputs = parseMessage(inputMessage, true);
        }

        WsdlPortTypeOutput output = operation.getOutput();
        // No output is possible.
        if (output != null) {
            WsdlMessage outputMessage = output.lookupMessage();
            this.outputs = parseMessage(outputMessage, false);
        }
    }
View Full Code Here

  public void setOdeLocation(String ODEEprEndingWithPort,
      String workflowName, WsdlDefinitions wsdl) {
    Iterator<WsdlService> serviceItr = wsdl.services().iterator();
    if (serviceItr.hasNext()) {
      WsdlService service = serviceItr.next();
      Iterator<WsdlPort> portItr = service.ports().iterator();
      if (portItr.hasNext()) {
        WsdlPort port = portItr.next();
        org.xmlpull.infoset.XmlElement address = port.xml().element(
            "address");
        if (address != null) {
View Full Code Here

 

  public XmlElement generate(String workflowName, WsdlDefinitions workflowWSDL, GpelProcess gpelProcess, Map<String, WsdlDefinitions> wsdls) throws GraphException{
   
    Iterator<WsdlService> services = workflowWSDL.services().iterator();
    WsdlService service = null;
    if(services.hasNext()){
      service = services.next();
    }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");
   
    GpelPartnerLinksContainer partnerLinks = gpelProcess.getPartnerLinks();
    Iterable<GpelPartnerLink> partnerLinkList = partnerLinks.partnerLinks();
   
    HashMap<String, String> newNamespaceMap = new HashMap<String, String>();
   
   
    for (GpelPartnerLink link : partnerLinkList) {
      String partnerRole = link.getPartnerRole();
      if(null != partnerRole){
        //These are the parrtner links that are non providers
        XmlElement invoke = process.addElement(odeNs, "invoke");
        invoke.setAttributeValue("partnerLink", link.getName());
       
        XmlElement invokeService = invoke.addElement(odeNs, "service");
//        invokeService.addAttribute("name", arg1)
        QName partnerLinkTypeQName = link.getPartnerLinkTypeQName();
        Iterator<org.xmlpull.infoset.XmlElement> plIterator = partnerLinkTypes.iterator();
        while(plIterator.hasNext()){
          org.xmlpull.infoset.XmlElement plType = plIterator.next();
          XmlAttribute plTypeName = plType.attribute(NAME);
          if(plTypeName.getValue().equals(partnerLinkTypeQName.getLocalPart())){
            //found the correct partnerlink type
            //now find the porttype
             
            XmlAttribute plPortType = plType.element("role").attribute("portType");
            String portTypeQnameString = plPortType.getValue();
            String[] portTypeSegs = portTypeQnameString.split(":");
            Iterator<org.xmlpull.infoset.XmlNamespace> namespaceIterator = wsdlXml.namespaces().iterator();
            QName portTypeQname = null;
            //find the qname of the porttype
            while (namespaceIterator.hasNext()) {
              org.xmlpull.infoset.XmlNamespace ns = (org.xmlpull.infoset.XmlNamespace) namespaceIterator.next();
              if(ns.getPrefix().equals(portTypeSegs[0])){
                portTypeQname = new QName(ns.getName(), portTypeSegs[1]);
              }
             
            }
           
            //now go through the WSDLS and find the one with the proper port type
            Set<String> keys = wsdls.keySet();
            for (String key : keys) {
              WsdlDefinitions wsdl = wsdls.get(key);
              WsdlPortType portType = wsdl.getPortType(portTypeQname.getLocalPart());
              if(null != portType && portType.getQName().equals(portTypeQname)){
                // this is the right porttype so extract the service and you will be done
                Iterator<WsdlService> svcIterator = wsdl.services().iterator();
                String nsPrefix = null;
                if(svcIterator.hasNext()){
                  WsdlService plService = svcIterator.next();
                  if(null == newNamespaceMap.get(wsdl.getTargetNamespace())){
                    nsPrefix = "p"+newNamespaceMap.size();
                    newNamespaceMap.put(wsdl.getTargetNamespace(), nsPrefix);
                  }else{
                    nsPrefix = newNamespaceMap.get(wsdl.getTargetNamespace());
                  }
                 
                  String portName = null;
                  Iterator<WsdlPort> portItr = plService.ports().iterator();
                  if(portItr.hasNext()){
                    portName = portItr.next().getName();
                  }
                  invokeService.setAttributeValue(NAME, nsPrefix+":"+plService.getName());
                  invokeService.setAttributeValue("port", portName);
                 
                }
              }
            }
View Full Code Here

        }

        GpelAssign assign = new GpelAssign(this.bpelNS, copies);
        sequence.addActivity(assign);

        PartnerLinkRole partnerRoll = this.workflowWSDL
                .getPartnerRoll(portTypeQName);
        if (partnerRoll == null) {
            String partnerLinkTypeName = id + PARTNER_LINK_TYPE_SUFFIX;
            String partnerRollName = id + PARTNER_ROLE_SUFFIX;
            partnerRoll = this.workflowWSDL.addPartnerLinkTypeAndRoll(
                    partnerLinkTypeName, partnerRollName, portTypeQName);
        }
        PartnerLinkType partnerLinkType = partnerRoll.getPartnerLinkType();

        // partnerLink
        String partnerLinkName = createPartnerLinkName(id);
        XmlNamespace partnerLinkTypeNS = this.targetNamespace;
        this.process.addPartnerLink(partnerLinkName, partnerLinkTypeNS,
                partnerLinkType.getName(), null, partnerRoll.getName());

        // Invoke
        GpelInvoke invoke = new GpelInvoke(this.bpelNS, partnerLinkName, namespace,
                portTypeQName.getLocalPart(), operation);
        invoke.setName(INVOKE_NAME_PREFIX + id);
View Full Code Here

    public PartnerLinkRole addPartnerLinkTypeAndRoll(
            String partnerLinkTypeName, String partnerRollName,
            QName servicePortTypeQName) {
        PartnerLinkType partnerLinkType = new PartnerLinkType(
                partnerLinkTypeName);
        PartnerLinkRole partnerRoll = new PartnerLinkRole(partnerRollName,
                servicePortTypeQName);
        partnerLinkType.addRole(partnerRoll);

        declareNamespaceIfNecessary("p",
                servicePortTypeQName.getNamespaceURI(), true);
View Full Code Here

            String partnerLinkTypeName = id + PARTNER_LINK_TYPE_SUFFIX;
            String partnerRollName = id + PARTNER_ROLE_SUFFIX;
            partnerRoll = this.workflowWSDL.addPartnerLinkTypeAndRoll(
                    partnerLinkTypeName, partnerRollName, portTypeQName);
        }
        PartnerLinkType partnerLinkType = partnerRoll.getPartnerLinkType();

        // partnerLink
        String partnerLinkName = createPartnerLinkName(id);
        XmlNamespace partnerLinkTypeNS = this.targetNamespace;
        this.process.addPartnerLink(partnerLinkName, partnerLinkTypeNS,
                partnerLinkType.getName(), null, partnerRoll.getName());

        // Invoke
        GpelInvoke invoke = new GpelInvoke(this.bpelNS, partnerLinkName, namespace,
                portTypeQName.getLocalPart(), operation);
        invoke.setName(INVOKE_NAME_PREFIX + id);
View Full Code Here

     * @return PartnerLinkRole
     */
    public PartnerLinkRole addPartnerLinkTypeAndRoll(
            String partnerLinkTypeName, String partnerRollName,
            QName servicePortTypeQName) {
        PartnerLinkType partnerLinkType = new PartnerLinkType(
                partnerLinkTypeName);
        PartnerLinkRole partnerRoll = new PartnerLinkRole(partnerRollName,
                servicePortTypeQName);
        partnerLinkType.addRole(partnerRoll);

        declareNamespaceIfNecessary("p",
                servicePortTypeQName.getNamespaceURI(), true);
        this.definitions.xml().addElement(partnerLinkType.xml());

        this.partnerLinkRoleMap.put(servicePortTypeQName, partnerRoll);
        return partnerRoll;
    }
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.