Package org.apache.axis2.clientapi

Examples of org.apache.axis2.clientapi.Call


                    }
                    fileObject.close();
                    if (!fileObject.delete()) {
                        String msg = "Cannot delete file : " + fileObject;
                        log.error(msg);
                        throw new AxisFault(msg);
                    }
                } catch (FileSystemException e) {
                    log.error("Error deleting file : " + fileObject, e);
                }
            }
View Full Code Here


                public void run() {
                    MessageReceiver mr = mc.getAxisOperation().getMessageReceiver();
                    try {
                        // This AxisFault is created to create the fault message context
                        // noinspection ThrowableInstanceNeverThrown
                        AxisFault axisFault = exceptionToRaise != null ?
                                new AxisFault(errorMessage, exceptionToRaise) :
                                new AxisFault(errorMessage);

                        MessageContext nioFaultMessageContext =
                            MessageContextBuilder.createFaultMessageContext(mc, axisFault);

                        SOAPEnvelope envelope = nioFaultMessageContext.getEnvelope();
View Full Code Here

            return failedRecordTimestampFormat;
      }

      @Override
    public EndpointReference[] getEndpointReferences(AxisService service, String ip) {
        return new EndpointReference[] { new EndpointReference("vfs:" + fileURI) };
    }
View Full Code Here

        try {

            MessageContext messageOut = MessageHelper.cloneMessageContext(messageIn);
            Options options = new Options();
            options.setTo(new EndpointReference(serviceUrl));
            if(messageIn.getSoapAction() != null) {

                options.setAction(messageIn.getSoapAction());

            } else {
View Full Code Here

                msgContext.setProperty(Constants.OUT_TRANSPORT_INFO,
                        new VFSOutTransportInfo(replyFileURI, entry.isFileLockingEnabled()));
            }

            // Determine the message builder to use
            Builder builder;
            if (contentType == null) {
                log.debug("No content type specified. Using SOAP builder.");
                builder = new SOAPBuilder();
            } else {
                int index = contentType.indexOf(';');
                String type = index > 0 ? contentType.substring(0, index) : contentType;
                builder = BuilderUtil.getBuilderFromSelector(type, msgContext);
                if (builder == null) {
                    if (log.isDebugEnabled()) {
                        log.debug("No message builder found for type '" + type +
                                "'. Falling back to SOAP.");
                    }
                    builder = new SOAPBuilder();
                }
            }

            // set the message payload to the message context
            InputStream in;
            ManagedDataSource dataSource;
            if (builder instanceof DataSourceMessageBuilder && entry.isStreaming()) {
                in = null;
                dataSource = ManagedDataSourceFactory.create(
                        new FileObjectDataSource(file, contentType));
            } else {
                in = content.getInputStream();
                dataSource = null;
            }
           
            try {
                OMElement documentElement;
                if (in != null) {
                    documentElement = builder.processDocument(in, contentType, msgContext);
                } else {
                    documentElement = ((DataSourceMessageBuilder)builder).processDocument(
                            dataSource, contentType, msgContext);
                }
                msgContext.setEnvelope(TransportUtils.createSOAPEnvelope(documentElement));
View Full Code Here

            // Determine the message builder to use
            Builder builder;
            if (contentType == null) {
                log.debug("No content type specified. Using SOAP builder.");
                builder = new SOAPBuilder();
            } else {
                int index = contentType.indexOf(';');
                String type = index > 0 ? contentType.substring(0, index) : contentType;
                builder = BuilderUtil.getBuilderFromSelector(type, msgContext);
                if (builder == null) {
                    if (log.isDebugEnabled()) {
                        log.debug("No message builder found for type '" + type +
                                "'. Falling back to SOAP.");
                    }
                    builder = new SOAPBuilder();
                }
            }

            // set the message payload to the message context
            InputStream in;
View Full Code Here

        }

        try {

            MessageContext messageOut = MessageHelper.cloneMessageContext(messageIn);
            Options options = new Options();
            options.setTo(new EndpointReference(serviceUrl));
            if(messageIn.getSoapAction() != null) {

                options.setAction(messageIn.getSoapAction());

            } else {

                if (messageIn.isSOAP11()) {
                    options.setProperty(Constants.Configuration.DISABLE_SOAP_ACTION, true);
                } else {
                    Axis2MessageContext axis2smc = (Axis2MessageContext) messageOut;
                    org.apache.axis2.context.MessageContext axis2MessageCtx =
                            axis2smc.getAxis2MessageContext();
                    axis2MessageCtx.getTransportOut().addParameter(
                            new Parameter(HTTPConstants.OMIT_SOAP_12_ACTION, true));
                }

            }

           //After setting all the options we need to find the MEP of the Message
           org.apache.axis2.context.MessageContext axis2Ctx =
                   ((Axis2MessageContext)messageOut).getAxis2MessageContext();

           boolean outOnlyMessage = "true".equals(messageIn.getProperty(
                SynapseConstants.OUT_ONLY)) || WSDL2Constants.MEP_URI_IN_ONLY.equals(
                axis2Ctx.getOperationContext()
                        .getAxisOperation().getMessageExchangePattern());

            // Here We consider all other Messages that evaluates to outOnlyMessage == false
            // follows out in mep.
            if(log.isDebugEnabled()) {
                log.debug("Invoking service Url " + serviceUrl + " with Message" +
                        messageIn.getMessageID());
            }





            options.setProperty(
                    AddressingConstants.DISABLE_ADDRESSING_FOR_OUT_MESSAGES, Boolean.TRUE);

            //clean existing headers
            // otherwise when retrying same header element will add multiple times
            sc.removeHeaders();
View Full Code Here

     * @return cloned Options object
     */
    public static Options cloneOptions(Options options) {

        // create new options object and set the parent
        Options clonedOptions = new Options(options.getParent());

        // copy general options
        clonedOptions.setCallTransportCleanup(options.isCallTransportCleanup());
        clonedOptions.setExceptionToBeThrownOnSOAPFault(options.isExceptionToBeThrownOnSOAPFault());
        clonedOptions.setManageSession(options.isManageSession());
        clonedOptions.setSoapVersionURI(options.getSoapVersionURI());
        clonedOptions.setTimeOutInMilliSeconds(options.getTimeOutInMilliSeconds());
        clonedOptions.setUseSeparateListener(options.isUseSeparateListener());

        // copy transport related options
        clonedOptions.setListener(options.getListener());
        clonedOptions.setTransportIn(options.getTransportIn());
        clonedOptions.setTransportInProtocol(options.getTransportInProtocol());
        clonedOptions.setTransportOut(clonedOptions.getTransportOut());

        // copy username and password options
        clonedOptions.setUserName(options.getUserName());
        clonedOptions.setPassword(options.getPassword());

        // cloen the property set of the current options object
        for (Object o : options.getProperties().keySet()) {
            String key = (String) o;
            clonedOptions.setProperty(key, options.getProperty(key));
        }

        return clonedOptions;
    }
View Full Code Here

         try {
            configurationContext
                    = ConfigurationContextFactory.createConfigurationContextFromFileSystem(
                    clientRepository != null ? clientRepository : DEFAULT_CLIENT_REPO,
                    axis2xml != null ? axis2xml : DEFAULT_AXIS2_XML);
            sc = new ServiceClient(configurationContext, null);
        } catch (AxisFault e) {
            String msg = "Error initializing BlockingMessageSender : " + e.getMessage();
            log.error(msg, e);
            throw new SynapseException(msg, e);
        }
View Full Code Here

  public static void main(String[] args) throws AxisFault,IOException {

    System.out.println ("\nTHIS IS A SAMPLE APPLICATION TO DEMONSTRATE THE FUNCTIONALITY OF SERVICE GROUPS");
    System.out.println ("===============================================================================");
    Call call = new Call();
    call.setTransportInfo(Constants.TRANSPORT_HTTP,
        Constants.TRANSPORT_HTTP, false);
   
   
    boolean exit = false;
    String serviceGroupContextId = null;
    while (!exit) {
      BufferedReader reader = new BufferedReader (new InputStreamReader (System.in));

      System.out.print ("\n\nNew round (n) /continue round (c).../exit (e)");
      String option = reader.readLine();
      if ("e".equalsIgnoreCase(option)){
        System.out.println ("Exiting calculator...");
        return;
      }
     
      if (!"n".equalsIgnoreCase(option) && !"c".equalsIgnoreCase(option)){
        System.out.println ("Error: Invalid option");
        continue;
      }
     
      System.out.print ("Please Select the service ( '+' / '-' / '*' )....");
      String operation = reader.readLine();
      if (!"+".equalsIgnoreCase(operation) && !"-".equalsIgnoreCase(operation) && !"*".equalsIgnoreCase(operation)){
        System.out.println ("Error: Invalid option");
        continue;
      }
     
      if ("+".equals(operation))
        call.setTo(new EndpointReference (addService));
      else if ("-".equals(operation))
        call.setTo(new EndpointReference (substractService));
      else if ("*".equals(operation))
        call.setTo(new EndpointReference (multiplyService));
     
      if ("n".equalsIgnoreCase(option)){
        System.out.print ("Enter parameter 1...");
        String param1Str = reader.readLine();
        System.out.print ("Enter parameter 2...");
        String param2Str = reader.readLine();
        int param1 = Integer.parseInt(param1Str);
        int param2 = Integer.parseInt(param2Str);
       
        String opStr = null;
        if ("+".equals(operation)){
          opStr = "add";
        }else if ("-".equals(operation)){
          opStr = "substract";
        }else if ("*".equals(operation)){
          opStr = "multiply";
        }
        System.out.println("Invoking...");
        SOAPEnvelope result = call.invokeBlocking(opStr,getRequestEnvelope(opStr,param1,param2,
            serviceGroupContextId));
        printResult(result);
       
        if (serviceGroupContextId==null)
          serviceGroupContextId = getServiceGroupContextId(result);
       
       
      }else if ("c".equalsIgnoreCase(option)){
        if (serviceGroupContextId==null)
        {
          System.out.println ("Error: First operation must be a New one. Please select 'n'");
          continue;
        }
       
        System.out.print ("Enter parameter...");
        String paramStr = reader.readLine();
        int param = Integer.parseInt(paramStr);
        String opStr = null;
        if ("+".equals(operation)){
          opStr = "addPrevious";
        }else if ("-".equals(operation)){
          opStr = "substractPrevious";
        }else if ("*".equals(operation)){
          opStr = "multiplyPrevious";
        }
       
        System.out.println("Invoking...");
        SOAPEnvelope result = call.invokeBlocking(opStr,getPreviousRequestEnvelope(opStr,param,
            serviceGroupContextId));
        printResult(result);
       
      }
     
View Full Code Here

TOP

Related Classes of org.apache.axis2.clientapi.Call

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.