Example #1
0
  private void collectValidationPointsForPortTypes() {
    for (QName ptName : portTypeRefNames) {
      PortType portType = getPortType(ptName);
      if (portType == null) {
        vResults.addError(new Message("NO_PORTTYPE", LOG, ptName));
        continue;
      }

      XNode vPortTypeNode = getXNode(portType);
      for (Operation operation : getOperations(portType).values()) {
        XNode vOperationNode = getOperationXNode(vPortTypeNode, operation.getName());
        if (operation.getInput() == null) {
          vResults.addError(
              new Message("WRONG_MEP", LOG, operation.getName(), portType.getQName()));
          continue;
        }
        javax.wsdl.Message inMsg = operation.getInput().getMessage();
        if (inMsg == null) {
          addWarning(
              "Operation "
                  + operation.getName()
                  + " in PortType: "
                  + portType.getQName()
                  + " has no input message");
        } else {
          XNode vInMsgNode = getXNode(inMsg);
          vInMsgNode.setFailurePoint(getInputXNode(vOperationNode, operation.getInput().getName()));
          vNodes.add(vInMsgNode);
          messageRefNames.add(inMsg.getQName());
        }

        if (operation.getOutput() != null) {
          javax.wsdl.Message outMsg = operation.getOutput().getMessage();

          if (outMsg == null) {
            addWarning(
                "Operation "
                    + operation.getName()
                    + " in PortType: "
                    + portType.getQName()
                    + " has no output message");
          } else {
            XNode vOutMsgNode = getXNode(outMsg);
            vOutMsgNode.setFailurePoint(
                getOutputXNode(vOperationNode, operation.getOutput().getName()));
            vNodes.add(vOutMsgNode);
            messageRefNames.add(outMsg.getQName());
          }
        }
        for (Iterator<?> iter = operation.getFaults().values().iterator(); iter.hasNext(); ) {
          Fault fault = (Fault) iter.next();
          javax.wsdl.Message faultMsg = fault.getMessage();
          XNode vFaultMsgNode = getXNode(faultMsg);
          vFaultMsgNode.setFailurePoint(getFaultXNode(vOperationNode, fault.getName()));
          vNodes.add(vFaultMsgNode);
          messageRefNames.add(faultMsg.getQName());
        }
      }
    }
  }
Example #2
0
  private void convertPortType(PortType portType, Binding binding) throws IOException {
    String comment = "";
    if (portType.getDocumentationElement() != null) {
      comment = portType.getDocumentationElement().getNodeValue();
    }

    Style style = Style.DOCUMENT;
    for (ExtensibilityElement element :
        (List<ExtensibilityElement>) binding.getExtensibilityElements()) {
      if (element instanceof SOAPBinding) {
        if ("rpc".equals(((SOAPBinding) element).getStyle())) {
          style = Style.RPC;
        }
      } else if (element instanceof HTTPBinding) {
        style = Style.HTTP;
      }
    }
    Interface iface = new Interface(portType.getQName().getLocalPart(), comment);
    List<Operation> operations = portType.getOperations();
    for (Operation operation : operations) {
      if (operation.getOutput() == null) {
        iface.addOneWayOperation(convertOperation(operation, style));
      } else {
        iface.addRequestResponseOperation(convertOperation(operation, style));
      }
    }
    interfaces.put(iface.name(), iface);
  }
Example #3
0
 private void setMexRole(MyRoleMessageExchangeImpl mex) {
   Operation operation = getMyRoleOperation(mex.getOperationName());
   mex.getDAO().setPartnerLinkModelId(_plinkDef.getId());
   mex.setPortOp(_plinkDef.myRolePortType, operation);
   mex.setPattern(
       operation.getOutput() == null
           ? MessageExchange.MessageExchangePattern.REQUEST_ONLY
           : MessageExchange.MessageExchangePattern.REQUEST_RESPONSE);
 }
