您好我可以新安卓android我想傳遞一些參數到soap網絡服務,但它在拋出NPE的同時得到response.i在評論哪裏正在獲取NPE。請給我提供了一些解決方案如何將參數傳遞給SOAP Web服務
這裏是我的XML
<soap:Body>
<CreateNewTask xmlns="http://tempuri.org/">
<description>string</description>
<userid>string</userid>
<task>
<Id>guid</Id>
<TaskMessage>string</TaskMessage>
<UserId>guid</UserId>
<AssignTaskTo>guid</AssignTaskTo>
<TaskStatus>boolean</TaskStatus>
<AssignDate>string</AssignDate>
<CompletionDate>dateTime</CompletionDate>
</task>
<assigntoId>string</assigntoId>
<comment>string</comment>
</CreateNewTask>
這裏是我的肥皂
public class New_Task extends AsyncTask<String, Void, String> {
String result = null;
Object resultRequestSOAP = null;
@Override
protected String doInBackground(String... params) {
// TODO Auto-generated method stub
SoapObject request = new SoapObject(NAMESPACE1, METHOD_NAME1);
request.addProperty("description", Singleton.Task_message);
request.addProperty("userid", Singleton.user_id);
request.addProperty("Id", Singleton.user_id);
request.addProperty("TaskMessage", Singleton.Task_message);
request.addProperty("UserId", Singleton.user_id);
request.addProperty("AssignTaskTo", Singleton.user_name);
request.addProperty("TaskStatus", "false");
request.addProperty("AssignDate", "2013-12-18T11:12:08.000");
request.addProperty("CompletionDate", "2013-12-18T11:12:08.000");
request.addProperty("assigntoId", Singleton.user_id);
request.addProperty("comment", comment.getText().toString());
// Declare the version of the SOAP request
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
SoapEnvelope.VER11);
envelope.setOutputSoapObject(request);
envelope.dotNet = true;
try {
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL1);
androidHttpTransport.debug = true;
androidHttpTransport.call(SOAP_ACTION1, envelope);
SoapObject soap_result = (SoapObject) envelope.getResponse();
System.out.println("soap_result " + soap_result);
String requestDumpString = androidHttpTransport.requestDump;
System.out.println("requestDump : " + requestDumpString);
result = soap_result.toString(); // here i am getting NPE
System.out.println("result " + result);
} catch (Exception e) {
e.printStackTrace();
}
return result;
}
}
這裏AsynchTask是我logcat的結果NPE
12-18 13:35:59.052: W/System.err(13924): java.lang.NullPointerException
12-18 13:35:59.062: W/System.err(13924): at com.example.woosuite.Woosuite_NewTask$New_Task.doInBackground(Woosuite_NewTask.java:183)
12-18 13:35:59.062: W/System.err(13924): at com.example.woosuite.Woosuite_NewTask$New_Task.doInBackground(Woosuite_NewTask.java:1)
12-18 13:35:59.062: W/System.err(13924): at android.os.AsyncTask$2.call(AsyncTask.java:287)
12-18 13:35:59.062: W/System.err(13924): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
12-18 13:35:59.062: W/System.err(13924): at java.util.concurrent.FutureTask.run(FutureTask.java:137)
12-18 13:35:59.072: W/System.err(13924): at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
12-18 13:35:59.072: W/System.err(13924): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
12-18 13:35:59.072: W/System.err(13924): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
12-18 13:35:59.072: W/System.err(13924): at java.lang.Thread.run(Thread.java:856)
謝謝而你是用XML發佈的數據有了一些變化S IN提前
有什麼問題?有什麼錯誤? – PankajAndroid
是NPE here「SoapObject soap_result =(SoapObject)envelope.getResponse();」 – Eyes
NPE?什麼是錯誤發佈它,我認爲它肥皂錯誤 – PankajAndroid