Axis2 and Webservices: File Upload

我只是一个虾纸丫 提交于 2019-12-06 14:18:40

It is actually simple: enable MTOM (but not SwA) and use DataHandler as the argument type.

mhan

Take a look here, but also would ask to think about using Servlet's doPost; as the thread suggests - Axis2 File Upload by chunk

If you have not seen this, then check this one too for details about the method you are using http://axis.apache.org/axis2/java/core/docs/mtom-guide.html

Andreas' advice was really helpful! I've tried passing an array of byte to the service, but i has some problems like the size of files on the server weren't of the same size of the files on the client..

With DataHandler i haven't such problems. I've enabled MTOM in Axis (\WEB-INF\conf\axis2.xml). My service operation signature was something like that:

public String importFile(String name, DataHandler dh);

And client side, after i've generated the client with WSDL2Java, i used the service as follows:

ImportServiceStub stub = new ImportServiceStub("http://localhost:8080/axis2/services/ImportModule");
ImportFile importFile = new ImportFile(); //operation name
DataSource fds = new FileDataSource(new File("FileName"));
importFile.setName("FileName");
importFile.setDh(new DataHandler(fds));
stub.importFile(importFile);

Thanks again for your support and your advices :)

Gokul

I could do this successfully when I generate stubs using wsdltojava but when I tried same using wsimport command I am receiving null parameter data at server side.

I am following below process.

  1. Wrote service side code using jax ws specification and mtom soap 11 binding @BindingType(value = SOAPBinding.SOAP11HTTP_MTOM_BINDING)
  2. Generate .aar file to upload it to axis2 server (axis1.6.2 & tomcat 6/7)
  3. Generate wsdl file from axis2 server just clicling on service name.
  4. Generated stubs using wsimport -keep -verbose wsdl url
  5. Test code with with mtom enable

     //Enable MTOM
     SOAPBinding binding = (SOAPBinding) bp.getBinding();
     binding.setMTOMEnabled(true);
    
  6. Result:- Passing i/p with Sting & byte but i/p received @ service method is null

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!