dspows0637 2011-04-21 07:37
浏览 119

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

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!!! :)

  • 写回答

1条回答 默认 最新

  • ds15812330851 2013-11-05 15:42
    关注
    pi.setType(int.class);
    

    Try use

    pi.setType(Integer.class);
    
    评论

报告相同问题?

悬赏问题

  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记