Package sample.mtom.service

Examples of sample.mtom.service.MTOMSampleMTOMSampleSOAP11Port_httpStub


  public static void transferFile(File file, String destination)
      throws RemoteException {
    // uncomment the following if you need to capture the messages from
    // TCPMON. Please look at http://ws.apache.org/commons/tcpmon/tcpmontutorial.html
    // to learn how to setup tcpmon
    MTOMSampleMTOMSampleSOAP11Port_httpStub serviceStub = new MTOMSampleMTOMSampleSOAP11Port_httpStub(
        //"http://localhost:8081/axis2/rest/MTOMSample"
    );

    // Enable MTOM in the client side
    serviceStub._getServiceClient().getOptions().setProperty(
        Constants.Configuration.ENABLE_MTOM, Constants.VALUE_TRUE);
    //Increase the time out when sending large attachments
    serviceStub._getServiceClient().getOptions().setTimeOutInMilliSeconds(10000);

    // Uncomment and fill the following if you want to have client side file
    // caching switched ON.
    /*
     * serviceStub._getServiceClient().getOptions().setProperty(
     * Constants.Configuration.CACHE_ATTACHMENTS, Constants.VALUE_TRUE);
     * serviceStub._getServiceClient().getOptions().setProperty(
     * Constants.Configuration.ATTACHMENT_TEMP_DIR, "your temp dir");
     * serviceStub._getServiceClient().getOptions().setProperty(
     * Constants.Configuration.FILE_SIZE_THRESHOLD, "4000");
     */

    // Populating the code generated beans
    AttachmentRequest attachmentRequest = new AttachmentRequest();
    AttachmentType attachmentType = new AttachmentType();
    Base64Binary base64Binary = new Base64Binary();

    // Creating a javax.activation.FileDataSource from the input file.
    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);
    base64Binary.setBase64Binary(dataHandler);
    base64Binary.setContentType(dataHandler.getContentType());
    attachmentType.setBinaryData(base64Binary);
    attachmentType.setFileName(destination);
    attachmentRequest.setAttachmentRequest(attachmentType);

    AttachmentResponse response = serviceStub.attachment(attachmentRequest);
    System.out.println(response.getAttachmentResponse());
  }
View Full Code Here

TOP

Related Classes of sample.mtom.service.MTOMSampleMTOMSampleSOAP11Port_httpStub

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.