Filenet 5.2.1 GetContent WebService返回文件不完整问题求助
Filenet 5.2.1 GetContent WebService 大文件返回不完整问题
我正在使用Filenet 5.2.1的SOAP WebService GetContent服务,对应的WSDL地址为:
http://myserver:9080/wsi/FNCEWS40MTOM.wsdl
当尝试获取大于1MB的文件内容时,返回的响应通过base64格式读取只能得到文件的一部分,而非完整文件。
我的请求内容如下:
<soapenv:Envelope xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <soapenv:Header> <Security xmlns="http://schemas.xmlsoap.org/ws/2002/12/secext"> <hd:UsernameToken xmlns:hd="http://schemas.xmlsoap.org/ws/2002/12/secext"> <hd:Username>myusername</hd:Username> <hd:Password>mypassword</hd:Password> </hd:UsernameToken> </Security> </soapenv:Header> <soapenv:Body> <p857:GetContentRequest validateOnly="0" xmlns:p857="http://www.filenet.com/ns/fnce/2006/11/ws/schema"> <p857:ContentRequest cacheAllowed="1" id="1" startOffset="0"> <p857:SourceSpecification classId="Document" itemIndex="0" objectId="{E408981D-FF67-4D91-B7A9-CEBEC4630AB0}" objectStore="myobjectstore" serializationDuplicate="0" xsi:type="p857:ObjectSpecification"/> <p857:ElementSpecification elementSequenceNumber="0" itemIndex="0"/> </p857:ContentRequest> </p857:GetContentRequest> </soapenv:Body> </soapenv:Envelope>
响应内容:
--A-B--MIME-BOUNDARY--27d99311536fa8c4-18606176189--Y-Z Content-Transfer-Encoding: binary Content-Type: application/xop+xml; type="application/soap+xml"; charset=UTF-8 Content-ID: <v0-27d99311536fa8c4-18606176189@mtom.p8ce.filenet.com> <?xml version="1.0" encoding="UTF-8"?> <e:Envelope xmlns:d="http://www.w3.org/2001/XMLSchema" xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns:fn35="http://www.filenet.com/ns/fnce/2005/02/ws/schema" xmlns:fn40m="http://www.filenet.com/ns/fnce/2006/11/ws/MTOM/schema" xmlns:fn40="http://www.filenet.com/ns/fnce/2006/11/ws/schema" xmlns:xop="http://www.w3.org/2004/08/xop/include" xmlns:e="http://schemas.xmlsoap.org/soap/envelope/"> <e:Body> <GetContentResponse xmlns="http://www.filenet.com/ns/fnce/2006/11/ws/schema"> <ContentResponse id="1" i:type="fn40:ContentElementResponse" retrievalName="test.pdf" totalSize="4586622" bufferedSize="1048576" continueFrom="offset=1048576;id={B3795692-DA06-468C-AEC9-523A3715455D};"> <SourceSpecification i:type="fn40:ObjectReference" classId="Document" objectId="{E408981D-FF67-4D91-B7A9-CEBEC4630AB0}" objectStore="MCIDEV"></SourceSpecification> <ElementSpecification elementSequenceNumber="0"></ElementSpecification> <Content i:type="fn40:InlineContent"> <Binary> <xop:Include href="cid:v1-27d99311536fa8c4-18606176189@mtom.p8ce.filenet.com"></xop:Include> </Binary> </Content> </ContentResponse> </GetContentResponse> </e:Body> </e:Envelope> --A-B--MIME-BOUNDARY--27d99311536fa8c4-18606176189--Y-Z Content-Transfer-Encoding: binary Content-Type: application/octet-stream Content-Id: <v1-27d99311536fa8c4-18606176189@mtom.p8ce.filenet.com> %PDF-1.4 ...... ...... ...... --A-B--MIME-BOUNDARY--27d99311536fa8c4-18606176189--Y-Z--
问题原因及解决方法
这是Filenet WebService的分块传输机制导致的:当文件大小超过默认1MB阈值时,服务会分批次返回内容。响应中的continueFrom字段包含下一次请求所需参数:offset=1048576;id={B3795692-DA06-468C-AEC9-523A3715455D};,其中offset是下一次请求的起始位置,id是本次会话标识。
解决步骤:
- 解析响应中的
totalSize(文件总大小)、bufferedSize(本次返回大小)和continueFrom参数 - 构建新的
GetContentRequest,将startOffset设为continueFrom中的offset值,并在ContentRequest节点添加continueFrom属性 - 循环发送请求,直到累计获取的大小等于
totalSize - 拼接每次返回的二进制内容,得到完整文件
内容的提问来源于stack exchange,提问作者Mahmoud Saleh
相关产品推荐
相关产品推荐

