[英]How to parse xml response from soap of type base64binary in android?
XML Response. XML响应。
Trying to get the value of file
which is of type base64binary
. 试图获取类型为
base64binary
的file
的值。
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:xmds" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body>
<ns1:GetFileResponse>
<file xsi:type="xsd:base64Binary">/9j/4AAQSkZJRgABAQAAAQABAAA=</file>
</ns1:GetFileResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
Android code to fetch and parse above response. Android代码来获取和解析以上响应。 I m using below code to that.
我正在使用下面的代码。
protected Void doInBackground(Void... params) {
String URL = "http://ngage.services/dss/albertsons/xmds.php?v=4&wsdl/GetFile";
//for linear parameter
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME_GET_FILE);
request.addProperty("serverKey", "nitro"); // adding method property here serially
request.addProperty("hardwareKey", "01a5de64f888b0c5a286ff821695cdfd41ad08"); // adding method property here serially
request.addProperty("fileId", "27");
request.addProperty("fileType", "media");
request.addProperty("chunkOffset", "0");
request.addProperty("chunkSize", "207672");
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
SoapEnvelope.VER11);
envelope.dotNet = true;
envelope.setOutputSoapObject(request);
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
try {
androidHttpTransport.call(SOAP_ACTION_GET_FILE, envelope);
} catch (Exception e) {
e.printStackTrace();
}
SoapObject result;
result = (SoapObject) envelope.bodyIn;
if (result != null) {
String encodedImage = result.getProperty("file").toString();
Log.v("TAG", encodedImage);
byte[] decodedString = Base64.decode(encodedImage, Base64.DEFAULT);
decodedByte = BitmapFactory.decodeByteArray(decodedString, 0,
decodedString.length);
}
return null;
}
The encoded Image value should be /9j/4AAQSkZJRgABAQAAAQABAAA=
but I m getting its value as base64Binary{}
. 编码的Image值应为
/9j/4AAQSkZJRgABAQAAAQABAAA=
但我将其值设置为base64Binary{}
。
Please help me out to parse it in right way 请帮助我以正确的方式解析它
Parameter which I was passing was misspelled. 我传递的参数拼写错误。 In place of chunkSize, it should be chuckSize.
代替chunkSize,它应该是chuckSize。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.