SoapAction 和 Web 服务不起作用
大家好,我正在做一个应用程序,我需要来自网络服务的一些信息,我写了这段代码:
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
以防万一:不要忘记将其添加到您的清单中。
Just in case : do not forget to add this to your manifest.