2012-05-30 54 views
0

我嘗試使用webservice發送數據到MsSql這個代碼。當我嘗試發送數據 Manuely其工作很好,但是當我嘗試通過此代碼發送不起作用。 返回值始終是正確的值,但不發送給MYDATABASEKsoap2發送數據不起作用「request.addProperty(」Lat「,」21233232「);」不工作

SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME); 

     PropertyInfo pi = new PropertyInfo(); 
     pi.setName("DeviceId"); 
     pi.setValue("mumin burak"); 
     pi.setType(String.class); 
     pi.setNamespace(NAMESPACE); 
     request.addProperty(pi); 


    request.addProperty("Lat", "21233232"); 

    SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
      SoapEnvelope.VER11); 
    envelope.dotNet = true; 
    envelope.setOutputSoapObject(request); 

    AndroidHttpTransport httpTransport = new AndroidHttpTransport(URL); 

    SoapPrimitive result = null; 
    try { 
     httpTransport.call(SOAP_ACTION, envelope); 
     result = (SoapPrimitive) envelope.getResponse(); 
     twMsg.setText(result.toString()); 
    } catch (IOException e) { 
     // TODO Auto-generated catch block 
     twMsg.setText(e.getMessage()); 
    } catch (XmlPullParserException e) { 
     // TODO Auto-generated catch block 
     twMsg.setText(e.getMessage()); 
    } 

回答

0

要發送double值,你應該實現KSOAP元帥接口。欲瞭解更多信息,請訪問這裏:Implementing KSOAP Marshal Interface

+0

感謝您的回答。我想發送字符串值。我需要Marshal界面嗎? – teknodram

+0

編號只是'request.addProperty(「PROPERTY_NAME」,「PROPERTY_VALUE」);' – OguzOzkeroglu

+0

request.addProperty(「PROPERTY_NAME」,「PROPERTY_VALUE」); doent工作webserver獲取參數,但web服務器功能doent工作,並沒有發送數據到sql – teknodram

2

我已經遭受了同樣的問題與SOAP WS .... 與緯度/經度和任何雙數據類型值......我必須要喜歡「MarshalFloat類」
http://seesharpgears.blogspot.in/2010/11/implementing-ksoap-marshal-interface.html

終於......無需改變整個邏輯。但只是創建MarshalFloat的實例,並註冊它與信封它已完成在我的情況..

MarshalFloat md = new MarshalFloat();

md.register(envelope);