我很难用SoapRequest来查看生成的XML.这是我的代码:
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
PropertyInfo propInfo=new PropertyInfo();
propInfo.setName("arg0");
propInfo.setType(PropertyInfo.STRING_CLASS);
propInfo.setValue(sessionId);
request.addProperty(propInfo);
// Sending the array representing our board:
Fields fieldsVector = new Fields();
for (int i=0; i<65; i++) {
fieldsVector.add(move[i].toString());
}
PropertyInfo fieldsPropertyInfo = new PropertyInfo();
fieldsPropertyInfo.setName("fields");
fieldsPropertyInfo.setValue(fieldsVector);
fieldsPropertyInfo.setType(fieldsVector.getClass());
request.addProperty(fieldsPropertyInfo);
PropertyInfo sessionPropertyInfo = new PropertyInfo();
sessionPropertyInfo.setName("arg0");
sessionPropertyInfo.setType(PropertyInfo.STRING_CLASS);
sessionPropertyInfo.setValue(sessionId);
request.addProperty(sessionPropertyInfo);
envelope.setOutputSoapObject(request);
envelope.addMapping(NAMESPACE, "fields", new Fields().getClass());
HttpTransportSE androidHttpTransport = new HttpTransportSE(WSDL_URL);
// androidHttpTransport.debug = true;
try {
androidHttpTransport.call(SOAP_ACTION, envelope);
} catch (Exception e) { …Run Code Online (Sandbox Code Playgroud) 我从Android客户端连接到我的webservice时遇到问题.在我的MainActivity类中,程序在该行崩溃:
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
Run Code Online (Sandbox Code Playgroud)
问题是定义不是方法名称,而是关于命名空间的东西,但我不知道有什么问题.
GameAndroidUtil:
private static final String NAMESPACE = "http://game.webcentral.pl/";
private static final String SOAP_ACTION = "";
private static final String WSDL_URL = "http://localhost:8080/ReversiGameWS/services/GameWS?wsdl";
Run Code Online (Sandbox Code Playgroud)
主要活动:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
try {
GameAndroidUtil.testGameWS();
} catch (SoapFault e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
Run Code Online (Sandbox Code Playgroud)
我的GameWS.wsdl:
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions targetNamespace="http://game.webcentral.pl" xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:impl="http://game.webcentral.pl" xmlns:intf="http://game.webcentral.pl" xmlns:tns1="http://data.game.webcentral.pl" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<!--WSDL created by Apache Axis version: 1.4
Built on Apr 22, 2006 (06:55:48 …Run Code Online (Sandbox Code Playgroud)