2017-03-31 117 views
0

工作我建立消耗KSOAP setProperity沒有在安卓

我面臨着一個奇怪的問題的.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> 

回答

0

部分比較我自己的肥皂項目,也許這將解決這個問題:

androidHttpTransport.call(DealightsConstants.SOAP_ACTION, envelope); 

通知,我已經刪除:

+ DealightsConstants.METHOD_MOBILE_LOGIN 

該信息已附加到信封

+0

如果我沒有發送參數,或者如果我發送了一個int參數,這個問題只會發生在字符串參數 –

+0

你可以提供任何部分wsdl – buradd

+0

我編輯了我的問題,請檢查它 –