Package org.apache.axis2.client

Examples of org.apache.axis2.client.Options


    
    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 = SandeshaUtil.getUUID()//sequence key for thie sequence.
    clientOptions.setProperty(SandeshaClientConstants.SEQUENCE_KEY,sequenceKey);
   
//    clientOptions.setReplyTo(new EndpointReference (AddressingConstants.Final.WSA_ANONYMOUS_URL));
//    clientOptions.setProperty(MessageContextConstants.CHUNKED,Constants.VALUE_FALSE);   //uncomment this to send messages without chunking.
//    clientOptions.setProperty(SandeshaClientConstants.RM_SPEC_VERSION,Sandesha2Constants.SPEC_VERSIONS.v1_1);  //uncomment this to send the messages according to the v1_1 spec.
//    serviceClient.engageModule(new QName ("sandesha2"));

    clientOptions.setProperty(MessageContextConstants.TRANSPORT_URL,transportToEPR);
   
    clientOptions.setSoapVersionURI(SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI);   //uncomment this to send messages in SOAP 1.2

    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);

    Callback callback1 = new TestCallback ("Callback 1");
    serviceClient.sendReceiveNonBlocking (getEchoOMBlock("echo1",sequenceKey),callback1);
   
    Callback callback2 = new TestCallback ("Callback 2");
    serviceClient.sendReceiveNonBlocking(getEchoOMBlock("echo2",sequenceKey),callback2);

    Callback callback3 = new TestCallback ("Callback 3");
    serviceClient.sendReceiveNonBlocking(getEchoOMBlock("echo3",sequenceKey),callback3);
   
    Callback callback4 = new TestCallback ("Callback 4");
    serviceClient.sendReceiveNonBlocking(getEchoOMBlock("echo4",sequenceKey),callback4);

    clientOptions.setProperty(SandeshaClientConstants.LAST_MESSAGE, "true");
    Callback callback5 = new TestCallback ("Callback 5");
    serviceClient.sendReceiveNonBlocking(getEchoOMBlock("echo5",sequenceKey),callback5);
   
        while (!callback5.isComplete()) {
            Thread.sleep(1000);
View Full Code Here


      AxisConfiguration axisConfiguration = configContext.getAxisConfiguration();

      MessageContext newMessageContext = new MessageContext();
      newMessageContext.setConfigurationContext(configContext);
     
      Options newOptions = new Options ();
      Options oldOptions = referenceMessage.getOptions();
     
      newMessageContext.setOptions(newOptions);
     
      if (referenceMessage.getAxisServiceGroup() != null) {
        newMessageContext.setAxisServiceGroup(referenceMessage.getAxisServiceGroup());
       
        if (referenceMessage.getServiceGroupContext()!=null) {
          newMessageContext.setServiceGroupContext(referenceMessage.getServiceGroupContext());
          newMessageContext.setServiceGroupContextId(referenceMessage.getServiceGroupContextId());
        } else {
          ServiceGroupContext serviceGroupContext = new ServiceGroupContext (
              configContext,referenceMessage.getAxisServiceGroup());
          newMessageContext.setServiceGroupContext(serviceGroupContext);
        }
      } else {
        AxisServiceGroup axisServiceGroup = new AxisServiceGroup(axisConfiguration);
        ServiceGroupContext serviceGroupContext = new ServiceGroupContext(configContext, axisServiceGroup);

        newMessageContext.setAxisServiceGroup(axisServiceGroup);
        newMessageContext.setServiceGroupContext(serviceGroupContext);
      }

      if (referenceMessage.getAxisService() != null) {
        newMessageContext.setAxisService(referenceMessage.getAxisService());
       
        if (referenceMessage.getServiceContext()!=null) {
          newMessageContext.setServiceContext(referenceMessage.getServiceContext());
          newMessageContext.setServiceContextID(referenceMessage.getServiceContextID());
        } else {
          ServiceContext serviceContext = new ServiceContext (referenceMessage.getAxisService(),newMessageContext.getServiceGroupContext());
          newMessageContext.setServiceContext(serviceContext);
        }
      }

      newMessageContext.setAxisOperation(operation);

      //The message created will basically be used as a outMessage, so setting the AxisMessage accordingly
      newMessageContext.setAxisMessage(operation.getMessage(WSDLConstants.MESSAGE_LABEL_OUT_VALUE));
     
      OperationContext operationContext = new OperationContext(operation, newMessageContext.getServiceContext());
      newMessageContext.setOperationContext(operationContext);
      operationContext.addMessageContext(newMessageContext);

      // adding a blank envelope
      SOAPFactory factory = SOAPAbstractFactory.getSOAPFactory(SandeshaUtil.getSOAPVersion(referenceMessage
          .getEnvelope()));
      newMessageContext.setEnvelope(factory.getDefaultEnvelope());

      newMessageContext.setTransportIn(referenceMessage.getTransportIn());
      newMessageContext.setTransportOut(referenceMessage.getTransportOut());

      // copying transport info.
      newMessageContext.setProperty(MessageContext.TRANSPORT_OUT, referenceMessage
          .getProperty(MessageContext.TRANSPORT_OUT));

      newMessageContext.setProperty(Constants.OUT_TRANSPORT_INFO, referenceMessage
          .getProperty(Constants.OUT_TRANSPORT_INFO));
      newMessageContext.setProperty(MessageContext.TRANSPORT_HEADERS, referenceMessage
          .getProperty(MessageContext.TRANSPORT_HEADERS));
      newMessageContext.setProperty(MessageContext.TRANSPORT_IN, referenceMessage
          .getProperty(MessageContext.TRANSPORT_IN));
      newMessageContext.setProperty(MessageContext.TRANSPORT_OUT, referenceMessage
          .getProperty(MessageContext.TRANSPORT_OUT));
     
      newMessageContext.setProperty(AddressingConstants.WS_ADDRESSING_VERSION,
          referenceMessage.getProperty(AddressingConstants.WS_ADDRESSING_VERSION));
     
      copyConfiguredProperties (referenceMessage,newMessageContext);

      //copying the serverSide property
      newMessageContext.setServerSide(referenceMessage.isServerSide());
     
      //this had to be set here to avoid a double invocation.
      if (oldOptions!=null)
        newOptions.setUseSeparateListener(oldOptions.isUseSeparateListener());

      return newMessageContext;

    } catch (AxisFault e) {
      log.debug(e.getMessage());
View Full Code Here

    return phases;
  }
 
  public static MessageContext cloneMessageContext (MessageContext oldMsg) throws AxisFault {
    MessageContext newMsg = new MessageContext ();
    newMsg.setOptions(new Options (oldMsg.getOptions()));
   
   
    //TODO hd to use following hack since a 'clone' method was not available for SOAPEnvelopes.
    //Do it the correct way when that becomes available.
    OMElement newElement = oldMsg.getEnvelope().cloneOMElement();
View Full Code Here

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

    ServiceClient serviceClient = new ServiceClient (configContext,null);
//    serviceClient.engageModule(new QName ("sandesha2"));
   
    Options clientOptions = new Options ();
   
//    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.setTo(new EndpointReference (toEPR));
   
    EndpointReference endpoint =   serviceClient.getMyEPR(Constants.TRANSPORT_HTTP);
    clientOptions.setProperty(SandeshaClientConstants.AcksTo,endpoint.getAddress());
   
    clientOptions.setTransportInProtocol(Constants.TRANSPORT_HTTP);
    clientOptions.setAction("urn:wsrm:Ping");
   
    String sequenceKey = "sequence2";
    clientOptions.setProperty(SandeshaClientConstants.SEQUENCE_KEY,sequenceKey);
   
    serviceClient.setOptions(clientOptions);
   
    serviceClient.fireAndForget(getPingOMBlock("ping1"));
    serviceClient.fireAndForget(getPingOMBlock("ping2"));
   
    clientOptions.setProperty(SandeshaClientConstants.LAST_MESSAGE, "true");
    serviceClient.fireAndForget(getPingOMBlock("ping3"));
   
    boolean complete = false;
    while (!complete) {
      SequenceReport sequenceReport = SandeshaClient.getOutgoingSequenceReport(serviceClient);
View Full Code Here

    ServiceClient serviceClient = new ServiceClient (configContext,null);
   
//    serviceClient.engageModule(new QName ("sandesha2"));
   
    Options clientOptions = new Options ();
   
    clientOptions.setTo(new EndpointReference (toEPR));
   
    String sequenceKey = "sequence3";
    clientOptions.setProperty(SandeshaClientConstants.SEQUENCE_KEY,sequenceKey);

    //You must set the following two properties in the request-reply case.
    clientOptions.setTransportInProtocol(Constants.TRANSPORT_HTTP);
    clientOptions.setUseSeparateListener(true);
    clientOptions.setAction("urn:wsrm:EchoString");
   
//    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(SandeshaClient.OFFERED_SEQUENCE_ID,SandeshaUtil.getUUID());  //Uncomment this to offer a sequenceID for the incoming sequence.
   
    serviceClient.setOptions(clientOptions);
   
    Callback callback1 = new TestCallback ("Callback 1");
    serviceClient.sendReceiveNonBlocking(getEchoOMBlock("echo1",sequenceKey),callback1);
   
    clientOptions.setAction("urn:wsrm:EchoString");
    Callback callback2 = new TestCallback ("Callback 2");
    serviceClient.sendReceiveNonBlocking(getEchoOMBlock("echo2",sequenceKey),callback2);
   
    clientOptions.setAction("urn:wsrm:EchoString");
   
    clientOptions.setProperty(SandeshaClientConstants.LAST_MESSAGE, "true");
    Callback callback3 = new TestCallback ("Callback 3");
    serviceClient.sendReceiveNonBlocking(getEchoOMBlock("echo3",sequenceKey),callback3);
   
        while (!callback3.isComplete()) {
            Thread.sleep(1000);
View Full Code Here

    
    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);
//    clientOptions.setProperty(MessageContextConstants.CHUNKED,Constants.VALUE_FALSE);   //uncomment this to send messages without chunking.
   
    String sequenceKey = SandeshaUtil.getUUID()//sequence key for thie sequence.
    clientOptions.setProperty(SandeshaClientConstants.SEQUENCE_KEY,sequenceKey);
   
    clientOptions.setReplyTo(new EndpointReference (AddressingConstants.Submission.WSA_ANONYMOUS_URL));
   
    clientOptions.setProperty(MessageContextConstants.TRANSPORT_URL,transportToEPR);
   
    clientOptions.setSoapVersionURI(SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI);   //uncomment this to send messages in SOAP 1.2
   
    clientOptions.setProperty(SandeshaClientConstants.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);

    //This asks Axis2 not to start a listner.
    clientOptions.setUseSeparateListener(true);
   
    serviceClient.setOptions(clientOptions);

    Callback callback1 = new TestCallback ("Callback 1");
    serviceClient.sendReceiveNonBlocking(getEchoOMBlock("echo1",sequenceKey),callback1);
View Full Code Here

   * @throws SandeshaException
   */
  public static String createSequence(ServiceClient serviceClient, boolean offer)
      throws SandeshaException {

    Options options = serviceClient.getOptions();
    if (options == null)
      throw new SandeshaException(SandeshaMessageHelper.getMessage(
          SandeshaMessageKeys.optionsObjectNotSet));
   
    String newSequenceKey = SandeshaUtil.getUUID();
View Full Code Here

    ServiceContext serviceContext = serviceClient.getServiceContext();
    if (serviceContext == null)
      throw new SandeshaException(SandeshaMessageHelper.getMessage(
          SandeshaMessageKeys.serviceContextNotSet));

    Options options = serviceClient.getOptions();
    if (options == null)
      throw new SandeshaException(SandeshaMessageHelper.getMessage(
          SandeshaMessageKeys.optionsObjectNotSet));

    String rmSpecVersion = (String) options.getProperty(SandeshaClientConstants.RM_SPEC_VERSION);

    if (rmSpecVersion == null)
      rmSpecVersion = SpecSpecificConstants.getDefaultSpecVersion();

    String rmNamespaceValue = SpecSpecificConstants.getRMNamespaceValue(rmSpecVersion);

    String oldAction = options.getAction();

    //in WSRM 1.0 we are adding another application msg with the LastMessage tag, instead of sending a terminate here.
    //Actual terminate will be sent once all the messages upto this get acked
   
    try {
      if (Sandesha2Constants.SPEC_VERSIONS.v1_1.equals(rmSpecVersion)) {
        SOAPEnvelope terminateEnvelope = configureTerminateSequence(options, serviceContext
            .getConfigurationContext());
        OMElement terminateBody = terminateEnvelope.getBody().getFirstChildWithName(
            new QName(rmNamespaceValue,
                Sandesha2Constants.WSRM_COMMON.TERMINATE_SEQUENCE));

        // to inform the Sandesha2 out handler.
        serviceClient.fireAndForget(terminateBody);

      } else {
        options.setAction(Sandesha2Constants.SPEC_2005_02.Actions.ACTION_LAST_MESSAGE);
        options.setProperty(SandeshaClientConstants.LAST_MESSAGE, Constants.VALUE_TRUE);
        serviceClient.fireAndForget(null);
      }
     
    } catch (AxisFault e) {
      String message = SandeshaMessageHelper.getMessage(
          SandeshaMessageKeys.couldNotSendTerminate,
          e.toString());
      throw new SandeshaException(message, e);
    } finally {
      options.setAction(oldAction);
    }
  }
View Full Code Here

      options.setAction(oldAction);
    }
  }

  public static void terminateSequence(ServiceClient serviceClient, String sequenceKey) throws SandeshaException {
    Options options = serviceClient.getOptions();
    if (options == null)
      throw new SandeshaException(SandeshaMessageHelper.getMessage(
          SandeshaMessageKeys.optionsObjectNotSet));

    String oldSequenceKey = (String) options.getProperty(SandeshaClientConstants.SEQUENCE_KEY);
    options.setProperty(SandeshaClientConstants.SEQUENCE_KEY, sequenceKey);
    terminateSequence(serviceClient);

    options.setProperty(SandeshaClientConstants.SEQUENCE_KEY, oldSequenceKey);
  }
