/**
   * Create a Axis2 Based Server Environment
   *
   * @param serverConfigurationInformation ServerConfigurationInformation instance
   */
  private void createNewInstance(ServerConfigurationInformation serverConfigurationInformation) {

    try {
      configurationContext =
          ConfigurationContextFactory.createConfigurationContextFromFileSystem(
              serverConfigurationInformation.getAxis2RepoLocation(),
              serverConfigurationInformation.getAxis2Xml());

      configurationContext.setProperty(AddressingConstants.ADDR_VALIDATE_ACTION, Boolean.FALSE);

      startJmxAdapter();

      listenerManager = configurationContext.getListenerManager();
      if (listenerManager == null) {

        // create and initialize the listener manager but do not start
        listenerManager = new ListenerManager();
        listenerManager.init(configurationContext);
      }

      // do not use the listener manager shutdown hook, because it clashes with the
      // SynapseServer shutdown hook.
      listenerManager.setShutdownHookRequired(false);

    } catch (Throwable t) {
      handleFatal("Failed to create a new Axis2 instance...", t);
    }
  }
Esempio n. 2
0
  public void init(SynapseEnvironment synapseEnvironment) {
    this.synapseEnv = synapseEnvironment;

    if (endpoint != null) {
      endpoint.init(synapseEnvironment);
    }

    if (blocking) {
      try {
        configCtx =
            ConfigurationContextFactory.createConfigurationContextFromFileSystem(
                DEFAULT_CLIENT_REPO, DEFAULT_AXIS2_XML);
        blockingMsgSender = new BlockingMsgSender();
        blockingMsgSender.setConfigurationContext(configCtx);
        blockingMsgSender.init();

      } catch (AxisFault axisFault) {
        String msg = "Error while initializing the Call mediator";
        log.error(msg, axisFault);
        throw new SynapseException(msg, axisFault);
      }
    } else {
      synapseEnvironment.updateCallMediatorCount(true);
    }
  }
  @edu.umd.cs.findbugs.annotations.SuppressWarnings(
      value = "PRMC_POSSIBLY_REDUNDANT_METHOD_CALLS",
      justification = "It is required to set two options on the Options object")
  public APIKeyValidatorClient() throws APISecurityException {
    APIManagerConfiguration config =
        ServiceReferenceHolder.getInstance().getAPIManagerConfiguration();
    String serviceURL = config.getFirstProperty(APIConstants.API_KEY_VALIDATOR_URL);
    username = config.getFirstProperty(APIConstants.API_KEY_VALIDATOR_USERNAME);
    password = config.getFirstProperty(APIConstants.API_KEY_VALIDATOR_PASSWORD);
    if (serviceURL == null || username == null || password == null) {
      throw new APISecurityException(
          APISecurityConstants.API_AUTH_GENERAL_ERROR,
          "Required connection details for the key management server not provided");
    }

    try {
      ConfigurationContext ctx =
          ConfigurationContextFactory.createConfigurationContextFromFileSystem(null, null);
      keyValidationServiceStub =
          new APIKeyValidationServiceStub(ctx, serviceURL + "APIKeyValidationService");
      ServiceClient client = keyValidationServiceStub._getServiceClient();
      Options options = client.getOptions();
      options.setTimeOutInMilliSeconds(TIMEOUT_IN_MILLIS);
      options.setProperty(HTTPConstants.SO_TIMEOUT, TIMEOUT_IN_MILLIS);
      options.setProperty(HTTPConstants.CONNECTION_TIMEOUT, TIMEOUT_IN_MILLIS);
      options.setCallTransportCleanup(true);
      options.setManageSession(true);

    } catch (AxisFault axisFault) {
      throw new APISecurityException(
          APISecurityConstants.API_AUTH_GENERAL_ERROR,
          "Error while initializing the API key validation stub",
          axisFault);
    }
  }
  public SampleAxis2Server(String axis2xmlFile) {
    repositoryPath =
        System.getProperty(ServerConstants.CARBON_HOME)
            + File.separator
            + "samples"
            + File.separator
            + "axis2Server"
            + File.separator
            + "repository";
    File repository = new File(repositoryPath);
    log.info("Using the Axis2 repository path: " + repository.getAbsolutePath());

    try {
      File axis2xml = copyResourceToFileSystem(axis2xmlFile, "axis2.xml");
      if (axis2xml == null) {
        log.error("Error while copying the test axis2.xml to the file system");
        return;
      }
      log.info("Loading axis2.xml from: " + axis2xml.getAbsolutePath());
      cfgCtx =
          ConfigurationContextFactory.createConfigurationContextFromFileSystem(
              repository.getAbsolutePath(), axis2xml.getAbsolutePath());
    } catch (Exception e) {
      log.error("Error while initializing the configuration context", e);
    }
  }
Esempio n. 5
0
 public void testParameterEdit() throws Exception {
   ConfigurationContext configCtx = ConfigurationContextFactory.createEmptyConfigurationContext();
   AxisConfiguration axisConfig = configCtx.getAxisConfiguration();
   Parameter parameter = new Parameter();
   parameter.setValue("true");
   parameter.setName("enableMTOM");
   axisConfig.addParameter(parameter);
   parameter.setValue("true");
   AxisServiceGroup serviceGroup = new AxisServiceGroupImpl();
   serviceGroup.setName("testServiceGroup");
   AxisService service = new AxisService();
   service.setName("service");
   serviceGroup.addService(service);
   axisConfig.addServiceGroup(serviceGroup);
   parameter = serviceGroup.getParameter("enableMTOM");
   parameter.setValue("true");
   Parameter para2 = serviceGroup.getParameter("enableMTOM");
   assertEquals(para2.getValue(), "true");
   Parameter test = new Parameter();
   test.setName("test");
   test.setValue("test");
   serviceGroup.addParameter(test);
   Parameter para = serviceGroup.getParameter("test");
   assertNotNull(para);
   assertEquals(para.getValue(), "test");
   para.setValue("newValue");
   para = serviceGroup.getParameter("test");
   assertNotNull(para);
   assertEquals(para.getValue(), "newValue");
 }
