简体   繁体   English

使用Axis2 1.7.4从Java客户端发送文件

[英]Send file using Axis2 1.7.4 from java client

I want to send a file using Axis2 1.7.4 to this endpoint https://cel.sri.gob.ec/comprobantes-electronicos-ws/RecepcionComprobantes?wsdl 我想使用Axis2 1.7.4发送文件到此端点https://cel.sri.gob.ec/comprobantes-electronicos-ws/RecepcionComprobantes?wsdl

Part of this code look like this: 此代码的一部分如下所示:

OMFactory factory = OMAbstractFactory.getOMFactory();
OMNamespace ns = factory.createOMNamespace("http://ec.gob.sri.ws.recepcion", "RecepcionComprobantesService");
   OMElement validarComprobante = factory.createOMElement("validarComprobante", ns);        
    ConfigurableDataHandler dataHandler = new ConfigurableDataHandler(new FileDataSource("file.xml"));
    dataHandler.setTransferEncoding("UTF-8");
    dataHandler.setContentType("txt/xml");
    OMText textData = factory.createOMText(dataHandler, false);       
    validarComprobante.addChild(textData);
    ...
       ServiceClient client = new ServiceClient();
    ...
        OMElement response = client.sendReceive(validarComprobante);

I have a response from the server but the file is not accepted, because i get this message"FILES SUBMITTED DO NOT MEET THE SPECIFICATIONS ESTABLISHED: EXTENSION, CODIFICATION" 我收到服务器的答复,但文件不被接受,因为我收到此消息“提交的文件不符合已建立的规格:扩展名,编码名”

I read the documentation and the file is sent as Base64 encoded string, so i think that is the problem the content of the file is serialized and i dont know if is possible resolve that. 我阅读了文档,文件以Base64编码的字符串形式发送,所以我认为这是文件内容被序列化的问题,我不知道是否有可能解决该问题。

As per the WSDL description soap request body xml tag expecting base64 encoded string. 根据WSDL描述,soap请求主体xml标签期望使用base64编码的字符串。 So you have to read the file content,convert into base64 encoded string and try to pass that string value to xml tag. 因此,您必须阅读文件内容,转换为base64编码的字符串,然后尝试将该字符串值传递给xml标记。

You SOAP request should be similar to this 您的SOAP请求应与此类似

    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ec="http://ec.gob.sri.ws.recepcion">
       <soapenv:Header/>
       <soapenv:Body>
          <ec:validarComprobante>
             <!--Optional:-->
             <xml>VGhpcyBpcyB0ZXN0IGRvY3VtZW50</xml>
          </ec:validarComprobante>
       </soapenv:Body>
    </soapenv:Envelope>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM