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);
    
    评论

报告相同问题?

悬赏问题

  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料