Nullpointer异常soapui文件上传调用

时间:2015-09-30 09:17:08

标签: java rest soapui

我必须使用soap ui上传文件.Below是我的服务代码。如果使用jersey调用它会执行正常。但是当我尝试使用soapui null指针调用异常时会发生。

我在soap ui中调用fileupload服务,如下所示

创建休息项目: 添加网址:

http://localhost:8080/FileService/Services/HomeService/testupload
file file:c:\\1.wav





 @POST
            @Path("testupload")
            @Consumes(MediaType.MULTIPART_FORM_DATA)
            @Produces(MediaType.TEXT_PLAIN)
            public String uploadFile(@FormDataParam("file") InputStream fis,
                            @FormDataParam("file") FormDataContentDisposition fdcd) {

                OutputStream outpuStream = null;
                String fileName = fdcd.getFileName();

                String filePath = FOLDER_PATH + fileName;

                try {
                    int read = 0;
                    byte[] bytes = new byte[1024];
                    outpuStream = new FileOutputStream(new File(filePath));
                    while ((read = fis.read(bytes)) != -1) {
                        outpuStream.write(bytes, 0, read);
                    }
                    outpuStream.flush();
                    outpuStream.close();
                } catch(IOException iox){
                    iox.printStackTrace();
                } finally {
                    if(outpuStream != null){
                        try{outpuStream.close();} catch(Exception ex){}
                    }
                }
                return "File Upload Successfully !!";
            }

如何解决此问题?任何帮助将不胜感激!!!

0 个答案:

没有答案