Esempio n. 6
0
 public static ConfigurationContext getNewConfigurationContext(String repository, String axis2xml)
     throws Exception {
   File file = new File(repository);
   if (!file.exists()) {
     throw new Exception("repository directory " + file.getAbsolutePath() + " does not exists");
   }
   return ConfigurationContextFactory.createConfigurationContextFromFileSystem(
       file.getAbsolutePath(), axis2xml);
 }
  public static void transferFile(File file, String destinationFile) throws Exception {

    Options options = new Options();
    options.setTo(targetEPR);
    options.setProperty(Constants.Configuration.ENABLE_SWA, Constants.VALUE_TRUE);
    options.setSoapVersionURI(SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI);
    // Increase the time out when sending large attachments
    options.setTimeOutInMilliSeconds(10000);
    options.setTo(targetEPR);
    options.setAction("urn:uploadFile");

    // assume the use runs this sample at
    // <axis2home>/samples/soapwithattachments/ dir
    ConfigurationContext configContext =
        ConfigurationContextFactory.createConfigurationContextFromFileSystem(
            "../../repository", null);

    ServiceClient sender = new ServiceClient(configContext, null);
    sender.setOptions(options);
    OperationClient mepClient = sender.createClient(ServiceClient.ANON_OUT_IN_OP);

    MessageContext mc = new MessageContext();
    FileDataSource fileDataSource = new FileDataSource(file);

    // Create a dataHandler using the fileDataSource. Any implementation of
    // javax.activation.DataSource interface can fit here.
    DataHandler dataHandler = new DataHandler(fileDataSource);
    String attachmentID = mc.addAttachment(dataHandler);

    SOAPFactory fac = OMAbstractFactory.getSOAP11Factory();
    SOAPEnvelope env = fac.getDefaultEnvelope();
    OMNamespace omNs = fac.createOMNamespace("http://service.soapwithattachments.sample", "swa");
    OMElement uploadFile = fac.createOMElement("uploadFile", omNs);
    OMElement nameEle = fac.createOMElement("name", omNs);
    nameEle.setText(destinationFile);
    OMElement idEle = fac.createOMElement("attchmentID", omNs);
    idEle.setText(attachmentID);
    uploadFile.addChild(nameEle);
    uploadFile.addChild(idEle);
    env.getBody().addChild(uploadFile);
    mc.setEnvelope(env);

    mepClient.addMessageContext(mc);
    mepClient.execute(true);
    MessageContext response = mepClient.getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
    SOAPBody body = response.getEnvelope().getBody();
    OMElement element =
        body.getFirstElement()
            .getFirstChildWithName(
                new QName("http://service.soapwithattachments.sample", "return"));
    System.out.println(element.getText());
  }
Esempio n. 8
0
  public static ConfigurationContext createClientConfigurationContext() throws AxisFault {
    File file = getAddressingMARFile();
    TestCase.assertTrue(file.exists());

    ConfigurationContext configContext =
        ConfigurationContextFactory.createConfigurationContextFromFileSystem(
            "target/test-resources/integrationRepo",
            "target/test-resources/integrationRepo/conf/axis2.xml");
    AxisModule axisModule =
        DeploymentEngine.buildModule(file, configContext.getAxisConfiguration());
    configContext.getAxisConfiguration().addModule(axisModule);
    return configContext;
  }
 protected AnalyticsProcessorAdminServiceStub getAnalyticsProcessorStub() throws Exception {
   ConfigurationContext configContext =
       ConfigurationContextFactory.createConfigurationContextFromFileSystem(null);
   String loggedInSessionCookie = getSessionCookie();
   AnalyticsProcessorAdminServiceStub analyticsStub =
       new AnalyticsProcessorAdminServiceStub(configContext, backendURL + ANALYTICS_SERVICE_NAME);
   ServiceClient client = analyticsStub._getServiceClient();
   Options option = client.getOptions();
   option.setManageSession(true);
   option.setProperty(
       org.apache.axis2.transport.http.HTTPConstants.COOKIE_STRING, loggedInSessionCookie);
   return analyticsStub;
 }
Esempio n. 10
0
  private ConfigurationContext generateConfigContext() throws Exception {
    if ("<SANDESHA2_HOME>".equals(SANDESHA2_HOME)) {
      System.out.println(
          "ERROR: Please change <SANDESHA2_HOME> to your Sandesha2 installation directory.");
      throw new Exception("Client not set up correctly");
    }

    String axis2_xml = AXIS2_CLIENT_PATH + "client_axis2.xml";
    ConfigurationContext configContext =
        ConfigurationContextFactory.createConfigurationContextFromFileSystem(
            AXIS2_CLIENT_PATH, axis2_xml);

    return configContext;
  }
  public void testEchoXMLASync() throws Exception {
    OMElement payload = createPayload();
    Options clientOptions = new Options();
    clientOptions.setTo(targetEPR);
    clientOptions.setTransportInProtocol(Constants.TRANSPORT_HTTP);

    AxisCallback callback =
        new AxisCallback() {

          public void onMessage(MessageContext msgContext) {
            SOAPEnvelope envelope = msgContext.getEnvelope();

            OMElement data = (OMElement) envelope.getBody().getFirstElement().getFirstOMChild();
            compareWithCreatedOMText(data.getText());
            finish = true;
          }

          public void onFault(MessageContext msgContext) {
            SOAPEnvelope envelope = msgContext.getEnvelope();

            OMElement data = (OMElement) envelope.getBody().getFirstElement().getFirstOMChild();
            compareWithCreatedOMText(data.getText());
            finish = true;
          }

          public void onError(Exception e) {
            log.info(e.getMessage());
            finish = true;
          }

          public void onComplete() {}
        };

    ConfigurationContext configContext =
        ConfigurationContextFactory.createConfigurationContextFromFileSystem(
            TestingUtils.prefixBaseDirectory("target/test-resources/integrationRepo"), null);
    ServiceClient sender = new ServiceClient(configContext, null);
    sender.setOptions(clientOptions);

    sender.sendReceiveNonBlocking(payload, callback);

    int index = 0;
    while (!finish) {
      Thread.sleep(1000);
      index++;
      if (index > 10) {
        throw new AxisFault("Server was shutdown as the async response take too long to complete");
      }
    }
  }
