Examples of MTOMSampleMTOMSampleSOAP11Port_httpStub


Examples of org.apache.ws.axis2.mtomsample.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
    MTOMSampleMTOMSampleSOAP11Port_httpStub.AttachmentRequest attachmentRequest = new MTOMSampleMTOMSampleSOAP11Port_httpStub.AttachmentRequest();
    MTOMSampleMTOMSampleSOAP11Port_httpStub.AttachmentType attachmentType = new MTOMSampleMTOMSampleSOAP11Port_httpStub.AttachmentType();
    MTOMSampleMTOMSampleSOAP11Port_httpStub.Base64Binary base64Binary = new MTOMSampleMTOMSampleSOAP11Port_httpStub.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);
        MTOMSampleMTOMSampleSOAP11Port_httpStub.ContentType_type0 param = new MTOMSampleMTOMSampleSOAP11Port_httpStub.ContentType_type0();
        param.setContentType_type0(dataHandler.getContentType());
        base64Binary.setContentType(param);
    attachmentType.setBinaryData(base64Binary);
    attachmentType.setFileName(destination);
    attachmentRequest.setAttachmentRequest(attachmentType);

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

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
Copyright © 2018 www.massapi.com. 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.