/**
   * Simple method to write a catalog file for the BPEL deployment archive.
   *
   * @return the PDD-file
   * @throws Exception
   */
  public File generateCatalogFile() {
    ProcessModel process = Controller.getInstance().getProcess();
    String processName = process.getProcessName();

    MessagePanel.appendOut("    Generating Catalog File ");
    MessagePanel.appendOutBlue("catalog.xml");
    MessagePanel.appendOut(" ... ");

    String content =
        "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
            + "<catalog xmlns='http://schemas.active-endpoints.com/catalog/2006/07/catalog.xsd'>"
            + "  <wsdlEntry location=\"project:/"
            + processName
            + "/"
            + processName
            + ".wsdl\" "
            + "classpath=\"wsdl/"
            + processName
            + "/"
            + processName
            + ".wsdl\" />"
            + "</catalog>";

    try {
      // write file
      File catalogFile = new File("temp/" + processName + "/catalog.xml");
      FileOutputStream out = new FileOutputStream(catalogFile);
      out.write(content.getBytes("UTF-8"));
      out.flush();
      out.close();

      MessagePanel.appendSuccessln("done.");

      return catalogFile;
    } catch (Exception e) {
      MessagePanel.appendErrorln("Error writing Catalog File!");
      Logger.error(e.getMessage());
      e.printStackTrace();

      return null;
    }
  }
  /**
   * Simple method to write a deployment descriptor (.pdd) for the BPEL process.
   *
   * @return the PDD-file
   * @throws Exception
   */
  public File generateDeploymentDescriptor() {
    ProcessModel process = Controller.getInstance().getProcess();
    String processName = process.getProcessName();

    MessagePanel.appendOut("    Generating Deployment Descriptor ");
    MessagePanel.appendOutBlue(processName + ".pdd");
    MessagePanel.appendOut(" ... ");

    String content =
        "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
            + "<process xmlns=\"http://schemas.active-endpoints.com/pdd/2006/08/pdd.xsd\" "
            + "xmlns:bpelns=\"urn:"
            + processName
            + "_targetNamespaceURN\" "
            + "xmlns:wsa=\"http://schemas.xmlsoap.org/ws/2003/03/addressing\" "
            + "location=\"bpel/"
            + processName
            + "/"
            + processName
            + ".bpel\" "
            + "name=\"bpelns:"
            + processName
            + "\" persistenceType=\"full\">"
            + "<partnerLinks>"
            + "<partnerLink name=\""
            + processName
            + "_PartnerLink\">"
            + "<myRole allowedRoles=\"\" binding=\"MSG\" "
            + "service=\""
            + processName
            + "_PartnerLinkService\"/>"
            + "</partnerLink>"
            + "</partnerLinks>"
            + "<references>"
            + "<wsdl location=\"project:/"
            + processName
            + "/"
            + processName
            + ".wsdl\" namespace=\"urn:"
            + processName
            + "_extWsdlURN\"/>"
            + "</references>"
            + "</process>";

    try {
      // write file
      File wsdlFile = new File("temp/" + processName + "/" + processName + ".pdd");
      FileOutputStream out = new FileOutputStream(wsdlFile);
      out.write(content.getBytes("UTF-8"));
      out.flush();
      out.close();

      MessagePanel.appendSuccessln("done.");

      return wsdlFile;
    } catch (Exception e) {
      MessagePanel.appendErrorln("Error writing Deployment Descriptor!");
      Logger.error(e.getMessage());
      e.printStackTrace();

      return null;
    }
  }
