Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
File 无法使用MTOM和Axis2存根从webservice下载文件_File_Axis2_Transfer_Mtom_Axiom - Fatal编程技术网

File 无法使用MTOM和Axis2存根从webservice下载文件

File 无法使用MTOM和Axis2存根从webservice下载文件,file,axis2,transfer,mtom,axiom,File,Axis2,Transfer,Mtom,Axiom,我正在尝试使用MTOM和ADB从Axis2 Web服务服务器下载一个文件。 如果在服务器端和客户端都不启用MTOM,我可以下载该文件。任何建议或代码示例都很好:) 客户端 ServerWSStub stub = new ServerWSStub(); stub._getServiceClient().getOptions().setProperty(Constants.Configuration.ENABLE_MTOM,Constants.VALUE_TRUE); 服务器端axis2.xml

我正在尝试使用MTOM和ADB从Axis2 Web服务服务器下载一个文件。 如果在服务器端和客户端都不启用MTOM,我可以下载该文件。任何建议或代码示例都很好:)

客户端

ServerWSStub stub = new ServerWSStub();
stub._getServiceClient().getOptions().setProperty(Constants.Configuration.ENABLE_MTOM,Constants.VALUE_TRUE);
服务器端axis2.xml

<parameter name="enableMTOM">optional</parameter>
这是我的客户

ServerWSStub stub = new ServerWSStub();          

//stub._getServiceClient().getOptions().setProperty(Constants.Configuration.ENABLE_MTOM,Constants.VALUE_TRUE); 

//when uncommented i get java.lang.NoClassDefFoundError: org/apache/james/mime4j/MimeException 
//while trying to invoke _operationClient.execute(true); in ServerWSStub 
//I guess it is because of wrong unparsing


Download download = new Download();
download.setKonum(konum);
try {
    DownloadResponse downloadResponse = stub.download(download);
    DataHandler dh =(DataHandler) downloadResponse.get_return();
    File file = new File("C:/dosya/"+fileNameType);

    if (!file.getParentFile().exists())
        file.getParentFile().mkdirs();
    if(!file.exists()){
        file.createNewFile();
    }
    FileOutputStream fileOutputStream = new FileOutputStream(file);

    dh.writeTo(fileOutputStream);
    fileOutputStream.flush();
    fileOutputStream.close();
} catch (ServerWSExceptionException e) {
    e.printStackTrace();
}

我想我终于找到了解决办法。流在客户端获取整个文件之前关闭,这就是为什么我首先使用getOptions().settimeoutinmillizes(10000)方法,但它也没用,然后在我注释的存根文件中

_messageContext.getTransportOut().getSender().cleanup(_messageContext);//look for the method's finally part
这样,在大文件传输过程中,流没有被关闭,我可以下载整个文件,没有任何愚蠢的例外:)

--mimebundary\u e56e8a77b94fbdd7678582aa5ca53f50b1d56c0d828499ea
内容类型:应用程序/xop+xml;字符集=UTF-8;type=“text/xml”
内容传输编码:二进制
内容ID:
--MIMEBORDING——e56e8a77b94fbdd7678582aa5ca53f50b1d56c0d828499ea
内容类型:文本/纯文本
内容传输编码:二进制
内容ID:
这里是二进制代码
只需将apache-mime4j-core-0.7.2.jar添加到服务(服务器)端的WEB-INF/lib中即可。可以找到这个罐子

_messageContext.getTransportOut().getSender().cleanup(_messageContext);//look for the method's finally part
--MIMEBoundary_e56e8a77b94fbdd7678582aa5ca53f50b1d56c0d828499ea
Content-Type: application/xop+xml; charset=UTF-8; type="text/xml"
Content-Transfer-Encoding: binary
Content-ID: <0.146e8a77b94fbdd7678582aa5ca53f50b1d56c0d828499ea@apache.org>

<?xml version='1.0' encoding='UTF-8'?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><ns:downloadResponse xmlns:ns="http://servis.ws.projem.tez.benim"><ns:return><xop:Include xmlns:xop="http://www.w3.org/2004/08/xop/include" href="cid:1.046e8a77b94fbdd7678582aa5ca53f50b1d56c0d828499ea@apache.org" /></ns:return></ns:downloadResponse></soapenv:Body></soapenv:Envelope>
--MIMEBoundary_e56e8a77b94fbdd7678582aa5ca53f50b1d56c0d828499ea
Content-Type: text/plain
Content-Transfer-Encoding: binary
Content-ID: <1.046e8a77b94fbdd7678582aa5ca53f50b1d56c0d828499ea@apache.org>
binary code here