我有錯誤從Web服務獲取價值。我嘗試所有的時間,但沒有成功。我用WCF,Entity框架做了webservice。這臺服務器很好用。但我想連接並從Android手機獲得價值。Android KSOAP2出錯獲取值
我的Android代碼:
private final String NAMESPACE="http://tempuri.org/"; private final String SOAPACTION="http://tempuri.org/IService/GetValues"; private final String METHODNAME="GetTreatmentValues"; private final String URL="http://localhost:49674/Service.svc";
保護無效的onCreate(捆綁savedInstanceState){
super.onCreate(savedInstanceState); setContentView(R.layout.menu); button1.setOnClickListener(新View.OnClickListener(){@覆蓋
公共無效的onClick(視圖v){SoapObject request = new SoapObject(NAMESPACE,METHODNAME); request.addProperty("value",1); SoapSerializationEnvelope sp = new SoapSerializationEnvelope(SoapEnvelope.VER11); sp.dotNet=true; sp.setOutputSoapObject(request); HttpTransportSE aht = new HttpTransportSE(URL); aht.debug = true; text2.setText(aht.toString()); //AndroidHttpTransport aht = new AndroidHttpTransport(URL); try { aht.call(SOAPACTION,sp); //I have ERROR! no work. //SoapPrimitive resultstring = (SoapPrimitive)sp.getResponse(); text1.setText("test"); //text2.setText(resultstring.toString()); } catch (Exception e) { // TODO: handle exception text2.setText("hata!"); } } });
我得到錯誤aht.call(SOAPACTION,SP); (使用Ksoap2.4)
我也無法連接模擬器中的瀏覽器。它可能是問題? –