Example #4
0
  private boolean checkR2201Output(final Operation operation, final BindingOperation bop) {
    int outmessagePartsCount = wsdlHelper.getOutMessageParts(operation).size();
    SoapBody soapBody = SOAPBindingUtil.getBindingOutputSOAPBody(bop);
    if (soapBody != null) {
      List<?> parts = soapBody.getParts();
      int boundPartSize = parts == null ? outmessagePartsCount : parts.size();
      SoapHeader soapHeader = SOAPBindingUtil.getBindingOutputSOAPHeader(bop);
      boundPartSize =
          soapHeader != null
                  && soapHeader.getMessage().equals(operation.getOutput().getMessage().getQName())
              ? boundPartSize - 1
              : boundPartSize;
      if (parts != null) {
        Iterator<?> partsIte = parts.iterator();
        while (partsIte.hasNext()) {
          String partName = (String) partsIte.next();
          boolean isDefined = false;
          for (Part part : wsdlHelper.getOutMessageParts(operation)) {
            if (partName.equalsIgnoreCase(part.getName())) {
              isDefined = true;
              break;
            }
          }
          if (!isDefined) {
            addErrorMessage(
                getErrorPrefix("WSI-BP-1.0 R2201")
                    + "Operation '"
                    + operation.getName()
                    + "' soapBody parts : "
                    + partName
                    + " not found in the message, wrong WSDL");
            return false;
          }
        }
      } else {
        if (wsdlHelper.getOutMessageParts(operation).size() > 1) {
          addErrorMessage(
              getErrorPrefix("WSI-BP-1.0 R2210")
                  + "Operation '"
                  + operation.getName()
                  + "' more than one part bound to body");
          return false;
        }
      }

      if (boundPartSize > 1) {
        addErrorMessage(
            getErrorPrefix("WSI-BP-1.0 R2201")
                + "Operation '"
                + operation.getName()
                + "' more than one part bound to body");
        return false;
      }
    }
    return true;
  }
Example #5
0
 @SuppressWarnings("unchecked")
 public boolean isOneWayOnly() {
   PortType portType = _plinkDef.myRolePortType;
   if (portType == null) {
     return false;
   }
   for (Operation operation : (List<Operation>) portType.getOperations()) {
     if (operation.getOutput() != null) {
       return false;
     }
   }
   return true;
 }
Example #6
0
  public boolean checkR2203And2204() {

    Collection<Binding> bindings = CastUtils.cast(def.getBindings().values());
    for (Binding binding : bindings) {

      String style = SOAPBindingUtil.getCanonicalBindingStyle(binding);

      if (binding.getPortType() == null) {
        return true;
      }

      //

      for (Iterator<?> ite2 = binding.getPortType().getOperations().iterator(); ite2.hasNext(); ) {
        Operation operation = (Operation) ite2.next();
        BindingOperation bop = wsdlHelper.getBindingOperation(def, operation.getName());
        if (operation.getInput() != null && operation.getInput().getMessage() != null) {
          Message inMess = operation.getInput().getMessage();

          for (Iterator<?> ite3 = inMess.getParts().values().iterator(); ite3.hasNext(); ) {
            Part p = (Part) ite3.next();
            if (SOAPBinding.Style.RPC.name().equalsIgnoreCase(style)
                && p.getTypeName() == null
                && !isHeaderPart(bop, p)) {
              addErrorMessage(
                  "An rpc-literal binding in a DESCRIPTION MUST refer, "
                      + "in its soapbind:body element(s), only to "
                      + "wsdl:part element(s) that have been defined "
                      + "using the type attribute.");
              return false;
            }

            if (SOAPBinding.Style.DOCUMENT.name().equalsIgnoreCase(style)
                && p.getElementName() == null) {
              addErrorMessage(
                  "A document-literal binding in a DESCRIPTION MUST refer, "
                      + "in each of its soapbind:body element(s),"
                      + "only to wsdl:part element(s)"
                      + " that have been defined using the element attribute.");
              return false;
            }
          }
        }
        if (operation.getOutput() != null && operation.getOutput().getMessage() != null) {
          Message outMess = operation.getOutput().getMessage();
          for (Iterator<?> ite3 = outMess.getParts().values().iterator(); ite3.hasNext(); ) {
            Part p = (Part) ite3.next();
            if (style.equalsIgnoreCase(SOAPBinding.Style.RPC.name())
                && p.getTypeName() == null
                && !isHeaderPart(bop, p)) {
              addErrorMessage(
                  "An rpc-literal binding in a DESCRIPTION MUST refer, "
                      + "in its soapbind:body element(s), only to "
                      + "wsdl:part element(s) that have been defined "
                      + "using the type attribute.");
              return false;
            }

            if (style.equalsIgnoreCase(SOAPBinding.Style.DOCUMENT.name())
                && p.getElementName() == null) {
              addErrorMessage(
                  "A document-literal binding in a DESCRIPTION MUST refer, "
                      + "in each of its soapbind:body element(s),"
                      + "only to wsdl:part element(s)"
                      + " that have been defined using the element attribute.");
              return false;
            }
          }
        }
      }
    }
    return true;
  }
