FileDocCategorySizeDatePackage
Tester.javaAPI DocApache Axis 1.43892Sat Apr 22 18:56:52 BST 2006samples.swa

Tester

public class Tester extends Object
Class Tester
version
%I%, %G%

Fields Summary
public static final String
HEADER_CONTENT_TYPE
Field HEADER_CONTENT_TYPE
public static final String
HEADER_CONTENT_TRANSFER_ENCODING
Field HEADER_CONTENT_TRANSFER_ENCODING
private static final String
address
Field address
Constructors Summary
Methods Summary
private static voidaddBodyPart(javax.mail.internet.MimeMultipart mp, javax.activation.DataHandler dh)
Method addBodyPart

param
mp
param
dh

        MimeBodyPart messageBodyPart = new MimeBodyPart();
        try {
            messageBodyPart.setDataHandler(dh);
            String contentType = dh.getContentType();
            if ((contentType == null) || (contentType.trim().length() == 0)) {
                contentType = "application/octet-stream";
            }
            System.out.println("Content type: " + contentType);
            messageBodyPart.setHeader(HEADER_CONTENT_TYPE, contentType);
            messageBodyPart.setHeader(
                    HEADER_CONTENT_TRANSFER_ENCODING,
                    "binary");    // Safe and fastest for anything other than mail
            mp.addBodyPart(messageBodyPart);
        } catch (javax.mail.MessagingException e) {
        }
    
public static voidmain(java.lang.String[] args)
Method main

param
args
throws
Exception


                  
           

        /*
         * Start to prepare service call. Once this is done, several
         * calls can be made on the port (see below)
         *
         * Fist: get the service locator. This implements the functionality
         * to get a client stub (aka port).
         */
        SwaServiceLocator service = new SwaServiceLocator();

        /*
         * Here we use an Axis specific call that allows to override the
         * port address (service endpoint address) with an own URL. Comes
         * in handy for testing.
         */
        java.net.URL endpoint;
        try {
            endpoint = new java.net.URL(address);
        } catch (java.net.MalformedURLException e) {
            throw new javax.xml.rpc.ServiceException(e);
        }

        SwaPort port = (SwaPort) service.getSwaHttp(endpoint);

        /*
         * At this point all preparations are done. Using the port we can
         * now perform as many calls as necessary.
         */

        /*
         * Prepare the Multipart attachment. It consists of several data files. The
         * multipart container is of type "multipart/mixed"
         */
        MimeMultipart mpRoot = new MimeMultipart();
        System.out.println("MimeMultipart content: " + mpRoot.getContentType());
        DataHandler dh = new DataHandler(new FileDataSource("duke.gif"));
        addBodyPart(mpRoot, dh);
        dh = new DataHandler(new FileDataSource("pivots.jpg"));
        addBodyPart(mpRoot, dh);
        // perform call
        port.swaSend("AppName", mpRoot);