axis2系列之傳輸複雜型別的資料
阿新 • • 發佈:2019-01-10
public static void main(String[] args) { RPCServiceClient client = null; try { client = new RPCServiceClient(); Options options = client.getOptions(); EndpointReference targetEPR = new EndpointReference("http://localhost:8080/myservice/services/binaryFileService"); options.setTo(targetEPR); //呼叫uploadWithByte方法 String srcFilePath = "d:\\pxt.jpg"; String targetFilePath1 = "d:\\test2.jpg"; String targetFilePath2 = "d:\\test3.jpg"; File file = new File(srcFilePath); FileInputStream fis = new FileInputStream(file); byte[] buffer = new byte[(int) file.length()]; fis.read(buffer); fis.close(); //qName //byte[]方式 QName qName = new QName("http://service.binaryFile.test.com","uploadWithByte"); Object[] oArgs = new Object[]{buffer,targetFilePath1}; Class[] cRtnType = new Class[]{Boolean.class}; Boolean isUpload = (Boolean) client.invokeBlocking(qName, oArgs, cRtnType)[0]; System.out.println(isUpload); //DataHandler方式 DataHandler handler = new DataHandler(new FileDataSource(srcFilePath)); qName = new QName("http://service.binaryFile.test.com","uploadWithDataHandler"); oArgs = new Object[]{handler,targetFilePath2}; cRtnType = new Class[]{Boolean.class}; isUpload = (Boolean) client.invokeBlocking(qName, oArgs, cRtnType)[0]; System.out.println(isUpload); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
(3)、集合