我正在使用 .net Web 服务 ksoap,我得到二进制字符串作为响应。我想将此字符串转换为图像并希望在 ImageView 中显示此图像。我正在从服务器获取图像/文档/pdf。
我的代码:
SoapObject DocumentRequest = new SoapObject(NAMESPACE, GET_DOCUMENT_METHOD);
DocumentRequest.addProperty("DocumentID", ID);
Log.i("DocumentID", ID);
SoapSerializationEnvelope Envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
Envelope.dotNet = true;
Envelope.setOutputSoapObject(DocumentRequest);
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
androidHttpTransport.debug = true;
androidHttpTransport.call(SOAP_ACTION_GETDOCUMENT, Envelope);
SoapPrimitive DocumentResponse = (SoapPrimitive)Envelope.getResponse();
Log.i("DocumentResponse", DocumentResponse.toString());
我应该使用什么来显示任何类型的文件 image/doc/pdf。如何将此二进制字符串转换为正确的格式以及如何下载它???我感到很困惑。
//位图是个好主意吗?
这段代码在日志中以二进制形式给我响应。我想将其转换为 Image/doc 文件/pdf 文件并希望将其下载到本地 sd 卡中。
POST /**********Mobile/**********.asmx HTTP/1.1
Host: 192.168.1.5
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://tempuri.org/GetDocument"
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<GetDocument xmlns="http://tempuri.org/">
<DocumentID>string</DocumentID>
</GetDocument>
</soap:Body>
</soap:Envelope>
HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: length
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<GetDocumentResponse xmlns="http://tempuri.org/">
<GetDocumentResult>string</GetDocumentResult>
</GetDocumentResponse>
</soap:Body>
</soap:Envelope>
请建议谢谢