Ksoap 在 java webservice 中发送空请求

发布于 2024-12-14 10:06:05 字数 1656 浏览 4 评论 0原文

我的简单应用程序没有向我的简单 Web 服务发送任何请求

    package com.demo;
    import javax.jws.WebService;
    @WebService
    public class hello {

                         public String hai(String name)
                      {
                        return "Hello"+name;

                       }
                        }

,我的 Android 应用程序代码是

    public void onClick(View arg0) {
    // TODO Auto-generated method stub
    Toast.makeText(this, "success", Toast.LENGTH_LONG).show();
    try {
         SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME); 

         //parameters.addProperty("name","muthu");
          PropertyInfo username=new PropertyInfo();
          username.name="name";
          username.type=PropertyInfo.STRING_CLASS;
          request.addProperty(username,"welcome");




          SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
          envelope.setOutputSoapObject(request);                       
          HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);            

          androidHttpTransport.call(SOAP_ACTION, envelope);

          SoapPrimitive  resultsRequestSOAP = (SoapPrimitive) envelope.getResponse();



     Toast.makeText(this, resultsRequestSOAP.toString(), Toast.LENGTH_LONG).show();
    }
    catch (Exception e) {}

    }

}

Web 服务在返回值时工作正常。我可以毫无问题地收到一个值。但是当我的请求返回到我的 Android 客户端时,它总是显示为 null(或)空。

我正在使用 ksoap:

ksoap2-android-assembly-2.5.7-jar-with-dependencies.jar

服务器:

Glassfish 3.1 in eclipse

请帮助我!

My simple application didn't send any request to my simple web service

    package com.demo;
    import javax.jws.WebService;
    @WebService
    public class hello {

                         public String hai(String name)
                      {
                        return "Hello"+name;

                       }
                        }

and my android app code is

    public void onClick(View arg0) {
    // TODO Auto-generated method stub
    Toast.makeText(this, "success", Toast.LENGTH_LONG).show();
    try {
         SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME); 

         //parameters.addProperty("name","muthu");
          PropertyInfo username=new PropertyInfo();
          username.name="name";
          username.type=PropertyInfo.STRING_CLASS;
          request.addProperty(username,"welcome");




          SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
          envelope.setOutputSoapObject(request);                       
          HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);            

          androidHttpTransport.call(SOAP_ACTION, envelope);

          SoapPrimitive  resultsRequestSOAP = (SoapPrimitive) envelope.getResponse();



     Toast.makeText(this, resultsRequestSOAP.toString(), Toast.LENGTH_LONG).show();
    }
    catch (Exception e) {}

    }

}

The web service is working fine when it returns values. I can receive a value without any problem. But my request show always null(or)empty when it return back to my android client side.

I am using ksoap:

ksoap2-android-assembly-2.5.7-jar-with-dependencies.jar

Server:

Glassfish 3.1 in eclipse

Please help me!!

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

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

发布评论

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

评论(1

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