使用 KSOAP2 发送参数时的错误 (Android)

发布于 2024-11-02 12:18:07 字数 1585 浏览 1 评论 0原文

我对 KSOAP2 的使用感到非常厌倦:我正在搜索解决方案 1 天,但我找不到任何东西...

我有一个简单的 PHP Web 服务,它是从教程中的示例中获取的:GetSumOfTwoInts。它需要两个 Int 参数并返回它们的和。

我可以在 PHP 和 Java 中调用这个 Web 服务,它工作得很好,但是当我用 KSAOP2 调用它时,我总是遇到同样的错误:

SoapFault - faultcode: 'SOAP-ENV:Server' faultstring: 'Procedure 'GetSumOfTwoInts' not present' faultactor: 'null' detail: null

这里,我的代码:

public void onCreate( Bundle icicle )
{
    super.onCreate(icicle);
    TextView tv = new TextView(this);
    setContentView(tv);
    SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);    

    PropertyInfo pi = new PropertyInfo();
    pi.setName("Operand1");
    pi.setValue(40);
    pi.setType(int.class);
    request.addProperty(pi);

    PropertyInfo pi2 = new PropertyInfo();
    pi2.setName("Operand2");
    pi2.setValue(6);
    pi2.setType(int.class);
    request.addProperty(pi2);

    SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);

    envelope.setOutputSoapObject(request);

    HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);

    try
    {
        androidHttpTransport.call(SOAP_ACTION, envelope);

        String result = envelope.bodyIn.toString(); 

        Toast.makeText(this, result, 10000).show();
        Log.v("TEST", result);
    }
    catch(Exception e)
    {
        e.printStackTrace();
        Log.v("TEST1", e.toString());
    }


}

并且错误发生在这一行:“androidHttpTransport.call(SOAP_ACTION, 信封) );”

这很奇怪,因为我做了其他尝试,使用不带参数的网络服务并且运行良好......只是当我需要参数时它不起作用......

我需要你的帮助! :)

I'm very bored with the using of KSOAP2 : i'm searching a solution for 1 day and I can't find anything...

I have a simple PHP Webservice that I took from example in tutorial : GetSumOfTwoInts. It takes two Int in parameters and return their sum.

I can call this webservice in PHP and in Java, it works good, but when I call it with KSAOP2 I have always the same error :

SoapFault - faultcode: 'SOAP-ENV:Server' faultstring: 'Procedure 'GetSumOfTwoInts' not present' faultactor: 'null' detail: null

Here, my code :

public void onCreate( Bundle icicle )
{
    super.onCreate(icicle);
    TextView tv = new TextView(this);
    setContentView(tv);
    SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);    

    PropertyInfo pi = new PropertyInfo();
    pi.setName("Operand1");
    pi.setValue(40);
    pi.setType(int.class);
    request.addProperty(pi);

    PropertyInfo pi2 = new PropertyInfo();
    pi2.setName("Operand2");
    pi2.setValue(6);
    pi2.setType(int.class);
    request.addProperty(pi2);

    SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);

    envelope.setOutputSoapObject(request);

    HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);

    try
    {
        androidHttpTransport.call(SOAP_ACTION, envelope);

        String result = envelope.bodyIn.toString(); 

        Toast.makeText(this, result, 10000).show();
        Log.v("TEST", result);
    }
    catch(Exception e)
    {
        e.printStackTrace();
        Log.v("TEST1", e.toString());
    }


}

ANd the error occured at this line : "androidHttpTransport.call(SOAP_ACTION, envelope);"

It's very strange, because I maked other attemps, with webservice which don't take parameters and it works good.... It just when I need parameters that it doesn't work....

I Need Your Help!!! :)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

傻比既视感 2024-11-09 12:18:07
pi.setType(int.class);

尝试使用

pi.setType(Integer.class);
pi.setType(int.class);

Try use

pi.setType(Integer.class);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文