Package org.apache.axis.client

Examples of org.apache.axis.client.ServiceClient


        System.err.println( "Usage: GetInfo <symbol> <datatype>" );
        System.exit(1);
      }

      String  symbol = args[0] ;
      ServiceClient call = new ServiceClient
            (new HTTPTransport(opts.getURL(), "urn:cominfo"));

      call.set( Transport.USER, opts.getUser() );
      call.set( Transport.PASSWORD, opts.getPassword() );
      String res = (String) call.invoke(
        "urn:cominfo", "getInfo",
        new Object[] { args[0], args[1] } );
     
      System.out.println( symbol + ": " + res );
    }
View Full Code Here


      Debug.setDebugLevel( opts.isFlagSet( 'd' ) );

      args = opts.getRemainingArgs();
      if ( args != null ) action = args[0];

      ServiceClient client = new ServiceClient(new HTTPTransport());
      client.set(HTTPTransport.URL, url);
      client.set(HTTPTransport.ACTION, action);

      Message        reqMsg      = new Message( msg );
      Message        resMsg     = null ;

      System.out.println( "Request:\n" + msg );
       
      client.setRequestMessage( reqMsg );
      client.invoke();
      resMsg = client.getMessageContext().getResponseMessage();

      System.out.println( "Response:\n" + resMsg.getAsString() );
        return (String)resMsg.getAsString();
    }
View Full Code Here

    /**
     * Set up the call object.
     */
    public void setURL(String url) {
        call = new ServiceClient(url);
        map = call.getMessageContext().getTypeMappingRegistry();
    }
View Full Code Here

           
            Debug.setDebugLevel(options.isFlagSet('d'));
           
            String endpointURL = options.getURL();
           
            ServiceClient client = new ServiceClient(endpointURL);
           
            client.invoke("LogTestService", "testMethod", new Object [] {});
        } catch (Exception e) {
            System.err.println(e.toString());
        }
    }
View Full Code Here

            else {
                log( "Processing file: " + args[i] );
                input = new FileInputStream( args[i] );
            }
           
            ServiceClient client = new ServiceClient(opts.getURL());
           
            /** Unfortunately, this is transport-specific.  However, no one
            * but the HTTP transport should pick this property up.
            */
            client.set(HTTPConstants.MC_HTTP_SOAPACTION, "AdminService");
           
            Message         inMsg      = new Message( input, true );
           
            client.setRequestMessage( inMsg );
           
            client.set( Transport.USER, opts.getUser() );
            client.set( Transport.PASSWORD, opts.getPassword() );

            String tName = opts.isValueSet( 't' );
            if ( tName != null && !tName.equals("") )
                client.setTransportName( tName );
           
            client.invoke();
           
            Message outMsg = client.getMessageContext().
                                                        getResponseMessage();
            if (outMsg == null) {
                log("Null response message!");
                return null;
            }
           
            client
              .getMessageContext()
               .setServiceDescription(new ServiceDescription("Admin", false));
           
            input.close();
            SOAPEnvelope envelope =
                                   (SOAPEnvelope) outMsg.getAsSOAPEnvelope();
            SOAPBodyElement body = envelope.getFirstBody();
            StringWriter writer = new StringWriter();
            client.addOption(AxisEngine.PROP_XML_DECL, new Boolean(false));
            SerializationContext ctx = new SerializationContext(writer,
                                                  client.getMessageContext());
            body.output(ctx);
            sb.append(writer.toString());
            sb.append('\n');
        }
       
View Full Code Here

    static void main(String[] args) throws Exception {
        Options opts = new Options(args);
        Debug.setDebugLevel( opts.isFlagSet( 'd' ) );
        String action = opts.isValueSet('a');

        ServiceClient sc = new ServiceClient(opts.getURL());
        if (action != null) sc.set(HTTPTransport.ACTION, action);
 
        args = opts.getRemainingArgs();
        for (int i=0; i<args.length; i++) {
            FileInputStream stream = new FileInputStream(new File(args[i]));
            sc.setRequestMessage(new Message(stream));
   
            sc.invoke();
       
            MessageContext mc = sc.getMessageContext();
            System.out.println(mc.getResponseMessage().getAsString());
        }
    }
View Full Code Here

public class MD5AttachTest {
    static void main(String[] args) throws Exception {
        Options opts = new Options(args);
        String action = opts.isValueSet('a');

        ServiceClient sc = new ServiceClient(opts.getURL());
        //if (action != null) sc.set(HTTPTransport.ACTION, action);
        sc.set(HTTPTransport.ACTION, "");
 
            args = opts.getRemainingArgs();

           if(null == args || args.length != 1)  {
              System.err.println("Must specify file to send as an attachment!");
              System.exit(8);
            }

            //Create the attachment.
            javax.activation.DataHandler dh= new javax.activation.DataHandler( new javax.activation.FileDataSource( args[0] ));

            org.apache.axis.message.SOAPEnvelope env= new org.apache.axis.message.SOAPEnvelope();

            //Build the body elements.
            javax.xml.parsers.DocumentBuilderFactory dbf= javax.xml.parsers.DocumentBuilderFactory.newInstance();
            javax.xml.parsers.DocumentBuilder db= dbf.newDocumentBuilder();
            org.w3c.dom.Document doc= db.newDocument();
            org.w3c.dom.Element methodElement=   doc.createElementNS("foo", "foo:MD5Attach");
            org.w3c.dom.Element paramElement=   doc.createElementNS("foo", "foo:thefile");
            long startTime= System.currentTimeMillis();
            methodElement.appendChild(paramElement);
            paramElement.appendChild( doc.createTextNode(""+startTime));


            org.apache.axis.message.SOAPBodyElement sbe= new org.apache.axis.message.SOAPBodyElement( methodElement);
            env.addBodyElement(sbe);
           
            org.apache.axis.Message msg=  new org.apache.axis.Message(env);

            //Add the attachment content to the message.
            org.apache.axis.attachments.Attachments attachments= msg.getAttachments();
            org.apache.axis.Part attachmentPart= attachments.createAttachmentPart(dh);
            String href= attachmentPart.getContentId();
            //Have the parameter element set an href attribute to the attachment.
            paramElement.setAttribute(org.apache.axis.Constants.ATTR_HREF, href );
            env.clearBody();
            env.addBodyElement(sbe);

            msg.getSOAPPart().setSOAPEnvelope(env);

            sc.setRequestMessage(msg);
            //go on now....
            sc.invoke();
       
            MessageContext mc = sc.getMessageContext();
            // System.out.println(mc.getResponseMessage().getAsString());
           
            env =  mc.getResponseMessage().getSOAPPart().getAsSOAPEnvelope();
            sbe= env.getFirstBody();
            org.w3c.dom.Element sbElement= sbe.getAsDOM();
View Full Code Here

TOP

Related Classes of org.apache.axis.client.ServiceClient

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.