ksoap2机器人发送数据 [英] ksoap2 android sending data

查看:203
本文介绍了ksoap2机器人发送数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图让ksoap2在Android上工作。我花了至少10小时,现在读书论坛帖子和文档。
刚刚查询了一些方法,如getServerTime在那里我没有发送任何值,有效。
我的目标是发送数据,并接收响应。例如:发送城市名称,获取城市时间

I'm trying to get ksoap2 working on android. I have spent at least 10 hours now reading forum posts, and documentations. Just querying some methods like getServerTime where I don't have to send any values, works. My goal is to send data, and receive a response. For example: send city name, get city time.

我练上这个网站: http://www.nanonull.com/TimeService/ TimeService.asmx

这是我的code:

  String METHOD_NAME = "getCityTime";
  String SOAP_ACTION = "http://www.Nanonull.com/TimeService/getCityTime";
  String NAMESPACE = "http://www.nanonull.com/TimeService/";
  String URL = "http://www.nanonull.com/TimeService/TimeService.asmx";

  SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);

  request.addProperty("city", "Chicago");

  SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
    SoapEnvelope.VER11);

  envelope.setOutputSoapObject(request);

  HttpTransportSE httpTransport = new HttpTransportSE(URL);
  try {
   httpTransport.call(SOAP_ACTION, envelope);
  } catch (IOException e) {
   // TODO Auto-generated catch block
   e.printStackTrace();
  } catch (XmlPullParserException e) {
   // TODO Auto-generated catch block
   e.printStackTrace();
  } // This sends a soap

  System.out.println(envelope.bodyIn.toString());

这是错误我得到(envelope.bodyIn.toString()):

this is the error I get(envelope.bodyIn.toString()):

SoapFault - faultcode: 'soap:Server'
faultstring: 'Server was unable to process request. ---> Object reference not set to an
instance of an object.' faultactor: 'null' detail: org.kxml2.kdom.Node@435b9cf8

帮助将不胜AP preciated。

Help would be greatly appreciated.

推荐答案

我发了一篇文章的话题

http://www.helloandroid.com/tutorials/using-ksoap2-android-and-parsing-output-data

这篇关于ksoap2机器人发送数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