Esempio n. 12
0
  public static void main(String[] args) {
    try {

      setSystemProperties();

      String axis2Configuration =
          System.getProperty("carbon.home")
              + File.separator
              + "repository"
              + File.separator
              + "conf"
              + File.separator
              + "axis2"
              + File.separator
              + "axis2_client.xml";
      ConfigurationContext configContext =
          ConfigurationContextFactory.createConfigurationContextFromFileSystem(axis2Configuration);

      Registry registry =
          new WSRegistryServiceClient(serverURL, username, password, configContext) {

            public void setCookie(String cookie) {
              CleanUp.cookie = cookie;
              super.setCookie(cookie);
            }
          };
      Registry gov = GovernanceUtils.getGovernanceUserRegistry(registry, "admin");
      GovernanceUtils.loadGovernanceArtifacts((UserRegistry) gov);
      deleteArtifacts(gov, "wsdl", "wsdl");
      System.out.println("########## Successfully deleted sample wsdls ###########");
      deleteArtifacts(gov, "wadl", "wadl");
      System.out.println("########## Successfully deleted sample wadls ###########");
      deleteArtifacts(gov, "schema", "xsd");
      System.out.println("########## Successfully deleted sample schemas ###########");
      deleteArtifacts(gov, "swagger", "json");
      System.out.println("########## Successfully deleted sample swagger docs ###########");
      deletePolicies(gov);
      System.out.println("########## Successfully deleted sample policies ###########");
      deleteServices(gov, "soapservice");
      System.out.println("########## Successfully deleted sample Soap Services ###########");
      deleteServices(gov, "restservice");
      System.out.println("########## Successfully deleted sample Rest Services ###########");

    } catch (Exception e) {
      System.out.println("An error occurred.");
      e.printStackTrace();
    }
    System.exit(0);
  }
  public static void main(String[] args) throws AxisFault {

    ConfigurationContext cc =
        ConfigurationContextFactory.createConfigurationContextFromFileSystem(
            args[0], args[1] + "/axis2.xml");
    OMElement payload = createPayLoad();
    ServiceClient serviceclient = new ServiceClient(cc, null);

    Options opts = new Options();
    opts.setTo(new EndpointReference(args[2] + "/RMProxy"));
    opts.setAction("urn:add");
    opts.setUseSeparateListener(true);
    opts.setSoapVersionURI(SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI);

    serviceclient.setOptions(opts);
    serviceclient.engageModule("Mercury");
    serviceclient.engageModule("addressing");

    for (int i = 0; i < 4; i++) {
      try {
        OMElement response = serviceclient.sendReceive(payload);
        System.out.println(response);
      } catch (RemoteException e) {
        e.printStackTrace();
      }

      try {
        Thread.sleep(1000);
      } catch (InterruptedException e) {
        e.printStackTrace();
      }
    }
    // Setting the last message
    serviceclient.getOptions().setProperty("MercuryLastMessage", Constants.VALUE_TRUE);

    try {
      OMElement response = serviceclient.sendReceive(payload);
    } catch (RemoteException e) {
      e.printStackTrace();
    }

    try {
      Thread.sleep(5000);
    } catch (InterruptedException e) {
      e.printStackTrace();
    }
    cc.getListenerManager().stop();
  }
Esempio n. 14
0
  public ConfigurationContext getClientCfgCtx() throws Exception {
    ConfigurationContext cfgCtx =
        ConfigurationContextFactory.createConfigurationContext(new CustomAxisConfigurator());
    AxisConfiguration axisCfg = cfgCtx.getAxisConfiguration();
    axisCfg.engageModule("addressing");

    TransportInDescription trpInDesc = new TransportInDescription("udp");
    trpInDesc.setReceiver(new UDPListener());
    axisCfg.addTransportIn(trpInDesc);

    TransportOutDescription trpOutDesc = new TransportOutDescription("udp");
    trpOutDesc.setSender(new UDPSender());
    axisCfg.addTransportOut(trpOutDesc);

    return cfgCtx;
  }
Esempio n. 15
0
  public static ServiceContext createAdressedEnabledClientSide(
      AxisService service, String clientHome) throws AxisFault {
    File file = getAddressingMARFile();
    TestCase.assertTrue(file.exists());

    ConfigurationContext configContext =
        ConfigurationContextFactory.createConfigurationContextFromFileSystem(clientHome, null);
    AxisConfiguration axisConfiguration = configContext.getAxisConfiguration();

    AxisModule axisModule = DeploymentEngine.buildModule(file, axisConfiguration);
    axisConfiguration.addModule(axisModule);

    axisConfiguration.addService(service);
    ServiceGroupContext serviceGroupContext =
        configContext.createServiceGroupContext((AxisServiceGroup) service.getParent());
    return serviceGroupContext.getServiceContext(service);
  }
Esempio n. 16
0
  public static void main(String[] args) throws Exception {

    if (args.length != 3) {
      System.out.println("Usage: $java Client endpoint_address client_repo_path policy_xml_path");
    }

    ConfigurationContext ctx =
        ConfigurationContextFactory.createConfigurationContextFromFileSystem(args[1], null);

    STSClient stsClient = new STSClient(ctx);

    stsClient.setRstTemplate(getRSTTemplate());
    String action =
        TrustUtil.getActionValue(RahasConstants.VERSION_05_02, RahasConstants.RST_ACTION_ISSUE);
    stsClient.setAction(action);

    Token responseToken =
        stsClient.requestSecurityToken(
            loadPolicy("sample05/policy.xml"),
            "http://localhost:8080/axis2/services/STS",
            loadPolicy("sample05/sts_policy.xml"),
            null);

    System.out.println(
        "\n############################# Requested Token ###################################\n");
    System.out.println(responseToken.getToken().toString());

    TokenStorage store = TrustUtil.getTokenStore(ctx);
    store.add(responseToken);

    ServiceClient client = new ServiceClient(ctx, null);

    Options options = new Options();
    options.setAction("urn:echo");
    options.setTo(new EndpointReference(args[0]));
    options.setProperty(RampartMessageData.KEY_RAMPART_POLICY, loadPolicy("sample05/policy.xml"));
    options.setProperty(RampartMessageData.KEY_CUSTOM_ISSUED_TOKEN, responseToken.getId());
    client.setOptions(options);

    client.engageModule("addressing");
    client.engageModule("rampart");

    OMElement response = client.sendReceive(getPayload("Hello world1"));
    System.out.println("Response  : " + response);
  }
