使用ksoap2库来连接.net服务端的webservices接口,发现其他调用时没有问题,但是一旦参数中带有中文,就会转化为&#xxxx;这样的内容,然后导致服务端不认可。
现在服务端不是我搞的,只能在客户端改,怎么办?private String callRemoteInterface(String methodName, String[] paramNames,
Object[] args) {
if (paramNames.length != args.length) {
Log.e(application.getString(R.string.app_name),
"Call RemoteInterface, but param name and args number is not equire");
return null;
}
SoapObject soapObject = new SoapObject(targetNameSpace, methodName);
for (int i = 0; i < paramNames.length; ++i) {
soapObject.addProperty(paramNames[i], args[i].toString());
} SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
SoapEnvelope.VER11);
envelope.setOutputSoapObject(soapObject);
envelope.bodyOut = soapObject;
envelope.dotNet = true;
HttpTransportSE httpTransport = new HttpTransportSE(url);
httpTransport.debug = true;

try {
httpTransport.call(targetNameSpace + methodName, envelope);
Object result = envelope.getResponse();
if (result != null && !result.toString().equals("0")) {
return result.toString();
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}以下是请求头的内容,不想要&#xxxx这些,想直接是汉字,也许就可以了
<v:Envelope xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns:d="http://www.w3.org/2001/XMLSchema" xmlns:c="http://schemas.xmlsoap.org/soap/encoding/" xmlns:v="http://schemas.xmlsoap.org/soap/envelope/"><v:Header /><v:Body><askLiuyan xmlns="http://tempuri.org/" id="o0" c:root="1"><linkid i:type="d:string">3350</linkid><userid i:type="d:string">10107</userid><linkName i:type="d:string">&#21335;&#26124;&#32769;&#30334;&#22995;&#22823;&#33647;&#25151;</linkName><be i:type="d:string">pppppp</be><key i:type="d:string">ecf66017e7a6fd0bb99df06730ca7f4d</key></askLiuyan></v:Body></v:Envelope>