View Full Code Here

    ServiceContext serviceContext = serviceClient.getServiceContext();
    if (serviceContext == null)
      throw new SandeshaException(SandeshaMessageHelper.getMessage(
          SandeshaMessageKeys.serviceContextNotSet));

    Options options = serviceClient.getOptions();
    if (options == null)
      throw new SandeshaException(SandeshaMessageHelper.getMessage(
          SandeshaMessageKeys.optionsObjectNotSet));

    String rmSpecVersion = (String) options.getProperty(SandeshaClientConstants.RM_SPEC_VERSION);

    if (rmSpecVersion == null)
      rmSpecVersion = SpecSpecificConstants.getDefaultSpecVersion();

    String rmNamespaceValue = SpecSpecificConstants.getRMNamespaceValue(rmSpecVersion);

    SOAPEnvelope closeSequnceEnvelope = configureCloseSequence(options, serviceContext.getConfigurationContext());
    OMElement closeSequenceBody = closeSequnceEnvelope.getBody().getFirstChildWithName(
        new QName(rmNamespaceValue, Sandesha2Constants.WSRM_COMMON.CLOSE_SEQUENCE));

    String oldAction = options.getAction();
    options.setAction(SpecSpecificConstants.getCloseSequenceAction(rmSpecVersion));
    try {
      //to inform the sandesha2 out handler
      serviceClient.fireAndForget (closeSequenceBody);
    } catch (AxisFault e) {
      String message = SandeshaMessageHelper.getMessage(
          SandeshaMessageKeys.couldNotSendClose,
          e.toString());
      throw new SandeshaException(message, e);
    } finally {
      options.setAction(oldAction);
    }
  }
View Full Code Here

TOP

Related Classes of org.apache.axis2.client.Options

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.