Esempio n. 17
0
  /**
   * Initialization of environment
   *
   * @throws Exception
   */
  public RemoteUMClient() throws Exception {
    ctx = ConfigurationContextFactory.createConfigurationContextFromFileSystem(null, null);
    String authEPR = serverUrl + "AuthenticationAdmin";
    authstub = new AuthenticationAdminStub(ctx, authEPR);
    ServiceClient client = authstub._getServiceClient();
    Options options = client.getOptions();
    options.setManageSession(true);
    options.setProperty(org.apache.axis2.transport.http.HTTPConstants.COOKIE_STRING, authCookie);

    // set trust store properties required in SSL communication.
    System.setProperty("javax.net.ssl.trustStore", RemoteUMSampleConstants.TRUST_STORE_PATH);
    System.setProperty(
        "javax.net.ssl.trustStorePassword", RemoteUMSampleConstants.TRUST_STORE_PASSWORD);

    // log in as admin user and obtain the cookie
    this.login(username, password);

    // create web service client
    this.createRemoteUserStoreManager();
  }
  public void testEchoXMLSync() throws Exception {
    for (int i = 0; i < 10; i++) {
      OMElement payload = createPayload();

      Options clientOptions = new Options();
      clientOptions.setTo(targetEPR);
      clientOptions.setProperty(Constants.Configuration.ENABLE_MTOM, Constants.VALUE_TRUE);
      clientOptions.setTransportInProtocol(Constants.TRANSPORT_HTTP);
      clientOptions.setSoapVersionURI(SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI);

      ConfigurationContext configContext =
          ConfigurationContextFactory.createConfigurationContextFromFileSystem(null, null);
      ServiceClient sender = new ServiceClient(configContext, null);
      sender.setOptions(clientOptions);

      OMElement result = sender.sendReceive(payload);

      OMElement data = (OMElement) result.getFirstOMChild();
      compareWithCreatedOMText(data.getText());
      log.info("" + i);
      UtilServer.unDeployClientService();
    }
  }
  /**
   * Invalidates registry cache of the resource in the given path in given server
   *
   * @param path registry path of the resource
   * @param tenantDomain
   * @param serverURL
   * @param cookie
   * @throws AxisFault
   * @throws RemoteException
   * @throws APIManagementException
   */
  public void clearCache(String path, String tenantDomain, String serverURL, String cookie)
      throws AxisFault, RemoteException, APIManagementException {
    RegistryCacheInvalidationServiceStub registryCacheServiceStub;

    ConfigurationContext ctx =
        ConfigurationContextFactory.createConfigurationContextFromFileSystem(null, null);
    registryCacheServiceStub =
        new RegistryCacheInvalidationServiceStub(
            ctx, serverURL + "RegistryCacheInvalidationService");
    ServiceClient client = registryCacheServiceStub._getServiceClient();
    Options options = client.getOptions();
    options.setTimeOutInMilliSeconds(TIMEOUT_IN_MILLIS);
    options.setProperty(HTTPConstants.SO_TIMEOUT, TIMEOUT_IN_MILLIS);
    options.setProperty(HTTPConstants.CONNECTION_TIMEOUT, TIMEOUT_IN_MILLIS);
    options.setManageSession(true);
    options.setProperty(HTTPConstants.COOKIE_STRING, cookie);

    try {
      registryCacheServiceStub.invalidateCache(path, tenantDomain);
    } catch (RegistryCacheInvalidationServiceAPIManagementExceptionException e) {
      APIUtil.handleException(e.getMessage(), e);
    }
  }
  /**
   * This method creates 3 soap envelopes for 3 different client based sessions. Then it randomly
   * choose one envelope for each iteration and send it to the ESB. ESB should be configured with
   * session affinity load balancer and the SampleClientInitiatedSession dispatcher. This will
   * output request number, session number and the server ID for each iteration. So it can be
   * observed that one session number always associated with one server ID.
   */
  private void sessionfullClient() {

    String synapsePort = "8280";
    int iterations = 100;
    boolean infinite = true;

    String pPort = getProperty("port", synapsePort);
    String pIterations = getProperty("i", null);
    String addUrl = getProperty("addurl", null);
    String trpUrl = getProperty("trpurl", null);
    String prxUrl = getProperty("prxurl", null);
    String sleep = getProperty("sleep", null);
    String session = getProperty("session", null);

    long sleepTime = -1;
    if (sleep != null) {
      try {
        sleepTime = Long.parseLong(sleep);
      } catch (NumberFormatException ignored) {
      }
    }

    if (pPort != null) {
      try {

        Integer.parseInt(pPort);
        synapsePort = pPort;
      } catch (NumberFormatException e) {
        // run with default value
      }
    }

    if (pIterations != null) {
      try {
        iterations = Integer.parseInt(pIterations);
        if (iterations != -1) {
          infinite = false;
        }
      } catch (NumberFormatException e) {
        // run with default values
      }
    }

    Options options = new Options();
    options.setTo(
        new EndpointReference("http://localhost:" + synapsePort + "/services/LBService1"));
    options.setAction("urn:sampleOperation");
    options.setTimeOutInMilliSeconds(10000000);

    try {

      SOAPEnvelope env1 = buildSoapEnvelope("c1", "v1");
      SOAPEnvelope env2 = buildSoapEnvelope("c2", "v1");
      SOAPEnvelope env3 = buildSoapEnvelope("c3", "v1");
      SOAPEnvelope[] envelopes = {env1, env2, env3};

      ConfigurationContext configContext =
          ConfigurationContextFactory.createConfigurationContextFromFileSystem("client_repo", null);
      ServiceClient client = new ServiceClient(configContext, null);

      // set addressing, transport and proxy url
      if (addUrl != null && !"null".equals(addUrl)) {
        client.engageModule("addressing");
        options.setTo(new EndpointReference(addUrl));
      }
      if (trpUrl != null && !"null".equals(trpUrl)) {
        options.setProperty(Constants.Configuration.TRANSPORT_URL, trpUrl);
      } else {
        client.engageModule("addressing");
      }
      if (prxUrl != null && !"null".equals(prxUrl)) {
        HttpTransportProperties.ProxyProperties proxyProperties =
            new HttpTransportProperties.ProxyProperties();
        try {
          URL url = new URL(prxUrl);
          proxyProperties.setProxyName(url.getHost());
          proxyProperties.setProxyPort(url.getPort());
          proxyProperties.setUserName("");
          proxyProperties.setPassWord("");
          proxyProperties.setDomain("");
          options.setProperty(HTTPConstants.PROXY, proxyProperties);
        } catch (MalformedURLException e) {
          throw new AxisFault("Error creating proxy URL", e);
        }
      }
      client.setOptions(options);

      int i = 0;
      int sessionNumber = 0;
      String[] cookies = new String[3];
      boolean httpSession = session != null && "http".equals(session);
      int cookieNumber = 0;
      while (i < iterations || infinite) {

        i++;
        if (sleepTime != -1) {
          try {
            Thread.sleep(sleepTime);
          } catch (InterruptedException ignored) {
          }
        }

        MessageContext messageContext = new MessageContext();
        sessionNumber = getSessionTurn(envelopes.length);

        messageContext.setEnvelope(envelopes[sessionNumber]);
        cookieNumber = getSessionTurn(cookies.length);
        String cookie = cookies[cookieNumber];
        if (httpSession) {
          setSessionID(messageContext, cookie);
        }
        try {
          OperationClient op = client.createClient(ServiceClient.ANON_OUT_IN_OP);
          op.addMessageContext(messageContext);
          op.execute(true);

          MessageContext responseContext =
              op.getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
          String receivedCookie = extractSessionID(responseContext);
          String receivedSetCookie = getSetCookieHeader(responseContext);
          if (httpSession) {

            if (receivedSetCookie != null && !"".equals(receivedSetCookie)) {
              cookies[cookieNumber] = receivedCookie;
            }
          }

          SOAPEnvelope responseEnvelope = responseContext.getEnvelope();

          OMElement vElement = responseEnvelope.getBody().getFirstChildWithName(new QName("Value"));
          System.out.println(
              "Request: "
                  + i
                  + " with Session ID: "
                  + (httpSession ? cookie : sessionNumber)
                  + " ---- "
                  + "Response : with  "
                  + (httpSession && receivedCookie != null
                      ? (receivedSetCookie != null ? receivedSetCookie : receivedCookie)
                      : " ")
                  + " "
                  + vElement.getText());
        } catch (AxisFault axisFault) {
          System.out.println(
              "Request with session id "
                  + (httpSession ? cookie : sessionNumber)
                  + " "
                  + "- Get a Fault : "
                  + axisFault.getMessage());
        }
      }

    } catch (AxisFault axisFault) {
      System.out.println(axisFault.getMessage());
    }
  }
