【问题标题】:Error while run web service [duplicate]运行 Web 服务时出错 [重复]
【发布时间】:2012-03-08 14:26:33
【问题描述】:

我正在尝试使用 android 提供网络服务。我使用 Visual Studio 创建了 Web 服务。我手动测试了 Web 服务,它返回了我的值。现在,我尝试在 android 中配置 web 服务,以便它可以返回相同的值,但是当我尝试运行代码时发生错误。 转换为 Dalvik 格式失败,出现错误 1。 需要大师的建议。谢谢

下面是我的代码。

package com.test.web;

import android.app.Activity;
import android.os.Bundle;

import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.PropertyInfo;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapPrimitive;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransportSE;
import android.util.Log;
import android.widget.TextView;
import android.widget.Toast;

public class WebSrviceActivity extends Activity {
    private final String WSDL_TARGET_NAMESPACE = "http://smartposter.smartag.my";
    private final String SOAP_ADDRESS = "http://smartposter.smartag.my/SmartPosterV1.asmx";
    private final String SOAP_ACTION = "http://smartposter.smartag.my/HelloWorld";
    private final String METHOD_NAME = "HelloWorld";
    private static final String URL = "http://localhost:62558/SmartPosterV1.asmx";
    private Object resultsRequestSOAP = null;
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
       // setContentView(R.layout.main);

        TextView tv = new TextView(this);
        setContentView(tv);


    SoapObject request = new SoapObject(WSDL_TARGET_NAMESPACE, METHOD_NAME);


     //SoapObject
    /*request.addProperty("firstname", "John");
    request.addProperty("lastname", "Williams");*/
    SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
    envelope.setOutputSoapObject(request);


    HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
    try
    {
        androidHttpTransport.call(SOAP_ACTION, envelope);
        resultsRequestSOAP =  envelope.getResponse();
        String[] results = (String[])  resultsRequestSOAP;
        tv.setText( results[0]);
        Toast.makeText(getApplicationContext(), "testig"+results[0].toString(),    Toast.LENGTH_LONG).show();    
    }
    catch(Exception ex)
    {

    }

    }
}

【问题讨论】:

  • 你是对的。一旦我取下罐子。它工作正常。谢谢。

标签: java android web-services android-emulator


【解决方案1】:

根据之前的答案,您的项目中似乎有冲突的库:

"Conversion to Dalvik format failed with error 1" on external JAR

【讨论】:

    【解决方案2】:

    不能在安卓上使用肥皂

    你可以试试其他的

    也许是 ksoap

    【讨论】:

      猜你喜欢
      • 2013-03-22
      • 2016-06-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多