ネストされたパラメーターを使用して SoapObject を送信しようとしていますが、kSOAP のガイドラインに従っているにもかかわらず、エラーが発生しています...
ネストされたパラメーターなしで SoapObject を送信しても問題はありませんが、ネストされたパラメーターを送信する必要があるとすぐにクラッシュします.... (唯一の違いはネストされたパラメーターです)...
リクエストの設定方法は次のとおりです。
void connection()
{
Singleton service = Singleton.getInstance();
String firstURL = service.getURL();
URL = firstURL + "Attendance.svc";
//Get parentID, parentToken
String parentIDSingleton = service.getParentID();
String parentTokenSingleton = service.getParentToken();
//Get current time for GMT
Calendar c = Calendar.getInstance();
//Set format
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
//Save in string
String formattedDate = df.format(c.getTime());
//Initialize soap request
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
SoapObject nestedParameters = new SoapObject(NAMESPACE, "planInfos");
//Add parameters
request.addProperty("nAttendeeId", "*some value");
//Add nested parameters
nestedParameters.addProperty("day:Date", formattedDate);
nestedParameters.addProperty("day:PlannedStatus", "Syg");
request.addSoapObject(nestedParameters);
//Declare the version of the SOAP request
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet=true;
envelope.implicitTypes=true;
envelope.setAddAdornments(false);
//Prepare request
envelope.setOutputSoapObject(request);
//Set up the header
Element parentID = new Element().createElement("ns", "parentId");
parentID.addChild(Node.TEXT, parentIDSingleton);
Element parentToken = new Element().createElement("ns", "parentToken");
parentToken.addChild(Node.TEXT, parentTokenSingleton);
Element authType = new Element().createElement("ns", "authType");
authType.addChild(Node.TEXT, "Parent");
Element kindergardenID = new Element().createElement("ns", "id");
kindergardenID.addChild(Node.TEXT, "1");
//Add the header
Element header[] = {parentID, parentToken, authType, kindergardenID};
envelope.headerOut = header;
//Needed to make the internet call
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
//Allow for debugging - needed to output the request
androidHttpTransport.debug = true;
try
{
//this is the actual part that will call the web service
androidHttpTransport.call(SOAP_ACTION, envelope);
//Get the SoapResult from the envelope body.
SoapObject sResult = (SoapObject)envelope.bodyIn;
} catch(org.xmlpull.v1.XmlPullParserException ex2)
{
System.out.println(androidHttpTransport.requestDump.toString());
} catch (Exception e)
{
e.printStackTrace();
System.out.println(androidHttpTransport.requestDump.toString());
}
}
kSOAP2 Web サイトでは、ネストされたパラメーターを次のように設定するように言われています。
SoapObject users = new SoapObject(NAMESPACE, "users");
SoapObject john = new SoapObject(NAMESPACE, "user");
john.addProperty("name", "john");
john.addProperty("age", 12);
SoapObject marie = new SoapObject(NAMESPACE, "user");
john.addProperty("name", "marie");
john.addProperty("age", 27);
users.addSoapObject(john);
users.addSoapObject(marie);
それは私がすることです...
何か案は???
私が得ているエラー:
05-03 10:46:45.313: W/System.err(1855): java.net.UnknownHostException: kindergardentest.sms2go.dk 05-03 10:46:45.329: W/System.err(1855): Java で。 net.InetAddress.lookupHostByName(InetAddress.java:506) 05-03
10:46:45.329: W/System.err(1855): java.net.InetAddress.getAllByNameImpl (InetAddress.java:294) 05-03 で
10:46:45.329: W/System.err(1855): java.net.InetAddress.getAllByName (InetAddress.java:256) 05-03 で
10:46:45.329: W/System.err(1855): org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnection.(HttpConnection.java:69) で
05-03 10:46:45.347: W/System.err(1855): org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnection.(HttpConnection.java:48) で
05-03 10:46:45.347: W/System.err(1855): org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnection$Address.connect(HttpConnection.java:322) で
05-03 10:46:45.347: W/System.err(1855): org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnectionPool.get(HttpConnectionPool.java:89) で
05-03 10:46:45.347: W/System.err(1855): org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.getHttpConnection(HttpURLConnectionImpl.java:285) で
05-03 10:46:45.347: W/System.err(1855): org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.makeConnection(HttpURLConnectionImpl.java:267) で
05-03 10:46:45.347: W/System.err(1855): org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:205) で
05-03 10:46:45.371: W/System.err (1855): org.ksoap2.transport.ServiceConnectionSE.connect (ServiceConnectionSE.java:76) で
05-03 10:46:45.371: W/System.err (1855): org.ksoap2.transport.HttpTransportSE.call (HttpTransportSE.java:153) で
05-03 10:46:45.371: W/System.err(1855): org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:95) で
05-03 10:46:45.371: W/System.err (1855): com.cim.daycare.AuthenticateConnection.connection (AuthenticateConnection.java:74) で
05-03 10:46:45.377: W/System.err(1855): com.cim.daycare.DayCareActivity$AuthenticateUser.doInBackground (DayCareActivity.java:308) で
05-03 10:46:45.377: W/System.err(1855): com.cim.daycare.DayCareActivity$AuthenticateUser.doInBackground (DayCareActivity.java:1) で
05-03 10:46:45.377: W/System.err(1855): android.os.AsyncTask$2.call(AsyncTask.java:185) で 05-03 10:46:45.377: W/System.err(1855) ): java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:306) で
05-03 10:46:45.377: W/System.err(1855): java.util.concurrent.FutureTask.run (FutureTask.java:138) 05-03 で
10:46:45.377: W/System.err(1855): java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1088) で
05-03 10:46:45.388: W/System.err(1855): java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:581) で
05-03 10:46:45.388: W/System.err(1855): java.lang.Thread.run(Thread.java:1019) で 05-03 10:46:45.388:
05-03 10:46:45.407: W/dalvikvm(1855): threadid=9: キャッチされない例外で終了するスレッド (グループ = 0x40015560)
05-03 10:46:45.420: E/AndroidRuntime(1855): 致命的な例外: AsyncTask #1 05-03
10:46:45.420: E/AndroidRuntime(1855): java.lang.RuntimeException: doInBackground() の実行中にエラーが発生しました
05-03 10:46:45.420: E/AndroidRuntime(1855): android.os.AsyncTask$3.done(AsyncTask.java:200)
05-03 10:46:45.420: E/AndroidRuntime (1855): java.util.concurrent.FutureTask$Sync.innerSetException (FutureTask.java:274) で
05-03 10:46:45.420: E/AndroidRuntime (1855): java.util.concurrent.FutureTask.setException (FutureTask.java:125) で
05-03 10:46:45.420: E/AndroidRuntime (1855): java.util.concurrent.FutureTask$Sync.innerRun (FutureTask.java:308) で
05-03 10:46:45.420: E/AndroidRuntime (1855): java.util.concurrent.FutureTask.run で (FutureTask.java:138) 05-03
10:46:45.420: E/AndroidRuntime(1855): java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1088) で
05-03 10:46:45.420: E/AndroidRuntime(1855): java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:581) で
05-03 10:46:45.420: E/AndroidRuntime(1855): java.lang.Thread.run(Thread.java:1019) 05-03 10:46:45.420: E/AndroidRuntime(1855): 原因: java.lang.NullPointerException
05-03 10:46:45.420: E/AndroidRuntime (1855): com.cim.daycare.DayCareActivity$AuthenticateUser.doInBackground (DayCareActivity.java:311) で
05-03 10:46:45.420: E/AndroidRuntime (1855): com.cim.daycare.DayCareActivity$AuthenticateUser.doInBackground (DayCareActivity.java:1) で
05-03 10:46:45.420: E/AndroidRuntime(1855): android.os.AsyncTask$2.call(AsyncTask.java:185)
05-03 10:46:45.420: E/AndroidRuntime (1855): java.util.concurrent.FutureTask$Sync.innerRun (FutureTask.java:306) で
05-03 10:46:45.420: E/AndroidRuntime(1855): ... 4 つ以上 05-03
10:46:47.697: E/WindowManager(1855): アクティビティ com.cim.daycare.DayCareActivity が、最初にここに追加されたウィンドウ com.android.internal.policy.impl.PhoneWindow$DecorView@40517918 をリークしました
05-03 10:46:47.697: E/WindowManager(1855): android.view.WindowLeaked: アクティビティ com.cim.daycare.DayCareActivity がウィンドウ com.android.internal.policy.impl.PhoneWindow$DecorView@40517918 をリークしました。最初にここに追加されました
05-03 10:46:47.697: E/WindowManager(1855): android.view.ViewRoot で。(ViewRoot.java:258) 05-03
10:46:47.697: E/WindowManager(1855): android.view.WindowManagerImpl.addView(WindowManagerImpl.java:148) で
05-03 10:46:47.697: E/WindowManager(1855): android.view.WindowManagerImpl.addView(WindowManagerImpl.java:91) で
05-03 10:46:47.697: E/WindowManager(1855): android.view.Window$LocalWindowManager.addView(Window.java:424) 05-03 で
10:46:47.697: E/WindowManager(1855): android.app.Dialog.show(Dialog.java:241) で
05-03 10:46:47.697: E/WindowManager(1855): android.app.ProgressDialog.show(ProgressDialog.java:107) 05-03
10:46:47.697: E/WindowManager(1855): android.app.ProgressDialog.show(ProgressDialog.java:90) 05-03
10:46:47.697: E/WindowManager (1855): com.cim.daycare.DayCareActivity$AuthenticateUser.onPreExecute (DayCareActivity.java:295) で
05-03 10:46:47.697: E/WindowManager (1855): android.os.AsyncTask.execute (AsyncTask.java:391) で
05-03 10:46:47.697: E/WindowManager (1855): com.cim.daycare.DayCareActivity.onCreate (DayCareActivity.java:154) で
05-03 10:46:47.697: E/WindowManager (1855): android.app.Instrumentation.callActivityOnCreate (Instrumentation.java:1047) で
05-03 10:46:47.697: E/WindowManager (1855): android.app.ActivityThread.performLaunchActivity (ActivityThread.java:1611) で
05-03 10:46:47.697: E/WindowManager (1855): android.app.ActivityThread.handleLaunchActivity (ActivityThread.java:1663) で
05-03 10:46:47.697: E/WindowManager(1855): android.app.ActivityThread.access$1500 で (ActivityThread.java:117) 05-03
10:46:47.697: E/WindowManager(1855): android.app.ActivityThread$H.handleMessage(ActivityThread.java:931) で
05-03 10:46:47.697: E/WindowManager(1855): android.os.Handler.dispatchMessage(Handler.java:99) 05-03 で
10:46:47.697: E/WindowManager(1855): android.os.Looper.loop(Looper.java:123)
05-03 10:46:47.697: E/WindowManager(1855): android.app.ActivityThread.main(ActivityThread.java:3683) 05-03 で
10:46:47.697: E/WindowManager(1855): java.lang.reflect.Method.invokeNative(ネイティブ メソッド) 05-03 で
10:46:47.697: E/WindowManager(1855): java.lang.reflect.Method.invoke(Method.java:507) で
05-03 10:46:47.697: E/WindowManager(1855): com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839) で
05-03 10:46:47.697: E/WindowManager (1855): com.android.internal.os.ZygoteInit.main (ZygoteInit.java:597) 05-03 で
10:46:47.697: E/WindowManager(1855): dalvik.system.NativeStart.main (ネイティブ メソッド) で