【发布时间】:2013-12-10 21:42:24
【问题描述】:
我从 Web 服务获取价值时出错。我一直在尝试,但没有成功。我使用 WCF 实体框架进行了 Web 服务。这台服务器运行良好。但我想连接并从 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); 设置内容视图(R.layout.menu); button1.setOnClickListener(new View.OnClickListener() {@Override
public void onClick(View 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); text1 从不设置“测试”我该怎么办。我不知道我想念什么。谢谢。 (使用Ksoap2.4)
【问题讨论】:
标签: c# java android wcf web-services