不幸的是Android的web服务已停止 [英] Unfortunately Android WebService Has Stopped

查看:126
本文介绍了不幸的是Android的web服务已停止的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新来的Andr​​oid编程和开发这个应用程序,需要在参数公斤的并将其转换为使用Web服务克,但同时在模拟器中运行的应用程序说,不幸的是Android的web服务已停止,并在logcat中的主要问题正在显示找不到org.ksoap2.serialization.SoapObjectare虽然我已经包含了ksoap2-机器人组装-2.5.4-JAR与 - 依赖的jar文件...请帮助

i am new to android programming and have developed this app that takes in parameter in Kg's and converts it to grams using a web service but while running on emulator the app says "Unfortunately Android WebService Has Stopped" and the main problem in logcat being shown "cannot find org.ksoap2.serialization.SoapObjectare" though i have included the "ksoap2-android-assembly-2.5.4-jar-with-dependencies" jar file ... please help

这是我的code:

package com.sencide;



private final String NAMESPACE = "http://www.webserviceX.NET/";
private final String URL = "http://www.webservicex.net/ConvertWeight.asmx";
private final String SOAP_ACTION = "http://www.webserviceX.NET/ConvertWeight";
private final String METHOD_NAME = "ConvertWeight";

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME); 

    String weight = "3700";
    String fromUnit = "Grams";
    String toUnit = "Kilograms";

    PropertyInfo weightProp =new PropertyInfo();
    weightProp.setName("Weight");
    weightProp.setValue(weight);
    weightProp.setType(double.class);
    request.addProperty(weightProp);

    PropertyInfo fromProp =new PropertyInfo();
    fromProp.setName("FromUnit");
    fromProp.setValue(fromUnit);
    fromProp.setType(String.class);
    request.addProperty(fromProp);

    PropertyInfo toProp =new PropertyInfo();
    toProp.setName("ToUnit");
    toProp.setValue(toUnit);
    toProp.setType(String.class);
    request.addProperty(toProp);

    SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
    envelope.dotNet = true;
    envelope.setOutputSoapObject(request);
    HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);

    try 
    {
        androidHttpTransport.call(SOAP_ACTION, envelope);
        SoapPrimitive response = (SoapPrimitive)envelope.getResponse();
        Log.i("myApp", response.toString());

        TextView tv = new TextView(this);
        tv.setText(weight+" "+fromUnit+" equal "+response.toString()+ " "+toUnit);
        setContentView(tv);

    } 
    catch (Exception e) 
    {
        e.printStackTrace();
    }
}

}

推荐答案

罐子添加到库文件夹和NOT lib文件夹,然后添加到构建路径。

Add the jar to the 'libs' folder and NOT lib folder and then add to the Build Path.

这篇关于不幸的是Android的web服务已停止的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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