これらの情報を取得するには、ユーザーが正しいコードを入力したかどうかを確認する必要があります。助けてください!以下のコードは、私の SOAP がどのように見えるかです。
<retrieveAudioInfoResponse xmlns="http://tempuri.org/">
<retrieveInfoResult>
<Info>
<date>string</date>
<name>string</name>
<id>int</id>
<description>string</description>
<url>string</url>
</Info>
これは、クラスが Web サービスからデータを取得するために行ったことです。
private void retrieveInfo(String code){
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
request.addProperty("code", code);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = true;
envelope.setOutputSoapObject(request);
System.out.println(request);
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
androidHttpTransport.debug = true;
try {
androidHttpTransport.call(SOAP_ACTION, envelope);
SoapObject response = (SoapObject) envelope.getResponse();
infoList = new String[response.getPropertyCount()];
for(int i=0;i<response.getPropertyCount();i++){
infoList[i] = response.getProperty(i).toString();
Log.d("This is the response",infoList[i]);
}
}
catch (Exception e) {
e.printStackTrace();
}
}
マイ Web サービス:
POST /mobile/.../....asmx HTTP/1.1
Host: ...
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://tempuri.org/retrieveInfo"
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<retrieveInfo xmlns="http://tempuri.org/">
<code>string</code>
</retrieveInfo>
</soap:Body>
</soap:Envelope>
HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: length
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<retrieveInfoResponse xmlns="http://tempuri.org/">
<retrieveInfoResult>
<Info>
<date>string</date>
<name>string</name>
<id>int</id>
<description>string</description>
<url>string</url>
</Info>
<Info>
<date>string</date>
<name>string</name>
<id>int</id>
<description>string</description>
<url>string</url>
</Info>
</retrieveInfoResult>
</retrieveInfoResponse>
</soap:Body>
</soap:Envelope>
私が受け取ったエラーは次のとおりです。
01-31 13:15:00.708: D/dalvikvm(13583): GC_FOR_ALLOC freed 85K, 3% free 13108K/13447K, paused 12ms
01-31 13:15:00.713: I/dalvikvm-heap(13583): Grow heap (frag case) to 15.312MB for 2457616-byte allocation
01-31 13:15:00.738: D/dalvikvm(13583): GC_CONCURRENT freed 1K, 3% free 15507K/15879K, paused 2ms+2ms
01-31 13:15:00.788: D/dalvikvm(13583): GC_FOR_ALLOC freed 0K, 3% free 15507K/15879K, paused 13ms
01-31 13:15:00.798: I/dalvikvm-heap(13583): Grow heap (frag case) to 19.476MB for 4367376-byte allocation
01-31 13:15:00.823: D/dalvikvm(13583): GC_CONCURRENT freed 0K, 2% free 19772K/20167K, paused 2ms+2ms
01-31 13:15:00.898: W/System.err(13583): android.os.NetworkOnMainThreadException
01-31 13:15:00.898: W/System.err(13583): at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1099)
01-31 13:15:00.898: W/System.err(13583): at java.net.InetAddress.lookupHostByName(InetAddress.java:391)
01-31 13:15:00.898: W/System.err(13583): at java.net.InetAddress.getAllByNameImpl(InetAddress.java:242)
01-31 13:15:00.903: W/System.err(13583): at java.net.InetAddress.getAllByName(InetAddress.java:220)
01-31 13:15:00.903: W/System.err(13583): at libcore.net.http.HttpConnection.<init>(HttpConnection.java:71)
01-31 13:15:00.903: W/System.err(13583): at libcore.net.http.HttpConnection.<init>(HttpConnection.java:50)
01-31 13:15:00.903: W/System.err(13583): at libcore.net.http.HttpConnection$Address.connect(HttpConnection.java:351)
01-31 13:15:00.903: W/System.err(13583): at libcore.net.http.HttpConnectionPool.get(HttpConnectionPool.java:86)
01-31 13:15:00.903: W/System.err(13583): at libcore.net.http.HttpConnection.connect(HttpConnection.java:128)
01-31 13:15:00.903: W/System.err(13583): at libcore.net.http.HttpEngine.openSocketConnection(HttpEngine.java:308)
01-31 13:15:00.903: W/System.err(13583): at libcore.net.http.HttpEngine.connect(HttpEngine.java:303)
01-31 13:15:00.903: W/System.err(13583): at libcore.net.http.HttpEngine.sendSocketRequest(HttpEngine.java:282)
01-31 13:15:00.903: W/System.err(13583): at libcore.net.http.HttpEngine.sendRequest(HttpEngine.java:232)
01-31 13:15:00.903: W/System.err(13583): at libcore.net.http.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:80)
01-31 13:15:00.903: W/System.err(13583): at org.ksoap2.transport.ServiceConnectionSE.connect(ServiceConnectionSE.java:75)
01-31 13:15:00.903: W/System.err(13583): at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:136)
01-31 13:15:00.903: W/System.err(13583): at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:90)
01-31 13:15:00.903: W/System.err(13583): at com.example.loginws.second.WebServiceCallExample(second.java:80)
01-31 13:15:00.903: W/System.err(13583): at com.example.loginws.second.onCreate(second.java:32)
01-31 13:15:00.908: W/System.err(13583): at android.app.Activity.performCreate(Activity.java:4470)
01-31 13:15:00.908: W/System.err(13583): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1052)
01-31 13:15:00.908: W/System.err(13583): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1931)
01-31 13:15:00.908: W/System.err(13583): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1992)
01-31 13:15:00.908: W/System.err(13583): at android.app.ActivityThread.access$600(ActivityThread.java:127)
01-31 13:15:00.908: W/System.err(13583): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1158)
01-31 13:15:00.908: W/System.err(13583): at android.os.Handler.dispatchMessage(Handler.java:99)
01-31 13:15:00.908: W/System.err(13583): at android.os.Looper.loop(Looper.java:137)
01-31 13:15:00.908: W/System.err(13583): at android.app.ActivityThread.main(ActivityThread.java:4511)
01-31 13:15:00.908: W/System.err(13583): at java.lang.reflect.Method.invokeNative(Native Method)
01-31 13:15:00.908: W/System.err(13583): at java.lang.reflect.Method.invoke(Method.java:511)
01-31 13:15:00.908: W/System.err(13583): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:980)
01-31 13:15:00.908: W/System.err(13583): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:747)
01-31 13:15:00.913: W/System.err(13583): at dalvik.system.NativeStart.main(Native Method)