Esempio n. 21
0
  private void run() {
    try {
      loadConfigurations();

      // set the trust store as a system property for communication over
      // TLS.
      System.setProperty("javax.net.ssl.trustStore", keystorePath);
      System.setProperty("javax.net.ssl.trustStorePassword", keystorePwd);

      // create configuration context
      ConfigurationContext configCtx =
          ConfigurationContextFactory.createConfigurationContextFromFileSystem(repoPath);

      // create STS client
      STSClient stsClient = new STSClient(configCtx);
      stsClient.setRstTemplate(getRSTTemplate());

      String action = null;
      String responseTokenID = null;

      action =
          TrustUtil.getActionValue(RahasConstants.VERSION_05_02, RahasConstants.RST_ACTION_ISSUE);
      stsClient.setAction(action);

      // request the security token from STS.
      Token responseToken;

      Policy stsPolicy = loadPolicy(stsPolicyPath);

      // add rampart config assertion to the ws-sec policies
      RampartConfig rampartConfig = buildRampartConfig();
      stsPolicy.addAssertion(rampartConfig);

      responseToken = stsClient.requestSecurityToken(null, stsEPR, stsPolicy, relyingPartyEPR);

      // store the obtained token in token store to be used in future
      // communication.
      TokenStorage store = TrustUtil.getTokenStore(configCtx);
      responseTokenID = responseToken.getId();
      store.add(responseToken);

      // print token
      System.out.println(responseToken.getToken().toString());
      // sending token renew request
      String renewedTokenID = null;
      if (enableRenewing) {
        System.out.println("Renewing " + tokenType);
        String TokenProfile = null;
        if (tokenType.equals(ClientConstants.SAML_TOKEN_TYPE_11)) {
          TokenProfile = RahasConstants.TOK_TYPE_SAML_10;
        } else if (tokenType.equals(ClientConstants.SAML_TOKEN_TYPE_20)) {
          TokenProfile = RahasConstants.TOK_TYPE_SAML_20;
        }

        stsClient.setRstTemplate(getRSTTemplate());
        boolean tokenRenewed =
            stsClient.renewToken(responseTokenID, TokenProfile, stsEPR, stsPolicy, store);
        System.out.println("tokenRenewed : " + tokenRenewed);

        Token renewedToken = store.getRenewedTokens()[0];
        renewedTokenID = renewedToken.getId();
        System.out.println("Renewed Token : \n" + renewedToken.getToken().toString());
      }
      // Validate the token
      if (enableValidateBinding) {
        // validating the token.
        stsClient = new STSClient(configCtx);
        action =
            TrustUtil.getActionValue(
                RahasConstants.VERSION_05_02, RahasConstants.RST_ACTION_VALIDATE);
        stsClient.setAction(action);
        String tokenID = null;
        if (renewedTokenID != null) {
          tokenID = renewedTokenID;
        } else {
          tokenID = responseTokenID;
        }
        boolean isValid = stsClient.validateToken(tokenID, stsEPR, stsPolicy);

        if (isValid) {
          if (enableRenewing) {
            System.out.println("Renewed SAML " + tokenType + " Token is valid");
          } else {
            System.out.println("Response SAML " + tokenType + " Token is valid");
          }
        } else {
          if (enableRenewing) {
            System.out.println("Renewed SAML " + tokenType + " Token is invalid");
          } else {
            System.out.println("Response SAML " + tokenType + " Token is invalid");
          }
        }
      }

      // Send the token to relying party
      if (enableRelyingParty) {
        /* Invoke secured service using the obtained token */
        OMElement responseElem = null;

        // create service client
        ServiceClient serClient = new ServiceClient(configCtx, null);

        // engage modules
        serClient.engageModule("addressing");
        serClient.engageModule("rampart");

        // load policy of secured service
        Policy sec_policy = loadPolicy(relyingPartyPolicyPath);

        // add rampart config to the ws-sec policies
        sec_policy.addAssertion(rampartConfig);

        // set in/out security policies in client opts
        serClient.getOptions().setProperty(RampartMessageData.KEY_RAMPART_POLICY, sec_policy);

        // Set the token id as a property in the Axis2 client scope, so
        // that this will be picked up when creating the secure message to
        // invoke
        // the endpoint.
        serClient
            .getOptions()
            .setProperty(RampartMessageData.KEY_CUSTOM_ISSUED_TOKEN, renewedTokenID);

        // set action of the Hello Service to be invoked.
        serClient.getOptions().setAction("urn:echoString");
        serClient.getOptions().setTo(new EndpointReference(relyingPartyEPR));

        // invoke the service
        // System.out.println(serClient.sendReceive(getPayload(echoRequestMsg)).toString());
        responseElem = serClient.sendReceive(getPayload(echoRequestMsg));
        // cleanup transports
        serClient.getOptions().setCallTransportCleanup(true);

        System.out.println(responseElem.toString());

        System.exit(0);
      }
    } catch (Exception e) {
      e.printStackTrace();
    } finally {
      System.exit(0);
    }
  }
Esempio n. 22
0
 private static ConfigurationContext getConfigurationContext() throws AxisFault {
   return ConfigurationContextFactory.createConfigurationContextFromFileSystem(
       "src/main/resources/axis2_client.xml");
 }
