1

我正在尝试将 ksaop2-android 库与 Dot42 一起使用,并且在达到我认为可以测试的地步后,在成功构建后出现上述错误。我从调试模式开始。我以前从未见过这种错误,甚至不知道从哪里开始纠正它。最新更新后,我已成功运行 Dot42 的默认应用程序模板。我正在使用 Visual Studio 2012。我在清单文件中启用了 INTERNET 权限。这是我的代码:

using System;
using Android.App;
using Android.Os;
using Android.Widget;
using Dot42;
using Dot42.Manifest;
using Org.Ksoap2.Serialization;
using Org.Ksoap2.Transport;


[assembly: Application("dot42Application7")]

namespace dot42Application7
{

    [Activity]
    public class MainActivity : Activity
    {
    private string NAMESPACE = "http://reps.catalystinnovations.net/";
    private string URL = "http://reps.catalystpromotions.net/T-ShirtPricing.asmx";

    protected override void OnCreate(Bundle savedInstance)
    {
        base.OnCreate(savedInstance);
        SetContentView(R.Layouts.MainLayout);
        TryWebService();
    }

    public void TryWebService()
    {
        string METHOD_NAME = "GetTShirtPricingString";
        string SOAP_ACTION = NAMESPACE + METHOD_NAME;

        SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);

        PropertyInfo password = new PropertyInfo();
        password.SetName("password");
        password.SetValue("password");
        password.SetType(typeof(string));

        PropertyInfo numColors = new PropertyInfo();
        numColors.SetName("color");
        numColors.SetValue("White");
        // numColors.setValue("White");
        numColors.SetType(typeof(string));

        PropertyInfo numShirts = new PropertyInfo();
        numShirts.SetName("weight");
        double w = 5.4d;
        numShirts.SetValue(w.ToString());
        // numShirts.setValue("5.4");
        numShirts.SetType(typeof(string));

        request.AddProperty(password);
        request.AddProperty(numColors);
        request.AddProperty(numShirts);

        SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(Org.Ksoap2.SoapEnvelope.VER11);
        envelope.DotNet = true;
        envelope.SetOutputSoapObject(request);
        envelope.ImplicitTypes = true;

        HttpTransportSE transport = new HttpTransportSE(URL);

        try
        {
            transport.Call(SOAP_ACTION, envelope);
            SoapPrimitive response = (SoapPrimitive)envelope.GetResponse();
            string result = response.ToString();
            int i = 0;
        }
        catch(Exception e)
        {
            e.PrintStackTrace();
        }

    }
}
}
4

0 回答 0