还有个问题,我后期这个东西是要部署到weblog 8.1上面的,会不会有问题呀

解决方案 »

  1.   

    用这个DataHandler客户端:
    DataHandler expectedDH;
    OMElement data = fac.createOMElement("upload", omNs);服务端方法名
    FileDataSource dataSource = new FileDataSource("要传的文件");
    expectedDH = new DataHandler(dataSource);
    OMText fileContent= fac.createOMText(expectedDH, true);
    data.addChild(fileContent);服务端:
     public OMElement upload(OMElement element) throws Exception {
      OMElement _fileContent = element;//文件内容
      OMText binaryNode = (OMText) _fileContent.getFirstOMChild();
      File uploadFile = new File("文件路径");
      DataHandler actualDH;
           actualDH = (DataHandler) binaryNode.getDataHandler();
           FileOutputStream imageOutStream = new FileOutputStream(uploadFile);
           InputStream is = actualDH.getInputStream();
           imageOutStream.write(IOUtils.getStreamAsByteArray(is));
    }