Ejemplo n.º 3
0
  /**
   * Simple method to write a WSDL file according to the defined process inputs and outputs.
   *
   * @return the WSDL file
   * @throws Exception
   */
  public File generateWSDL() {
    ProcessModel process = Controller.getInstance().getProcess();
    String processName = process.getProcessName();
    String parameterOrder = " parameterOrder=\"";
    String processTypes = "<wsdl:types><xsd:schema targetNamespace=\"urn:processTypes\">";
    Vector registeredProcessTypes = new Vector();

    MessagePanel.appendOut("    Generating WSDL ");
    MessagePanel.appendOutBlue(processName + ".wsdl");
    MessagePanel.appendOut(" ... ");

    String content =
        "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
            + "<wsdl:definitions xmlns:processTypes=\"urn:processTypes\" targetNamespace=\"urn:"
            + processName
            + "_extWsdlURN\" xmlns:impl=\"urn:"
            + processName
            + "_extWsdlURN\" xmlns:wsdlsoap=\"http://schemas.xmlsoap.org/wsdl/soap/\" "
            + "xmlns:apachesoap=\"http://xml.apache.org/xml-soap\" "
            + "xmlns:soapenc=\"http://schemas.xmlsoap.org/soap/encoding/\" "
            + "xmlns:plnk=\"http://schemas.xmlsoap.org/ws/2003/05/partner-link/\" "
            + "xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" "
            + "xmlns:wsdl=\"http://schemas.xmlsoap.org/wsdl/\">"
            + "<plnk:partnerLinkType xmlns:plnk=\"http://docs.oasis-open.org/wsbpel/2.0/plnktype\" "
            + "name=\""
            + processName
            + "_PartnerLinkType\">"
            + "   <plnk:role name=\"serviceProvider\" portType=\"impl:"
            + processName
            + "_PortType\"/>"
            + "</plnk:partnerLinkType>"
            + "  <wsdl:message name=\"processInputMessage\">";

    // add inputs
    Iterator inputIter = process.getProcessInputs().iterator();
    while (inputIter.hasNext()) {
      ProcessInput processInput = (ProcessInput) inputIter.next();
      String processInputName = processInput.getName();
      content +=
          "    <wsdl:part name=\""
              + processInputName
              + "\" type=\"processTypes:"
              + processInputName
              + "\"/>";
      parameterOrder += processInputName + " ";
      if (!registeredProcessTypes.contains(processInputName)) {
        processTypes +=
            "<xsd:complexType name=\""
                + processInputName
                + "\">  <xsd:sequence>  <xsd:element name=\""
                + processInputName
                + "Data\" type=\"xsd:string\" nillable=\"false\"/> "
                + " </xsd:sequence>  </xsd:complexType>";
        registeredProcessTypes.add(processInputName);
      }
    }

    content += "  </wsdl:message>";

    if (process.getProcessOutputs().size() > 0) {
      content += "  <wsdl:message name=\"processOutputMessage\">";

      // add outputs
      Iterator outputIter = process.getProcessOutputs().iterator();
      while (outputIter.hasNext()) {
        ProcessOutput processOutput = (ProcessOutput) outputIter.next();
        String processOutputName = processOutput.getName();
        content +=
            "    <wsdl:part name=\""
                + processOutputName
                + "\" type=\"processTypes:"
                + processOutputName
                + "\"/>";
        parameterOrder += processOutputName + " ";
        if (!registeredProcessTypes.contains(processOutputName)) {
          processTypes +=
              "<xsd:complexType name=\""
                  + processOutputName
                  + "\">  <xsd:sequence>  <xsd:element name=\""
                  + processOutputName
                  + "Data\" type=\"xsd:string\" nillable=\"false\"/> "
                  + " </xsd:sequence>  </xsd:complexType>";
          registeredProcessTypes.add(processOutputName);
        }
      }

      content += "  </wsdl:message>";
    }

    parameterOrder += "\"";
    processTypes += "</xsd:schema></wsdl:types>";

    content +=
        "  <wsdl:portType name=\""
            + processName
            + "_PortType\">"
            + "    <wsdl:operation name=\""
            + processName
            + "_processOperation\" "
            + parameterOrder
            + ">"
            + "      <wsdl:input name=\"inputMessage\" message=\"impl:processInputMessage\"/>";

    if (process.getProcessOutputs().size() > 0) {
      content += "    <wsdl:output name=\"outputMessage\" message=\"impl:processOutputMessage\"/>";
    }

    content +=
        "    </wsdl:operation>" + "  </wsdl:portType>" + processTypes + "</wsdl:definitions>";

    try {
      // write file
      File wsdlFile = new File("temp/" + processName + "/" + processName + ".wsdl");
      FileOutputStream out = new FileOutputStream(wsdlFile);
      out.write(content.getBytes("UTF-8"));
      out.flush();
      out.close();

      MessagePanel.appendSuccessln("done.");

      return wsdlFile;
    } catch (Exception e) {
      MessagePanel.appendErrorln("Error writing WSDL file!");
      Logger.error(e.getMessage());
      e.printStackTrace();

      return null;
    }
  }