Tag: 网络服务

尝试从我的android java应用程序调用web服务时android.os.NetworkOnMainThreadExceptionexception?

嗨,我是Android java开发的新手,我试图从我的android java应用程序调用java webservice。 当我试图运行此应用程序时,我得到一个exception,说明android.os.NetworkOnMainThreadException。 我不知道为什么会出现这个错误.. ?? 无论如何我都遇到了这个错误。 我已经google了很多,但无法找到一个确切的解决方案..任何人都可以帮助..?我的代码片段如下。 SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME); SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11); envelope.setOutputSoapObject(request); HttpTransportSE androidHttpTransport = new HttpTransportSE(URL); androidHttpTransport.call(SOAP_ACTION,envelope); SoapObject so = (SoapObject)envelope.bodyIn; 完成调试后我认为这些代码行androidHttpTransport.call(SOAP_ACTION,envelope); SoapObject so = (SoapObject)envelope.bodyIn; androidHttpTransport.call(SOAP_ACTION,envelope); SoapObject so = (SoapObject)envelope.bodyIn; 正在制造问题。 代码envelope.bodyIn给我一个空值。

如何加密android中的数据

我正在使用PHP WebService将我的数据发送到服务器。 不知何故,我的数据太重要了,同样我必须使用一些加密算法将我的数据发送到webservice。 然后webservice必须解密该数据并进一步继续。 同样,当WebService发送响应时,响应应该加密,并且从客户端它将被解除。 任何人都可以建议我应该为上述问题实施什么算法或方法?

Android:由于Web服务Http请求,活动耗时太长而无法显示

当我启动应用程序时,我的一个活动向Web服务发出http请求以获取一些天气数据。 由于Web服务请求,活动将需要3-4秒才能显示的问题。 (在实际设备上测试) 我知道我没有以正确的方式做到这一点。 我正在做的就是在onCreate方法上,我发出请求,获取xml,解析并显示数据。 在Android中处理Web服务请求的最佳方法是什么,因此应用程序在请求时不会显示白屏? 也许有些线程……. 我知道我的设备中的其他应用程序没有发生请求获取实时数据。 笔记: 1)我回来的xml不是那么大(5个元素,每个元素有5个嵌套元素)。 2)我试过3G网络和Wifi,但响应时间仍然相同。 示例代码: @Override public void onCreate(Bundle icicle) { super.onCreate(icicle); setContentView(R.layout.clock_weather); // this is where it is making the request and parsing the xml. WeatherSet set = getWeatherCondition(“New York, NY”); TextView currentWeather = (TextView) findViewById(R.id.current_weather); currentWeather.setText(“” + set.getWeatherCurrentCondition().getTempFahrenheit()); TextView currentWeatherH = (TextView) findViewById(R.id.current_weatherH); currentWeatherH.setText(“H: ” + […]

如何将json数据发送到POST restful服务

我想用POST方法调用rest webservice.Below是我需要传递的服务url及其参数 Rest Service: https://url/SSOServer/SSO.svc/RestService/Login Json Object {“ProductCode”:”AB”,”DeviceType”:”android Simulator”,”UserName”:””,”ModuleCode”:”AB_MOBILE”,”DeviceId”:”device-id”,”Version”:”1.0.0.19″,”CustomerCode”:”w”,”Password”:””} 这是我的post请求代码: public void sendHttpPost() throws ClientProtocolException, IOException{ HttpPost httpPostRequest = new HttpPost(url + buildParams()); // add headers Iterator it = headers.entrySet().iterator(); Iterator itP = params.entrySet().iterator(); while (it.hasNext()) { Entry header = (Entry) it.next(); httpPostRequest.addHeader((String)header.getKey(), (String)header.getValue()); } HttpClient client = new DefaultHttpClient(); HttpResponse resp; resp = client.execute(httpPostRequest); […]

抢购道路Android

我正在编写一个Android应用程序,我需要能够获取一个纬度/经度值,并找到最近的道路的纬度/经度值。 我已经阅读了http://econym.org.uk/gmap/snap.htm上的文章,并试图实现这一点,但我不得不使用谷歌地图Web服务而不是javascript(因为它是一个Android应用程序) 。 当我提出要求时 maps.google.com/maps/api/directions/xml?origin=52.0,0&destination=52.0,0&sensor=true 它根本不会让我回到最近的路上! 似乎上述方法不适用于Web服务。 有没有人对如何解决这个问题有任何其他想法?