`
tenn
  • 浏览: 565278 次
  • 性别: Icon_minigender_1
  • 来自: 苏州
文章分类
社区版块
存档分类
最新评论

easylink webservice(FaxService) test

阅读更多
mstsc.exe
java 代码
  1. package com.easylink.services.sample;   
  2.   
  3. import java.io.File;   
  4.   
  5. import testpackage.SendFaxResponse;   
  6.   
  7. import com.easylink.services.ELSException;   
  8. import com.easylink.services.ELSFaxManager_test;   
  9.   
  10. /**  
  11.  * SendFax - Send a fax to the specified destination fax  
  12.  * @author zhu jiyun  
  13.  * @version 1.0  
  14.  */  
  15. public class SendFax_test {   
  16.   
  17.    public static void main(String[] args) throws Exception {   
  18.   
  19.       try {   
  20.          /**  
  21.           * the required variable with '*';   
  22.           */  
  23.   
  24.          /**  
  25.           * Host*  
  26.           * Secured production fax endpoint:faxadmin.easylink.com  
  27.           */  
  28.          String host = "webservicetest.easylink.com"//Test system secured fax endpoint   
  29.   
  30.          /**  
  31.           * port*  
  32.           * The port of the destination service. ie 443 unless using a proxy  
  33.           */  
  34.          String port = "443";   
  35.   
  36.          /**  
  37.           * email*  
  38.           * The email address of the registered account  
  39.           */  
  40.          String emailAddress = "tenn911@163.com";   
  41.   
  42.          /**  
  43.           * password*  
  44.           * Password for the registered account  
  45.           */  
  46.          String password = "password";   
  47.   
  48.          /**  
  49.           * destination*  
  50.           * Destination fax number  
  51.           */  
  52.          String destination = "8641139778161";   
  53.             
  54.          //trustStorePath*   
  55.          String trustStorePath = "c:\\testEasyLink\\easysendfax.keystore";            
  56.   
  57.          // AcctCode   
  58.          String accountCode = "";   
  59.   
  60.          // UserCode   
  61.          String userCode = "";   
  62.   
  63.          // TSI - Fax Machine Identification String   
  64.          String TSI = "";   
  65.   
  66.          // alternateDeliveryNotice - Delivery Notification EMAIL   
  67.          String alternateDeliveryNotice = "";   
  68.   
  69.          String deliveryNoticeType = "ALL";   
  70.          String faxResolution = "Normal";   
  71.   
  72.          // to - Value for the TO field   
  73.          String to = "";   
  74.   
  75.          String from = emailAddress;   
  76.   
  77.          //Setup the attachments*   
  78.          String filePath = "c:\\testEasyLink\\testEasyLink.txt";         
  79.          File[] attachments = getAttachments(filePath);   
  80.   
  81.          ELSFaxManager_test efm = new ELSFaxManager_test();   
  82.          efm.setHost(host);   
  83.          efm.setPort(Integer.parseInt(port));   
  84.          efm.setEmailAddress(emailAddress);   
  85.          efm.setPassword(password);   
  86.             
  87. //       Run in secured mode   
  88.          efm.setSecured(true);   
  89.          efm.setTrustStoreName(trustStorePath);   
  90.   
  91.          SendFaxResponse rs = efm.sendFax(destination,   
  92.                                           accountCode,   
  93.                                           userCode,   
  94.                                           TSI,   
  95.                                           alternateDeliveryNotice,   
  96.                                           deliveryNoticeType,   
  97.                                           faxResolution,   
  98.                                           to,   
  99.                                           from,   
  100.                                           attachments);   
  101.   
  102.          System.out.println("Transaction Id  : " + rs.getTransactionId());   
  103.       } catch (ELSException e) {   
  104.          System.out.println("Exception message "+e.getMessage());   
  105.          e.printStackTrace();   
  106.       }   
  107.   
  108.    }   
  109.   
  110.    private static File[] getAttachments(String filePath) {   
  111.   
  112.          String[] filePaths = filePath.split(";");   
  113.          File[] files = new File[filePaths.length];   
  114.          int cntr=0;   
  115.          for(int i=0;i
  116.             String fPath = filePaths[i];   
  117.             files[cntr++] = new File(fPath);   
  118.          }        
  119.          return files;   
  120.    }   
  121.   
  122.   
  123. }   
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics