package testUpload;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.net.MalformedURLException;
import java.rmi.RemoteException;
import javax.xml.namespace.QName;
import javax.xml.rpc.ServiceException;
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import org.apache.axis.message.SOAPHeaderElement;
import sun.misc.BASE64Decoder;
import _1._0._0._127.ormrpc.services.EASLogin.EASLoginProxyProxy;
import _1._0._0._127.ormrpc.services.WSBanktransactionFacade.WSBanktransactionFacadeSrvProxyProxy;
import _1._0._0._127.ormrpc.services.WSSaleDonwoladFacade.WSSaleDonwoladFacadeSrvProxyServiceLocator;
import _1._0._0._127.ormrpc.services.WSSaleattachFileFacade.WSSaleattachFileFacadeSrvProxyServiceLocator;
import client.WSContext;
import mytest.FileOuttest;
public class testUpload {
public static void main(String[] args) throws ServiceException, IOException {
//调用登陆接口
Service s=new Service();
Call call=(Call)s.createCall();
call.setOperationName("login");
call.setTargetEndpointAddress("http://127.0.0.1:56898/ormrpc/services/EASLogin?wsdl");
call.setReturnType(new QName("urn:client","WSContext"));
call.setReturnClass(WSContext.class);
call.setReturnQName(new QName("","loginReturn"));
//超时
call.setTimeout(Integer.valueOf(1000*600000*60));
call.setMaintainSession(true);
//登陆接口参数
WSContext rs=(WSContext)call.invoke(new Object[]{"user", "kduser", "eas", "test", "l2", Integer.valueOf(2)});
System.out.println(rs.getSessionId());
System.out.println(rs.getUserName());
//清理
call.clearOperation();
//调用业务接口
call.setOperationName("fileUpload");
call.setTargetEndpointAddress("http://127.0.0.1:56898/ormrpc/services/WSSaleattachFileFacade");
//call.setReturnType(new QName("urn:lang.java","String"));
//call.setReturnClass(String.class);
call.setReturnQName(new QName("","fileUploadReturn"));
call.setTimeout(Integer.valueOf(1000*600000*60));
call.setMaintainSession(true);
SOAPHeaderElement header=new SOAPHeaderElement("http://login.webservice.bos.kingdee.com","SessionId", rs.getSessionId());
call.addHeader(header);
//接口参数
// String aa=(String)call.invoke(new Object[]{"user", "kduser"} );
FileOuttest fileOuttest = new FileOuttest();
call.invoke(new Object[]{"DY72Vrm5SSWx7JjwuuGkLin1XqY=",fileOuttest.file2Str("C:\\Users\\mz\\Desktop\\44.doc"), "44", "doc"} );
// try {
//登录接口
// EASLoginProxyProxy proxy = new EASLoginProxyProxy();
// WSContext ctx = proxy.login("user", "kduser", "eas", "test", "l2", 2);
// System.out.println(ctx.getSessionId());
// System.out.println(ctx.getUserName());
// boolean saleContractSubmit = locator2.getWSSaleContractSubmitFacade().saleContractSubmit("8uQQtd70TaWYd8woQy5F6Sn1XqY=");
// FileOuttest fileOuttest = new FileOuttest();
// java.lang.Thread.currentThread().getContextClassLoader().getResource("com/kingdee/eas/base/param/util/ParamManager.class");
// boolean saleContractSubmit = locator2.getWSSaleContractSubmitFacade().saleContractSubmit(fileOuttest.file2Str("C:\\Users\\mz\\Desktop\\西安必康开发项目12-20.zip"));
//获取销售合同内码
//WSSaleContractSrvProxyProxy proxy2 = new WSSaleContractSrvProxyProxy();
// WSSaleattachFileFacadeSrvProxyServiceLocator locator = new WSSaleattachFileFacadeSrvProxyServiceLocator();
// locator.getWSSaleattachFileFacade().fileUpload("DY72Vrm5SSWx7JjwuuGkLin1XqY=", fileOuttest.file2Str("C:\\Users\\mz\\Desktop\\44.txt"), "44", "txt");
// locator.submit(fileOuttest.file2Str("C:\\Users\\mz\\Desktop\\33.pdf"));//系统标准的提交接口
/* WSSaleDonwoladFacadeSrvProxyServiceLocator locator = new WSSaleDonwoladFacadeSrvProxyServiceLocator();
String attachmentIds = locator.getWSSaleDonwoladFacade().getAttachmentIds("8uQQtd70TaWYd8woQy5F6Sn1XqY=");
System.out.println(attachmentIds); //得到附件id 名字 类型 大小
String attachment = locator.getWSSaleDonwoladFacade().getAttachment("pfnLMCHZSfaLkvWOfDlrkfSvTwM=");//加码后的字节字符串
System.out.println(attachment.toString());
BASE64Decoder Base64 = new BASE64Decoder();
// try {
// Base64解码
byte[] b = Base64.decodeBuffer(attachment);
for (int i = 0; i < b.length; ++i) {
if (b[i] < 0) {// 调整异常数据
b[i] += 256;
}
}
// "C:\\Users\\mz\\Desktop\\新建文件夹\\"+fileName+"."+fileType
// 生成文件,并保存在服务器硬盘上 /root/kingdee/eas/attach/ 自己在服务器上建个attach目录 这样是在eas服务器上测试,在自己bos上测试,目录要换,参数要换成db
OutputStream out = new FileOutputStream( "C:\\Users\\mz\\Desktop\\新建文件夹\\mz.xlsx");
out.write(b);
out.flush();
out.close();
} catch (RemoteException e) {
e.printStackTrace();
} */
// WSBanktransactionFacadeSrvProxyProxy proxy2 = new WSBanktransactionFacadeSrvProxyProxy();
// String bankaccounts = proxy2.getBankaccounts();
// String banktransactions = proxy2.getBanktransactions("", "2018-01-01", "2019-03-03");
// System.out.println(bankaccounts);
// System.out.println(banktransactions);
}
}