![](/img/trans.png)
[英]KSOAP2 - envelope.bodyIn or envelop.getResponse() giving a soap fault
[英]SOAP envelope for ksoap lib
我为sharepoint编写了android客户端,并使用ksoap2-android-assembly-2.5.8 lib。 我有下一个代码:
public class AndroidWSDLKActivity extends Activity {
private static final String NAMESPACE = "http://schemas.microsoft.com/sharepoint/soap/";
private static final String URL = "http://192.168.0.193:30004/SPMobApp/_vti_bin/lists.asmx";
private static final String SOAP_ACTION = "http://schemas.microsoft.com/sharepoint/soap/GetList";
private static final String METHOD_NAME = "GetList";
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
TextView lblResult = (TextView) findViewById(R.id.result);
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
// Set all input params
request.addProperty("listName", "Tasks");
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
// Enable the below property if consuming .Net service
envelope.dotNet = true;
envelope.setOutputSoapObject(request);
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
try
{
List<HeaderProperty> headerList = new ArrayList<HeaderProperty>();
String authentication = android.util.Base64.encodeToString("LOGIN:PASS".getBytes(), android.util.Base64.NO_WRAP);
headerList.add(new HeaderProperty("Authorization", "Basic " + authentication));
androidHttpTransport.call(SOAP_ACTION, envelope);
SoapObject response = (SoapObject)envelope.getResponse();
lblResult.setText(response.getProperty(0).toString());
}
catch(Exception e)
{
lblResult.setText(e.getStackTrace().toString());
}
在这一步
SoapObject response =(SoapObject)envelope.getResponse();
在调试模式下,我有2个错误
语法错误,插入“ AssignmentOperator表达式”以完成分配
语法错误,插入“;” 完成BlockStatement
怎么了? 救救我,PLZ
public class AndroidWSDLKActivity extends Activity
{
private static final String NAMESPACE = "http://schemas.microsoft.com/sharepoint/soap/";
private static final String URL = "http://192.168.0.193:30004/SPMobApp/_vti_bin/lists.asmx";
private static final String SOAP_ACTION = "http://schemas.microsoft.com/sharepoint/soap/GetList";
private static final String METHOD_NAME = "GetList";
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
TextView lblResult = (TextView) findViewById(R.id.result);
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
// Set all input params
request.addProperty("listName", "Tasks");
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
// Enable the below property if consuming .Net service
envelope.dotNet = true;
envelope.setOutputSoapObject(request);
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
try
{
List<HeaderProperty> headerList = new ArrayList<HeaderProperty>();
String authentication = android.util.Base64.encodeToString("LOGIN:PASS".getBytes(), android.util.Base64.NO_WRAP);
headerList.add(new HeaderProperty("Authorization", "Basic " + authentication));
androidHttpTransport.call(SOAP_ACTION, envelope);
SoapObject response = (SoapObject)envelope.getResponse();
lblResult.setText(response.getProperty(0).toString());
}
catch(Exception e)
{
lblResult.setText(e.getStackTrace().toString());
}
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.