我有错误从Web服务获得 Value . 我一直在尝试,但没有成功 . 我使用WCF,Entity框架进行了webservice . 这台服务器运行良好 . 但我想从Android手机连接并获得 Value .
我的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”;
protected void onCreate(Bundle savedInstanceState){super.onCreate(savedInstanceState);的setContentView(R.layout.menu); button1.setOnClickListener(new View.OnClickListener(){@Override public void onClick(View v){SoapObject request = new SoapObject(NAMESPACE,METHODNAME);
request.addProperty( “值”,1);
SoapSerializationEnvelope sp = new SoapSerializationEnvelope(SoapEnvelope.VER11);
sp.dotNet = TRUE;
sp.setOutputSoapObject(请求);
HttpTransportSE aht = new HttpTransportSE(URL);
aht.debug = true;
text2.setText(aht.toString());
// AndroidHttpTransport aht = new AndroidHttpTransport(URL);
尝试{
aht.call(SOAPACTION,SP); //我有错误!没工作 .
// SoapPrimitive resultstring =(SoapPrimitive)sp.getResponse();
text1.setText( “测试”);
//text2.setText(resultstring.toString());
} catch(例外e){
// TODO:处理异常
text2.setText( “畑!”);
}
}
});
我得到错误aht.call(SOAPACTION,sp); text1永远不会设置“测试”我该怎么办 . 我不知道我想念的是什么 . 谢谢 . (使用Ksoap2.4)
2 回答
试试这个例子,或者用这段代码检查你的代码
http://www.c-sharpcorner.com/uploadfile/88b6e5/how-to-call-web-service-in-android-using-soap/
希望你能得到解决方案 .
我将我的网络服务放入国际空间站 . 我的链接是http:// localhost:90 / Service.svc?wsdl在这个页面中,我看到了xml代码
我将此代码写入Android应用程序
但我总是在这里得到错误:( :(