XML响应。
尝试获取file
类型base64binary
的值。
<?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代码。我使用下面的代码。
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;
}
编码后的图片值应为/9j/4AAQSkZJRgABAQAAAQABAAA=
,但我的值为base64Binary{}
。
请帮我解析一下
答案 0 :(得分:0)
我传递的参数拼写错误。取代chunkSize,它应该是chuckSize。