Example #1
0
  /**
   * Method for processing policy on interface level it should include processing of all types of
   * policies, but for now there's only Addressing policy implemented
   *
   * @param policy
   * @return this interface changed in a proper way indicated by the policy
   */
  public void processPolicy(Policy policy) throws Exception {

    // default is optional
    // String anonymous = AnonymousTypeConfig.OPTIONAL.toString();
    // if (StringUtils.isNullOrEmpty(interfaceAnonymous) || policyFlag)
    // interfaceAnonymous = AnonymousTypeConfig.OPTIONAL.toString() ;
    // if (StringUtils.isNullOrEmpty(interfaceWsaVersion)|| policyFlag)
    // interfaceWsaVersion = WsaVersionTypeConfig.NONE.toString();
    if (!policyFlag) {
      interfaceAnonymous = AnonymousTypeConfig.OPTIONAL.toString();
      interfaceWsaVersion = WsaVersionTypeConfig.NONE.toString();
    }
    policyFlag = true;

    if (policy != null) {
      List<Addressing> addressingList = policy.getAddressingList();
      List<?> usingAddressingList = policy.getUsingAddressingList();
      for (Addressing addressing : addressingList) {
        policyFlag = true;
        String optional = addressing.getOptional().toString();
        if (StringUtils.isNullOrEmpty(optional)
            || optional.equals("false")
            || (optional.equals("true")
                && SoapUI.getSettings().getBoolean(WsaSettings.ENABLE_FOR_OPTIONAL))) {
          interfaceWsaVersion = WsaVersionTypeConfig.X_200508.toString();
        }
        Policy innerPolicy = addressing.getPolicy();
        if (innerPolicy != null) {
          List<AnonymousResponses> anonymousList = innerPolicy.getAnonymousResponsesList();
          List<NonAnonymousResponses> nonAnonymousList = innerPolicy.getNonAnonymousResponsesList();
          if (anonymousList.size() > 0 && nonAnonymousList.size() > 0) {
            throw new Exception(
                "Wrong addressing policy, anonymousResponses and nonAnonymousResponses can not be specified together");
          }
          if (anonymousList.size() > 0) {
            interfaceAnonymous = AnonymousTypeConfig.REQUIRED.toString();
          } else {
            if (nonAnonymousList.size() > 0) {
              interfaceAnonymous = AnonymousTypeConfig.PROHIBITED.toString();
            }
          }
        }
      }
      if (interfaceWsaVersion == WsaVersionTypeConfig.NONE.toString()
          && !usingAddressingList.isEmpty()) {
        /*
         * UsingAddressing can also be specified insde Policy check
         * http://www.w3.org/TR/ws-addr-wsdl/#id2263339
         */
        interfaceWsaVersion = WsaVersionTypeConfig.X_200508.toString();
      }
    }
    setAnonymous(interfaceAnonymous);
    // set wsaVersion to one from policy only if it was null from wsdl binding
    if (getConfig().getWsaVersion().equals(WsaVersionTypeConfig.NONE)) {
      setWsaVersion(interfaceWsaVersion);
    }
  }
Example #2
0
 public void setWsaVersion(String wsAddressing) {
   if (wsAddressing.equals(WsaVersionTypeConfig.X_200508.toString()))
     getConfig().setWsaVersion(WsaVersionTypeConfig.X_200508);
   else if (wsAddressing.equals(WsaVersionTypeConfig.X_200408.toString()))
     getConfig().setWsaVersion(WsaVersionTypeConfig.X_200408);
   else getConfig().setWsaVersion(WsaVersionTypeConfig.NONE);
 }
Example #3
0
  public String getWsaVersion() {
    if (getConfig().getWsaVersion().equals(WsaVersionTypeConfig.X_200408)) {
      return WsaVersionTypeConfig.X_200408.toString();
    } else if (getConfig().getWsaVersion().equals(WsaVersionTypeConfig.X_200508)) {
      return WsaVersionTypeConfig.X_200508.toString();
    }

    return WsaVersionTypeConfig.NONE.toString();
  }
  public void buildContent(SimpleBindingForm form) {
    form.addSpace(5);
    form.appendCheckBox("wsaEnabled", "Enable WS-A addressing", "Enable/Disable WS-A addressing");
    form.addSpace(5);
    // add mustUnderstand drop down list
    form.appendComboBox(
        "mustUnderstand",
        "Must understand",
        new String[] {
          MustUnderstandTypeConfig.NONE.toString(),
          MustUnderstandTypeConfig.TRUE.toString(),
          MustUnderstandTypeConfig.FALSE.toString()
        },
        "The  property for controlling use of the mustUnderstand attribute");

    form.appendComboBox(
        "version",
        "WS-A Version",
        new String[] {
          WsaVersionTypeConfig.X_200508.toString(), WsaVersionTypeConfig.X_200408.toString()
        },
        "The  property for managing WS-A version");

    addDefaultActionCheckBox =
        form.appendCheckBox("addDefaultAction", "Add default wsa:Action", "Add default wsa:Action");
    actionTextField =
        form.appendTextField(
            "action",
            "Action",
            "The action related to a message, will be generated if left empty and ws-a settings 'use default action...' checked ");
    actionTextField.setEnabled(!addDefaultActionCheckBox.isSelected());
    addDefaultActionCheckBox.addItemListener(
        new ItemListener() {

          public void itemStateChanged(ItemEvent arg0) {
            actionTextField.setEnabled(!addDefaultActionCheckBox.isSelected());
          }
        });

    addDefaultToCheckBox =
        form.appendCheckBox("addDefaultTo", "Add default wsa:To", "Add default wsa:To");
    toTextField =
        form.appendTextField(
            "to", "To", "The destination endpoint reference, will be generated if left empty");
    toTextField.setEnabled(!addDefaultToCheckBox.isSelected());
    addDefaultToCheckBox.addItemListener(
        new ItemListener() {

          public void itemStateChanged(ItemEvent arg0) {
            toTextField.setEnabled(!addDefaultToCheckBox.isSelected());
          }
        });

    form.appendTextField(
        "replyTo", "Reply to", "The reply endpoint reference, will be generated if left empty");
    form.appendTextArea(
        "replyToRefParams",
        "ReplyTo Reference Parameters",
        "ReplyTo Reference Parameters, content will be inserted as an xml (not text)");
    generateMessageIdCheckBox =
        form.appendCheckBox(
            "generateMessageId", "Generate MessageID", "Randomly generate MessageId");
    messageIdTextField =
        form.appendTextField(
            "messageID",
            "MessageID",
            " The ID of a message that can be used to uniquely identify a message, will be generated if left empty and ws-a settings 'generate message id' checked ");
    messageIdTextField.setEnabled(!generateMessageIdCheckBox.isSelected());
    generateMessageIdCheckBox.addItemListener(
        new ItemListener() {

          public void itemStateChanged(ItemEvent arg0) {
            messageIdTextField.setEnabled(!generateMessageIdCheckBox.isSelected());
          }
        });
    form.addSpace(10);
    form.appendTextField("from", "From", "The source endpoint reference");
    form.appendTextField("faultTo", "Fault to", "The fault endpoint reference");
    form.appendTextArea(
        "faultToRefParams",
        "FaultTo Reference Parameters",
        "FaultTo Reference Parameters, content will be inserted as an xml (not text)");
    form.appendTextField("relatesTo", "Relates to", "The endpoint reference request relates to");
    form.appendTextField("relationshipType", "Relationship type", "Relationship type");
    form.addSpace(5);
  }