Android:关于ksoap2和webservice

发布于 2024-12-04 10:24:05 字数 122 浏览 4 评论 0原文

我得到了wsdl和URL,服务器是用C++编写的; 我在android中使用KSoap2来访问该方法,但它总是 打印出:“方法'methodname'未实现”!!! 有人可以帮我吗? 提前致谢!

I get the wsdl and the URL,and the server is written in C++;
I use KSoap2 in android to access the method ,but it always
prints out :"Method 'methodname' not implemented"!!!
Can anyone help me out?
Thanks in advance!

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

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

发布评论

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

评论(4

下壹個目標 2024-12-11 10:24:05

您是否正确创建了请求和 SoapAction

尝试下面的示例(它是一个带有 0 个参数的公共 Web 服务),看看它是否适合您。

private static final String WSDL_URL = "http://wsf.cdyne.com/WeatherWS/Weather.asmx?WSDL";
private static final String WS_NAMESPACE = "http://ws.cdyne.com/WeatherWS/";
private static final String WS_METHOD_NAME = "GetWeatherInformation";

// 1. Creating SOAP request with no arguments
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.setOutputSoapObject(new SoapObject(WS_NAMESPACE, WS_METHOD_NAME));

// 2. Create a HTTP Transport object to send the web service request
HttpTransportSE httpTransport = new HttpTransportSE(WSDL_URL);
httpTransport.debug = true; // allows capture of raw request/respose in Logcat

// 3. Make the web service invocation
httpTransport.call(WS_NAMESPACE + WS_METHOD_NAME, envelope);

Log.d(TAG, "HTTP REQUEST:\n" + httpTransport.requestDump);
Log.d(TAG, "HTTP RESPONSE:\n" + httpTransport.responseDump);

看看这个详细的教程,解释 的基础知识在 Android 中使用 kSOAP2

Are you creating your request and the SoapAction properly?

Try the example below (it is a public web service with 0 arguments) and see if it works for you.

private static final String WSDL_URL = "http://wsf.cdyne.com/WeatherWS/Weather.asmx?WSDL";
private static final String WS_NAMESPACE = "http://ws.cdyne.com/WeatherWS/";
private static final String WS_METHOD_NAME = "GetWeatherInformation";

// 1. Creating SOAP request with no arguments
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.setOutputSoapObject(new SoapObject(WS_NAMESPACE, WS_METHOD_NAME));

// 2. Create a HTTP Transport object to send the web service request
HttpTransportSE httpTransport = new HttpTransportSE(WSDL_URL);
httpTransport.debug = true; // allows capture of raw request/respose in Logcat

// 3. Make the web service invocation
httpTransport.call(WS_NAMESPACE + WS_METHOD_NAME, envelope);

Log.d(TAG, "HTTP REQUEST:\n" + httpTransport.requestDump);
Log.d(TAG, "HTTP RESPONSE:\n" + httpTransport.responseDump);

Have a look at this detailed tutorial explaining the basics of using kSOAP2 with Android

哀由 2024-12-11 10:24:05

请参阅此处 ksoap 的简单示例可能会有所帮助 http://vimeo.com/9633556

see here the simple example of ksoap may help http://vimeo.com/9633556

浪荡不羁 2024-12-11 10:24:05
private static final String NAMESPACE = "http://tempuri.org/";
private static final String URL = "http://216.128.29.26/webservices/TempConvert.asmx";
private static final String SOAP_ACTION = "http://tempuri.org/CelsiusToFahrenheit";
private static final String METHOD_NAME = "CelsiusToFahrenheit"

您应该如上所述指定必要的字段。

private static final String NAMESPACE = "http://tempuri.org/";
private static final String URL = "http://216.128.29.26/webservices/TempConvert.asmx";
private static final String SOAP_ACTION = "http://tempuri.org/CelsiusToFahrenheit";
private static final String METHOD_NAME = "CelsiusToFahrenheit"

you should specify necessary field as above.

带上头具痛哭 2024-12-11 10:24:05
private static final String NAMESPACE = "http://tempuri.org/";
private static final String URL = "http://216.128.29.26/webservices/TempConvert.asmx";
private static final String SOAP_ACTION = "http://tempuri.org/CelsiusToFahrenheit";
private static final String METHOD_NAME = "CelsiusToFahrenheit";

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    TextView tv;
    tv = (TextView) findViewById(R.id.tv);
    tv.setText(ws());
}
public String ws() {
    String result = "";
    try
    {
        SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
        request.addProperty("Celsius", "32");

        SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
                SoapEnvelope.VER11);

        envelope.dotNet = true;

        envelope.setOutputSoapObject(request);

        HttpTransportSE ht = new HttpTransportSE(URL);
        ht.call(SOAP_ACTION, envelope);

        if(envelope.getResponse()!=null){
            SoapPrimitive response = (SoapPrimitive) envelope.getResponse();
            result = "FeranHit : " + response.toString();
        }   
    }
    catch (Exception e) 
    {
        result = e.getMessage();
    }
    return result;
}

看看这是我的代码。我得到了完整的结果。这只是 ksoap2 的测试程序。

我这里没有包含任何库。

private static final String NAMESPACE = "http://tempuri.org/";
private static final String URL = "http://216.128.29.26/webservices/TempConvert.asmx";
private static final String SOAP_ACTION = "http://tempuri.org/CelsiusToFahrenheit";
private static final String METHOD_NAME = "CelsiusToFahrenheit";

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    TextView tv;
    tv = (TextView) findViewById(R.id.tv);
    tv.setText(ws());
}
public String ws() {
    String result = "";
    try
    {
        SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
        request.addProperty("Celsius", "32");

        SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
                SoapEnvelope.VER11);

        envelope.dotNet = true;

        envelope.setOutputSoapObject(request);

        HttpTransportSE ht = new HttpTransportSE(URL);
        ht.call(SOAP_ACTION, envelope);

        if(envelope.getResponse()!=null){
            SoapPrimitive response = (SoapPrimitive) envelope.getResponse();
            result = "FeranHit : " + response.toString();
        }   
    }
    catch (Exception e) 
    {
        result = e.getMessage();
    }
    return result;
}

see this is my code. and m getting full result. This is just test program for ksoap2.

i have not included any libraries here.

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