Esempio n. 23
0
  public OMElement runSecurityClient(
      int scenarioNo, String serviceName, String soapAction, String body) throws Exception {

    FrameworkSettings.getProperty();
    String clientRepo = null;
    String trustStore = null;
    String endpointHttpS = null;
    String endpointHttp = null;
    String securityPolicy = null;
    String clientKey = null;

    File filePath = new File("./");
    String relativePath = filePath.getCanonicalPath();
    File findFile =
        new File(
            relativePath + File.separator + "config" + File.separator + "framework.properties");
    if (!findFile.isFile()) {
      filePath = new File("./../");
      relativePath = filePath.getCanonicalPath();
    }

    /*Properties properties = new Properties();
    FileInputStream freader = new FileInputStream(relativePath + File.separator + "proxyservices" + File.separator + "src" + File.separator + "test" + File.separator + "resources"+ File.separator + "ClientSecurityFiles" + File.separator + "client.properties");
    properties.load(freader);*/
    if (FrameworkSettings.STRATOS.equalsIgnoreCase("true")) {
      clientRepo =
          FrameworkSettings.TEST_FRAMEWORK_HOME
              + File.separator
              + "lib"
              + File.separator
              + "stratos-artifacts"
              + File.separator
              + "client_repo";
      endpointHttpS =
          "https://"
              + FrameworkSettings.HOST_NAME
              + ":"
              + FrameworkSettings.HTTPS_PORT
              + "/services/"
              + FrameworkSettings.TENANT_NAME
              + "/"
              + serviceName;
      endpointHttp =
          "http://"
              + FrameworkSettings.HOST_NAME
              + ":"
              + FrameworkSettings.HTTP_PORT
              + "/services/"
              + FrameworkSettings.TENANT_NAME
              + "/"
              + serviceName;
      clientKey =
          FrameworkSettings.TEST_FRAMEWORK_HOME
              + File.separator
              + "lib"
              + File.separator
              + "stratos-artifacts"
              + File.separator
              + "wso2carbon.jks";
      trustStore =
          FrameworkSettings.TEST_FRAMEWORK_HOME
              + File.separator
              + "lib"
              + File.separator
              + "stratos-artifacts"
              + File.separator
              + "wso2carbon.jks";
      securityPolicy =
          relativePath
              + File.separator
              + "proxyservices"
              + File.separator
              + "src"
              + File.separator
              + "test"
              + File.separator
              + "resources"
              + File.separator
              + "ClientSecurityFiles";

    } else if (FrameworkSettings.STRATOS.equalsIgnoreCase("false")) {
      clientRepo =
          FrameworkSettings.CARBON_HOME
              + File.separator
              + "samples"
              + File.separator
              + "axis2Client"
              + File.separator
              + "client_repo";
      endpointHttpS =
          "https://"
              + FrameworkSettings.HOST_NAME
              + ":"
              + FrameworkSettings.HTTPS_PORT
              + "/services/"
              + serviceName;
      endpointHttp =
          "http://"
              + FrameworkSettings.HOST_NAME
              + ":"
              + FrameworkSettings.HTTP_PORT
              + "/services/"
              + serviceName;
      clientKey =
          FrameworkSettings.CARBON_HOME
              + File.separator
              + "resources"
              + File.separator
              + "security"
              + File.separator
              + "wso2carbon.jks";
      trustStore =
          FrameworkSettings.CARBON_HOME
              + File.separator
              + "resources"
              + File.separator
              + "security"
              + File.separator
              + "wso2carbon.jks";
      securityPolicy =
          relativePath
              + File.separator
              + "proxyservices"
              + File.separator
              + "src"
              + File.separator
              + "test"
              + File.separator
              + "resources"
              + File.separator
              + "ClientSecurityFiles";
    }
    OMElement result;

    System.setProperty("javax.net.ssl.trustStore", trustStore);
    System.setProperty("javax.net.ssl.trustStorePassword", "wso2carbon");

    ConfigurationContext ctx =
        ConfigurationContextFactory.createConfigurationContextFromFileSystem(clientRepo, null);
    ServiceClient sc = new ServiceClient(ctx, null);
    sc.engageModule("rampart");
    sc.engageModule("addressing");

    Options opts = new Options();

    if (scenarioNo == 1) {
      opts.setTo(new EndpointReference(endpointHttpS));
    } else {
      opts.setTo(new EndpointReference(endpointHttp));
    }

    opts.setAction(soapAction);

    if (scenarioNo != 0) {
      try {
        String securityPolicyPath =
            securityPolicy + File.separator + "scenario" + scenarioNo + "-policy.xml";
        opts.setProperty(
            RampartMessageData.KEY_RAMPART_POLICY, loadPolicy(securityPolicyPath, clientKey));
      } catch (Exception e) {
        e.printStackTrace();
      }
    }
    sc.setOptions(opts);
    result = sc.sendReceive(AXIOMUtil.stringToOM(body));
    System.out.println(result.getFirstElement().getText());
    return result;
  }
