从应用程序中使用KSOAP方法Web服务临危空参数应用程序、参数、方法、KSOAP

2023-09-05 02:16:50 作者:爆你菊花牌菊花茶*

我见过的话题讨论这一点,但没有人似乎已发布的解决方案。目前,我测试的参数传递到我的.NET Web服务。当参数达到Web服务将其添加一个额外的字符串,然后返回它太我的应用程序;但所有我是返回字符串信息,而不是我传递的​​参数。是不是有什么毛病我的网络服务或我的肥皂的方法?

香皂:

  

SoapObject请求=新SoapObject(命名空间METHOD_NAME);

  request.addProperty(A,workowr);


    SoapSerializationEnvelope信封=
        新SoapSerializationEnvelope(SoapEnvelope.VER11);
        envelope.dotNet = TRUE;
        envelope.setOutputSoapObject(要求);
        HttpTransportSE androidHttpTransport =新HttpTransportSE(URL);
        尝试 {
            androidHttpTransport.call(SOAP_ACTION,包);
            SoapPrimitive结果=(SoapPrimitive)envelope.getResponse();
            // SoapObject结果=(SoapObject)envelope.getResponse();
            串resultData = result.toString();
            testTV.setText(resultData);

        }
        赶上(例外五)
        {
            testTV.setText(e.getMessage());
        }
 

下面是我简单的.NET Web服务:

  

公共功能getRegInfo(一BYVAL作为字符串)作为字符串

     

返回A +字符串消息

     

端功能

我会AP preciate任何帮助。

解决方案

什么工作对我来说是改变我的两个.NET Web服务上,在我的应用程序的命名空间网址。

例如,我有:

http://www.example.com/webservices/

我更改为:

example.com/webservices /

在web项目中使用KSOAP2调用WebService

和它的工作完美。

试试看。

I've seen topics discussing this but no one has seemed to post a solution. At the moment, I'm testing passing parameters to my .Net web service. When the parameters reach the web service it adds it with an additional string then returns it too my application; but all I'm returning is the string message, not the parameter I passed. Is there something wrong with my web service or my soap method?

Soap:

SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);

    request.addProperty("A", "workowr");


    SoapSerializationEnvelope envelope =
        new SoapSerializationEnvelope(SoapEnvelope.VER11);
        envelope.dotNet = true;
        envelope.setOutputSoapObject(request);
        HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);    
        try {
            androidHttpTransport.call(SOAP_ACTION, envelope);
            SoapPrimitive result = (SoapPrimitive) envelope.getResponse();
            //SoapObject result = (SoapObject)envelope.getResponse();       
            String resultData = result.toString();
            testTV.setText(resultData);

        }
        catch(Exception e)
        {
            testTV.setText(e.getMessage());
        }

Here is my simple .Net web service:

Public Function getRegInfo(ByVal A As String) As String

Return A + "String message"

End Function

I would appreciate any help.

解决方案

What worked for me was changing the namespace URL in both my .Net webservice and in my application.

For example, I had:

"http://www.example.com/webservices/"

i changed to:

"example.com/webservices/"

and it worked perfectly.

Give it a shot.