我正在构建一个使用.asmx web服务的应用程序
我遇到一个奇怪的问题,我在服务器中发送的所有参数都是null
这是我的方法
try {
SoapObject request = new SoapObject(DealightsConstants.NAMESPACE, DealightsConstants.METHOD_MOBILE_LOGIN);
//request.addProperty(DealightsConstants.METHOD_MOBILE_LOGIN_USERNAME, username);
//request.addProperty(DealightsConstants.METHOD_MOBILE_LOGIN_PASSWORD, password);
PropertyInfo pi = new PropertyInfo();
pi.setName(DealightsConstants.METHOD_MOBILE_LOGIN_USERNAME);
pi.setValue(username);
pi.setType(String.class);
PropertyInfo pi1 = new PropertyInfo();
pi1.setName(DealightsConstants.METHOD_MOBILE_LOGIN_PASSWORD);
pi1.setValue(password);
pi1.setType(String.class);
request.addProperty(pi);
request.addProperty(pi1);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet=true;
envelope.setOutputSoapObject(request);
HttpTransportSE androidHttpTransport = new HttpTransportSE(DealightsConstants.URL);
androidHttpTransport.call(DealightsConstants.SOAP_ACTION + DealightsConstants.METHOD_MOBILE_LOGIN, envelope);
androidHttpTransport.debug=true;
Object result = envelope.getResponse();
if (result != null) {
Log.i("AMIRA" , result.toString());
JSONArray array = new JSONArray(result.toString());
if (array != null && array.length() > 0) {
return array.getJSONObject(0);
} else {
return null;
}
} else {
return null;
}
} catch (Exception e) {
e.printStackTrace();
return null;
}
我使用了很多格式,没有什么能和我一起工作
修改
asmx方法描述的一部分
POST /DealightsWS.asmx HTTP/1.1
Host: ------
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "Dealights/mobileLogin"
<?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>
<mobileLogin xmlns="Dealights">
<uname>string</uname>
<pass>string</pass>
</mobileLogin>
</soap:Body>
</soap:Envelope>
答案 0 :(得分:0)
与我自己的肥皂项目相比,这可能会解决它:
androidHttpTransport.call(DealightsConstants.SOAP_ACTION, envelope);
请注意我已删除:
+ DealightsConstants.METHOD_MOBILE_LOGIN
已在附加到信封的请求中提供