Esempio n. 24
0
 public static ConfigurationContext createClientConfigurationContext(String repo)
     throws AxisFault {
   return ConfigurationContextFactory.createConfigurationContextFromFileSystem(
       repo, repo + "/conf/axis2.xml");
 }
  public String sessionlessClient() throws AxisFault {

    String synapsePort = "8280";
    int iterations = 100;
    boolean infinite = true;

    String pPort = getProperty("port", synapsePort);
    String pIterations = getProperty("i", null);
    String addUrl = getProperty("addurl", null);
    String trpUrl = getProperty("trpurl", null);
    String prxUrl = getProperty("prxurl", null);

    String sleep = getProperty("sleep", null);

    long sleepTime = -1;
    if (sleep != null) {
      try {
        sleepTime = Long.parseLong(sleep);
      } catch (NumberFormatException ignored) {
      }
    }

    if (pPort != null) {
      try {
        Integer.parseInt(pPort);
        synapsePort = pPort;
      } catch (NumberFormatException e) {
        // run with default value
      }
    }

    if (pIterations != null) {
      try {
        iterations = Integer.parseInt(pIterations);
        if (iterations != -1) {
          infinite = false;
        }
      } catch (NumberFormatException e) {
        // run with default values
      }
    }

    OMFactory fac = OMAbstractFactory.getOMFactory();
    OMElement value = fac.createOMElement("Value", null);
    value.setText("Sample string");

    Options options = new Options();
    options.setTo(
        new EndpointReference("http://localhost:" + synapsePort + "/services/LBService1"));

    options.setAction("urn:sampleOperation");

    String repo = System.getProperty("repository");
    ConfigurationContext configContext;
    if (repo != null) {
      configContext =
          ConfigurationContextFactory.createConfigurationContextFromFileSystem(
              repo, repo + File.separator + "conf" + File.separator + "axis2.xml");
    } else {
      configContext =
          ConfigurationContextFactory.createConfigurationContextFromFileSystem("client_repo", null);
    }
    ServiceClient client = new ServiceClient(configContext, null);
    long timeout = Integer.parseInt(getProperty("timeout", "10000000"));
    System.out.println("timeout=" + timeout);
    options.setTimeOutInMilliSeconds(timeout);

    // set addressing, transport and proxy url
    if (addUrl != null && !"null".equals(addUrl)) {
      client.engageModule("addressing");
      options.setTo(new EndpointReference(addUrl));
    }
    if (trpUrl != null && !"null".equals(trpUrl)) {
      options.setProperty(Constants.Configuration.TRANSPORT_URL, trpUrl);
    } else {
      client.engageModule("addressing");
    }
    if (prxUrl != null && !"null".equals(prxUrl)) {
      HttpTransportProperties.ProxyProperties proxyProperties =
          new HttpTransportProperties.ProxyProperties();
      try {
        URL url = new URL(prxUrl);
        proxyProperties.setProxyName(url.getHost());
        proxyProperties.setProxyPort(url.getPort());
        proxyProperties.setUserName("");
        proxyProperties.setPassWord("");
        proxyProperties.setDomain("");
        options.setProperty(HTTPConstants.PROXY, proxyProperties);
      } catch (MalformedURLException e) {
        throw new AxisFault("Error creating proxy URL", e);
      }
    }

    client.setOptions(options);
    String testString = "";

    long i = 0;
    while (i < iterations || infinite) {

      if (sleepTime != -1) {
        try {
          Thread.sleep(sleepTime);
        } catch (InterruptedException ignored) {
        }
      }

      client.getOptions().setManageSession(true);
      OMElement responseElement = client.sendReceive(value);
      String response = responseElement.getText();

      i++;
      System.out.println("Request: " + i + " ==> " + response);
      testString += (":" + i + ">" + response + ":");
    }

    return testString;
  }
  /**
   * Create Tenant Axis2 ConfigurationContexts & add them to the main Axis2 ConfigurationContext
   *
   * @param mainConfigCtx Super-tenant Axis2 ConfigurationContext
   * @param tenantDomain Tenant domain (e.g. foo.com)
   * @return The newly created Tenant ConfigurationContext
   * @throws Exception If an error occurs while creating tenant ConfigurationContext
   */
  private static ConfigurationContext createTenantConfigurationContext(
      ConfigurationContext mainConfigCtx, String tenantDomain) throws Exception {
    synchronized (tenantDomain.intern()) { // lock based on tenant domain
      Map<String, ConfigurationContext> tenantConfigContexts =
          getTenantConfigurationContexts(mainConfigCtx);
      ConfigurationContext tenantConfigCtx = tenantConfigContexts.get(tenantDomain);
      if (tenantConfigCtx != null) {
        return tenantConfigCtx;
      }
      long tenantLoadingStartTime = System.currentTimeMillis();
      int tenantId = getTenantId(tenantDomain);
      if (tenantId == MultitenantConstants.SUPER_TENANT_ID
          || tenantId == MultitenantConstants.INVALID_TENANT_ID) {
        throw new Exception("Tenant " + tenantDomain + " does not exist");
      }
      PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
      carbonContext.setTenantId(tenantId);
      carbonContext.setTenantDomain(tenantDomain);

      tenantConfigCtx = tenantConfigContexts.get(tenantDomain);
      if (tenantConfigCtx != null) {
        return tenantConfigCtx;
      }

      AxisConfiguration mainAxisConfig = mainConfigCtx.getAxisConfiguration();

      dataHolder.getTenantRegistryLoader().loadTenantRegistry(tenantId);

      try {
        UserRegistry tenantConfigRegistry =
            dataHolder.getRegistryService().getConfigSystemRegistry(tenantId);
        UserRegistry tenantLocalUserRegistry =
            dataHolder.getRegistryService().getLocalRepository(tenantId);
        TenantAxisConfigurator tenantAxisConfigurator =
            new TenantAxisConfigurator(
                mainAxisConfig,
                tenantDomain,
                tenantId,
                tenantConfigRegistry,
                tenantLocalUserRegistry);
        doPreConfigContextCreation(tenantId);
        tenantConfigCtx =
            ConfigurationContextFactory.createConfigurationContext(tenantAxisConfigurator);

        AxisConfiguration tenantAxisConfig = tenantConfigCtx.getAxisConfiguration();

        tenantConfigCtx.setServicePath(CarbonUtils.getAxis2ServicesDir(tenantAxisConfig));
        tenantConfigCtx.setContextRoot("local:/");

        TenantTransportSender transportSender = new TenantTransportSender(mainConfigCtx);
        // Adding transport senders
        HashMap<String, TransportOutDescription> transportSenders =
            mainAxisConfig.getTransportsOut();
        if (transportSenders != null && !transportSenders.isEmpty()) {
          for (String strTransport : transportSenders.keySet()) {
            TransportOutDescription outDescription = new TransportOutDescription(strTransport);
            outDescription.setSender(transportSender);
            tenantAxisConfig.addTransportOut(outDescription);
          }
        }

        // Set the work directory
        tenantConfigCtx.setProperty(
            ServerConstants.WORK_DIR, mainConfigCtx.getProperty(ServerConstants.WORK_DIR));
        PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantId(tenantId);
        new TransportPersistenceManager(tenantAxisConfig)
            .updateEnabledTransports(
                tenantAxisConfig.getTransportsIn().values(),
                tenantAxisConfig.getTransportsOut().values());

        // Notify all observers
        BundleContext bundleContext = dataHolder.getBundleContext();
        if (bundleContext != null) {
          ServiceTracker tracker =
              new ServiceTracker(
                  bundleContext, Axis2ConfigurationContextObserver.class.getName(), null);
          tracker.open();
          Object[] services = tracker.getServices();
          if (services != null) {
            for (Object service : services) {
              ((Axis2ConfigurationContextObserver) service)
                  .createdConfigurationContext(tenantConfigCtx);
            }
          }
          tracker.close();
        }
        tenantConfigCtx.setProperty(MultitenantConstants.LAST_ACCESSED, System.currentTimeMillis());

        // Register Capp deployer for this tenant
        Utils.addCAppDeployer(tenantAxisConfig);

        // deploy the services since all the deployers are initialized by now.
        tenantAxisConfigurator.deployServices();

        // tenant config context must only be made after the tenant is fully loaded, and all its
        // artifacts
        // are deployed.
        // -- THIS SHOULD BE THE LAST OPERATION OF THIS METHOD --
        tenantConfigContexts.put(tenantDomain, tenantConfigCtx);

        log.info(
            "Loaded tenant "
                + tenantDomain
                + " in "
                + (System.currentTimeMillis() - tenantLoadingStartTime)
                + " ms");

        return tenantConfigCtx;
      } catch (Exception e) {
        String msg = "Error occurred while running deployment for tenant ";
        log.error(msg + tenantDomain, e);
        throw new Exception(msg, e);
      }
    }
  }
  @Test(groups = {"wso2.greg"})
  public void testPaginate() throws Exception {
    try {
      Registry gov = GovernanceUtils.getGovernanceUserRegistry(registry, "admin");
      // Should be load the governance artifact.
      GovernanceUtils.loadGovernanceArtifacts((UserRegistry) gov);
      addServices(gov);
      // Initialize the pagination context.
      // Top five services, sortBy name , and sort order descending.
      PaginationContext.init(0, 5, "DES", "overview_name", 100);
      WSRegistrySearchClient wsRegistrySearchClient = new WSRegistrySearchClient();
      // This should be execute to initialize the AttributeSearchService.
      ConfigurationContext configContext;
      String axis2Repo = FrameworkPathUtil.getSystemResourceLocation() + "client";
      String axis2Conf =
          FrameworkPathUtil.getSystemResourceLocation()
              + "axis2config"
              + File.separator
              + "axis2_client.xml";
      TestFrameworkUtils.setKeyStoreProperties(automationContext);
      configContext =
          ConfigurationContextFactory.createConfigurationContextFromFileSystem(
              axis2Repo, axis2Conf);
      configContext.setProperty(HTTPConstants.CONNECTION_TIMEOUT, TIME_OUT_VALUE);

      wsRegistrySearchClient.init(cookie, backendURL, configContext);

      //            wsRegistrySearchClient.authenticate(configContext, getServiceURL(),
      //                    automationContext.getContextTenant().getContextUser().getUserName(),
      //                    automationContext.getContextTenant().getContextUser().getPassword());

      // Initialize the GenericArtifactManager
      GenericArtifactManager artifactManager = new GenericArtifactManager(gov, "service");
      Map<String, List<String>> listMap = new HashMap<String, List<String>>();
      // Create the search attribute map
      listMap.put(
          "lcName",
          new ArrayList<String>() {
            {
              add("ServiceLifeCycle");
            }
          });
      listMap.put(
          "lcState",
          new ArrayList<String>() {
            {
              add("Development");
            }
          });
      // Find the results.
      GenericArtifact[] genericArtifacts = artifactManager.findGenericArtifacts(listMap);
      assertTrue(genericArtifacts.length > 0, "No any service found");
      assertTrue(genericArtifacts.length == 5, "Filtered service count should be 5");
      assertTrue(
          genericArtifacts[0].getQName().getLocalPart().equals("FlightService9"),
          "filter results are not sorted");
      assertTrue(
          genericArtifacts[4].getQName().getLocalPart().equals("FlightService5"),
          "filter results are not sorted");
    } finally {
      PaginationContext.destroy();
    }
  }