Example #7
0
  private joliex.wsdl.impl.Operation convertOperation(Operation operation, Style style)
      throws IOException {
    String comment = "";
    if (operation.getDocumentationElement() != null) {
      operation.getDocumentationElement().getNodeValue();
    }
    String responseTypeName = null;

    String requestTypeName =
        convertOperationMessage(operation.getInput().getMessage(), operation.getName(), style);
    if (operation.getOutput() != null) {
      responseTypeName =
          convertOperationMessage(operation.getOutput().getMessage(), operation.getName(), style);
    }

    Map<String, Part> parts;
    List<Pair<String, String>> faultList = new ArrayList<Pair<String, String>>();
    Map<String, Fault> faults = operation.getFaults();
    for (Entry<String, Fault> entry : faults.entrySet()) {
      String faultName = entry.getKey();
      String faultTypeName = null;
      parts = entry.getValue().getMessage().getParts();
      if (parts.size() > 1) {
        String typeName = faultName = faultTypeName;
        TypeInlineDefinition faultType =
            new TypeInlineDefinition(
                URIParsingContext.DEFAULT,
                typeName,
                NativeType.VOID,
                jolie.lang.Constants.RANGE_ONE_TO_ONE);
        for (Entry<String, Part> partEntry : parts.entrySet()) {
          Part part = partEntry.getValue();
          if (part.getElementName() == null) {
            if (part.getTypeName() == null) {
              throw new IOException(
                  "Could not parse message part "
                      + entry.getKey()
                      + " for operation "
                      + operation.getName()
                      + ".");
            }
            TypeDefinitionLink link =
                new TypeDefinitionLink(
                    URIParsingContext.DEFAULT,
                    part.getName(),
                    jolie.lang.Constants.RANGE_ONE_TO_ONE,
                    XsdUtils.xsdToNativeType(part.getTypeName().getLocalPart()).id());
            faultType.putSubType(link);
          } else {
            TypeDefinitionLink link =
                new TypeDefinitionLink(
                    URIParsingContext.DEFAULT,
                    part.getName(),
                    jolie.lang.Constants.RANGE_ONE_TO_ONE,
                    part.getElementName().getLocalPart());
            faultType.putSubType(link);
          }
        }
        typeDefinitions.add(faultType);
      } else {
        for (Entry<String, Part> e : parts.entrySet()) {
          Part part = e.getValue();
          if (part.getElementName() == null) {
            if (part.getTypeName() == null) {
              throw new IOException(
                  "Could not parse message part "
                      + e.getKey()
                      + " for operation "
                      + operation.getName()
                      + ", fault "
                      + entry.getKey()
                      + ".");
            }
            faultTypeName = XsdUtils.xsdToNativeType(part.getTypeName().getLocalPart()).id();
          } else {
            faultTypeName = part.getElementName().getLocalPart();
            NativeType nativeType = XsdUtils.xsdToNativeType(faultTypeName);
            if (nativeType != null) {
              faultTypeName = nativeType.id();
            }
          }
        }
      }
      faultList.add(new Pair<String, String>(faultName, faultTypeName));
    }

    return new joliex.wsdl.impl.Operation(
        operation.getName(), requestTypeName, responseTypeName, faultList, comment);
  }
  public ReplyAction readReplyAction(Element replyElem, CompositeActivity parent) {
    ReplyAction replyAction = new ReplyAction();

    // partner link
    String partnerLinkName = replyElem.getAttribute(BpelConstants.ATTR_PARTNER_LINK);
    PartnerLinkDefinition partnerLink = parent.findPartnerLink(partnerLinkName);
    if (partnerLink == null) {
      bpelReader.getProblemHandler().add(new ParseProblem("partner link not found", replyElem));
      return replyAction;
    }
    replyAction.setPartnerLink(partnerLink);

    // port type
    Role myRole = partnerLink.getMyRole();
    // BPEL-181 detect absence of my role
    if (myRole == null) {
      bpelReader
          .getProblemHandler()
          .add(new ParseProblem("partner link does not indicate my role", replyElem));
      return replyAction;
    }
    PortType portType = bpelReader.getMessageActivityPortType(replyElem, partnerLink.getMyRole());

    // operation
    Operation operation = bpelReader.getMessageActivityOperation(replyElem, portType);
    if (operation.getStyle() != OperationType.REQUEST_RESPONSE) {
      bpelReader
          .getProblemHandler()
          .add(new ParseProblem("not a request/response operation", replyElem));
      return replyAction;
    }
    replyAction.setOperation(operation);

    // message exchange
    // BPEL-74: map the empty message exchange to null for compatibility with Oracle
    replyAction.setMessageExchange(
        XmlUtil.getAttribute(replyElem, BpelConstants.ATTR_MESSAGE_EXCHANGE));

    // fault name
    Message replyMessage;
    Attr faultNameAttr = replyElem.getAttributeNode(BpelConstants.ATTR_FAULT_NAME);
    if (faultNameAttr != null) {
      QName faultName = XmlUtil.getQNameValue(faultNameAttr);
      replyAction.setFaultName(faultName);

      Fault fault = operation.getFault(faultName.getLocalPart());
      if (fault == null) {
        bpelReader.getProblemHandler().add(new ParseProblem("fault not found", replyElem));
        return replyAction;
      }
      replyMessage = fault.getMessage();
    } else replyMessage = operation.getOutput().getMessage();

    // variable
    VariableDefinition variable =
        bpelReader.getMessageActivityVariable(
            replyElem, BpelConstants.ATTR_VARIABLE, parent, replyMessage);
    replyAction.setVariable(variable);

    // correlations
    Element correlationsElement =
        XmlUtil.getElement(replyElem, BpelConstants.NS_BPEL, BpelConstants.ELEM_CORRELATIONS);
    if (correlationsElement != null)
      replyAction.setCorrelations(
          bpelReader.readCorrelations(correlationsElement, parent, variable));

    return replyAction;
  }
  protected void addPortTypeTransformers(
      PortType portType,
      boolean provider,
      StringBuffer transformers,
      javax.wsdl.Definition wsdl,
      ResourceLocator locator,
      String srcFolder) {
    String attr1 = (provider ? "from" : "to");
    String attr2 = (provider ? "to" : "from");

    for (Object opobj : portType.getOperations()) {
      if (opobj instanceof javax.wsdl.Operation) {
        javax.wsdl.Operation op = (javax.wsdl.Operation) opobj;

        String qname = "";
        String javaType = "";
        String javaPackage = "";

        javax.wsdl.Part p =
            (javax.wsdl.Part) op.getInput().getMessage().getParts().values().iterator().next();
        qname = p.getElementName().toString();

        javaType = getJavaType(wsdl, p.getElementName(), locator);

        if (javaType != null) {
          int ind = javaType.lastIndexOf('.');
          if (ind != -1) {
            javaPackage = javaType.substring(0, ind);
          }
        }

        transformers.append("\t\t<xform:transform.jaxb\r\n");
        transformers.append("\t\t\t" + attr1 + "=\"" + qname + "\"\r\n");
        transformers.append("\t\t\t" + attr2 + "=\"java:" + javaType + "\"\r\n");
        transformers.append("\t\t\tcontextPath=\"" + javaPackage + "\"/>\r\n");

        if (op.getOutput() != null) {
          p = (javax.wsdl.Part) op.getOutput().getMessage().getParts().values().iterator().next();
          qname = p.getElementName().toString();

          javaType = getJavaType(wsdl, p.getElementName(), locator);

          if (javaType != null) {
            int ind = javaType.lastIndexOf('.');
            if (ind != -1) {
              javaPackage = javaType.substring(0, ind);
            }
          }

          transformers.append("\t\t<xform:transform.jaxb\r\n");
          transformers.append("\t\t\t" + attr2 + "=\"" + qname + "\"\r\n");
          transformers.append("\t\t\t" + attr1 + "=\"java:" + javaType + "\"\r\n");
          transformers.append("\t\t\tcontextPath=\"" + javaPackage + "\"/>\r\n");
        }

        for (Object faultObj : op.getFaults().values()) {
          if (faultObj instanceof javax.wsdl.Fault) {
            javax.wsdl.Fault fault = (javax.wsdl.Fault) faultObj;

            p = (javax.wsdl.Part) fault.getMessage().getParts().values().iterator().next();
            qname = p.getElementName().toString();

            String javaFaultType = getJavaType(wsdl, p.getElementName(), locator);

            String pack =
                JavaGeneratorUtil.getJavaPackage(fault.getMessage().getQName().getNamespaceURI());

            javaType =
                pack
                    + "."
                    + JavaGeneratorUtil.getJavaClassName(
                        fault.getMessage().getQName().getLocalPart());

            String transformerClassName = getFaultTransformerClassName(javaType, provider);

            String faultTransClass = pack + "." + transformerClassName;

            transformers.append("\t\t<xform:transform.java class=\"" + faultTransClass + "\"\r\n");
            transformers.append("\t\t\t" + attr2 + "=\"" + qname + "\"\r\n");
            transformers.append("\t\t\t" + attr1 + "=\"java:" + javaType + "\"/>\r\n");

            // Create transformer class
            String folder = pack.replace('.', java.io.File.separatorChar);

            String javaFile = folder + java.io.File.separator + transformerClassName;

            java.io.File jFile =
                new java.io.File(srcFolder + java.io.File.separator + javaFile + ".java");

            jFile.getParentFile().mkdirs();

            try {
              java.io.FileOutputStream fos = new java.io.FileOutputStream(jFile);

              generateFaultTransformer(qname, javaType, javaFaultType, provider, fos);

              fos.close();
            } catch (Exception e) {
              logger.log(Level.SEVERE, "Failed to create fault transformer", e);
            }
          }
        }
      }
    }
  }