从soap响应字符串中提取PDF文件

时间:2014-07-30 17:36:05

标签: xml web-services soap xop

问题:从soap响应字符串中提取PDF文件。

描述:我有webservice返回的以下响应,并使用

转换
response = client.UploadData(ClientUrl, Data);
string s = Encoding.UTF8.GetString(response);


--MIMEBoundaryurn_uuid_E2119CF27EF7027A6F1406730560891
Content-Type: application/xop+xml; charset=UTF-8; type="text/xml"
Content-Transfer-Encoding: binary
Content-ID: <0.urn:uuid:E2119CF27EF7027A6F1406730560892@apache.org>

<?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><dlwmin:getApplicationPDFResponse xmlns:dlwmin="http://example.com/POS/get" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><ns1:GetPDFResponse xmlns:ns1="http://example.com/POS/get"><ns1:appPdfDoc><xop:Include xmlns:xop="http://www.w3.org/2004/08/xop/include" href="cid:urn:uuid:E2119CF27EF7027A6F1406730560893@apache.org"/></ns1:appPdfDoc><ns1:messageList/></ns1:GetPDFResponse></dlwmin:getApplicationPDFResponse></soapenv:Body></soapenv:Envelope>
--MIMEBoundaryurn_uuid_E2119CF27EF7027A6F1406730560891
Content-Type: application/pdf
Content-Transfer-Encoding: binary
Content-ID: <urn:uuid:E2119CF27EF7027A6F1406730560893@apache.org>

%PDF-1.4
%????
26 0 obj<</Rect[91.4365 636.817 299.129 651.505]/T(Contract Address 2)/t 1/V(OA CITY / OK / 73132-1501)/Subtype/Widget/DA(/ArialMT 10 Tf )/MK<<>>/FT/Tx/AP<</N 27 0 R>>/Ff 8388609>>
endobj

H??Wk????_?|?A?0???"K?  \???+????^?]?f???:U??p6D????T???5???????y???z?f??zS???????t?{u?????U?DZ?`??i?l6u???u?U??:?0??2????S{yqU????\?>
d?~d(??C??Y?F???'?~K?03&?2??U.F?:4?@???????>_,???"?M?+????.*?x2?4Y??b???o??(M??F[X???j?cQ????EQZ??_??)Jg?a??h8m-;???:??;-???

它有PDF,从%PDF-1.4开始。

我从未解析过xop内容。我只是尝试将其加载到XDocument中,如

XDocument xdoc = XDocument.Parse(s);
XElement root = xdoc.Root; 
XNamespace ns1 = "example.com/POS/get";
var fileBinary = root.Descendants(ns1 + "appPdfDoc").FirstOrDefault(); 

并收到错误消息,表明它不是有效的xml文档。

现在我尝试使用XmlDictionaryReader.CreateMtomReader加载字符串S,看看是否允许我提取PDF。

如果需要任何其他细节,请告诉我。任何帮助深表感谢。

最诚挚的问候。

0 个答案:

没有答案