Esempio n. 28
0
  private void run() throws Exception {

    if ("<SANDESHA2_HOME>".equals(SANDESHA2_HOME)) {
      System.out.println(
          "ERROR: Please set the directory you unzipped Sandesha2 as the first option.");
      return;
    }

    String axis2_xml = AXIS2_CLIENT_PATH + "client_axis2.xml";

    ConfigurationContext configContext =
        ConfigurationContextFactory.createConfigurationContextFromFileSystem(
            AXIS2_CLIENT_PATH, axis2_xml);

    ServiceClient serviceClient = new ServiceClient(configContext, null);

    Options clientOptions = new Options();

    clientOptions.setTo(new EndpointReference(toEPR));

    String acksTo =
        serviceClient.getMyEPR(Constants.TRANSPORT_HTTP).getAddress()
            + "/"
            + ServiceClient.ANON_OUT_IN_OP;
    clientOptions.setProperty(SandeshaClientConstants.AcksTo, acksTo);

    String sequenceKey = "sequence4";
    clientOptions.setProperty(SandeshaClientConstants.SEQUENCE_KEY, sequenceKey);

    clientOptions.setProperty(Configuration.TRANSPORT_URL, transportToEPR);

    //		clientOptions.setProperty(MessageContextConstants.CHUNKED,Constants.VALUE_FALSE);
    // //uncomment this to send messages without chunking.

    clientOptions.setSoapVersionURI(
        SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI); // uncomment this to send messages in SOAP 1.2

    //
    //	clientOptions.setProperty(SandeshaClient.RM_SPEC_VERSION,Sandesha2Constants.SPEC_VERSIONS.v1_1);  //uncomment this to send the messages according to the v1_1 spec.

    clientOptions.setProperty(
        AddressingConstants.WS_ADDRESSING_VERSION, AddressingConstants.Submission.WSA_NAMESPACE);
    clientOptions.setProperty(
        SandeshaClientConstants.OFFERED_SEQUENCE_ID,
        SandeshaUtil.getUUID()); // Uncomment this to offer a sequenceID for the incoming sequence.
    clientOptions.setAction("urn:wsrm:EchoString");

    // You must set the following two properties in the request-reply case.
    clientOptions.setTransportInProtocol(Constants.TRANSPORT_HTTP);
    clientOptions.setUseSeparateListener(true);

    serviceClient.setOptions(clientOptions);

    clientOptions.setTimeOutInMilliSeconds(40000);

    OMElement result = serviceClient.sendReceive(getEchoOMBlock("echo1", sequenceKey));
    showResult(result);

    result = serviceClient.sendReceive(getEchoOMBlock("echo2", sequenceKey));
    showResult(result);

    result = serviceClient.sendReceive(getEchoOMBlock("echo3", sequenceKey));
    showResult(result);

    result = serviceClient.sendReceive(getEchoOMBlock("echo4", sequenceKey));
    showResult(result);

    clientOptions.setProperty(SandeshaClientConstants.LAST_MESSAGE, "true");
    OMElement bodyElem = getEchoOMBlock("echo5", sequenceKey);

    result = serviceClient.sendReceive(bodyElem);
    showResult(result);

    Thread.sleep(4000);
  }