ksoap setProperity在Android中不起作用



我正在构建一个使用 .asmx Web 服务的应用程序

遇到了一个奇怪的问题,我随请求发送的所有参数在服务器中都是空的

这是我的方法

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>

与我自己的肥皂项目相比,也许这可以解决它:

androidHttpTransport.call(DealightsConstants.SOAP_ACTION, envelope);

请注意,我已删除:

+ DealightsConstants.METHOD_MOBILE_LOGIN

已在附加到信封的请求中提供

相关内容

  • 没有找到相关文章

最新更新