SoapAction 和 Web 服务不起作用

发布于 2024-12-26 20:38:55 字数 1831 浏览 1 评论 0原文

大家好,我正在做一个应用程序,我需要来自网络服务的一些信息,我写了这段代码:

package messinaline.matteo.app;

import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransportSE;

import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;

public class MessinaAppActivity extends Activity {
private static final String SOAP_ACTION = "FINDPORT";
private static final String METHOD_NAME = "FINDPORTRequest";
private static final String NAMESPACE = "urn:DefaultNamespace";
private static final String URL = "http://apps.messinaline.it:80/TestWSDL.nsf/CheckNaveNew?OpenWebService";
private Object resultRequestSOAP = null;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    TextView tv = (TextView) findViewById(R.id.webservice);

    SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);

    // SoapObject
    request.addProperty("SHIP", "Jolly Blu");
    request.addProperty("XDATE", "15/01/2012");
    SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER12);
    envelope.setOutputSoapObject(request);

    HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
    try {
        androidHttpTransport.call(SOAP_ACTION, envelope);
        String[] resultsRequestSOAP = (String[]) envelope.getResponse();
        tv.setText(resultsRequestSOAP[0]);
    } catch (Exception aE) {
        aE.printStackTrace();
        tv.setText("don't work");
    }
}
}

我在这里找到了这段代码 http://www.anddev.org/calling_a_web_service_from_android-t348.html TextView 显示“不起作用”?为什么 ?非常感谢你

Hello everybody i'm doing an application and I need some information from a web service and I wrote this code:

package messinaline.matteo.app;

import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransportSE;

import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;

public class MessinaAppActivity extends Activity {
private static final String SOAP_ACTION = "FINDPORT";
private static final String METHOD_NAME = "FINDPORTRequest";
private static final String NAMESPACE = "urn:DefaultNamespace";
private static final String URL = "http://apps.messinaline.it:80/TestWSDL.nsf/CheckNaveNew?OpenWebService";
private Object resultRequestSOAP = null;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    TextView tv = (TextView) findViewById(R.id.webservice);

    SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);

    // SoapObject
    request.addProperty("SHIP", "Jolly Blu");
    request.addProperty("XDATE", "15/01/2012");
    SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER12);
    envelope.setOutputSoapObject(request);

    HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
    try {
        androidHttpTransport.call(SOAP_ACTION, envelope);
        String[] resultsRequestSOAP = (String[]) envelope.getResponse();
        tv.setText(resultsRequestSOAP[0]);
    } catch (Exception aE) {
        aE.printStackTrace();
        tv.setText("don't work");
    }
}
}

I found this code here http://www.anddev.org/calling_a_web_service_from_android-t348.html
The TextView show me "don't work" ? Why ? Thankyou sooo much

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

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

发布评论

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

评论(1

面如桃花 2025-01-02 20:38:55

以防万一:不要忘记将其添加到您的清单中。

<uses-permission xmlns:android="http://schemas.android.com/apk/res/android" android:name="android.permission.INTERNET"></uses-permission>

Just in case : do not forget to add this to your manifest.

<uses-permission xmlns:android="http://schemas.android.com/apk/res/android" android:name="android.permission.INTERNET"></uses-permission>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文