我正在尝试从我的 android 应用程序调用 web 服务。我的 logcat 出现以下错误。我的网络服务工作正常,因为我可以从 java 客户端调用方法。
Error in logcat:
06-13 13:19:47.585: I/System.out(1317): validateUserAndReturnDashBoard
06-13 13:19:48.143: D/dalvikvm(1317): GC_CONCURRENT freed 256K, 9% free 4147K/4520K, paused 85ms+106ms, total 327ms
06-13 13:19:48.143: D/dalvikvm(1317): WAIT_FOR_CONCURRENT_GC blocked 22ms
06-13 13:19:48.333: I/System.out(1317): Retrieving document at ''.
06-13 13:19:49.243: D/dalvikvm(1317): GC_CONCURRENT freed 400K, 11% free 4250K/4768K, paused 100ms+104ms, total 308ms
06-13 13:19:49.263: I/System.out(1317): Retrieving schema at '../gw/xsd/guidewire/soapheaders.xsd', relative to 'xxxx://xxx.xxx.x.x:8080/cc/ws/com/LoginAppAPI?WSDL'.
06-13 13:19:49.703: I/System.out(1317): Full Request XML Is <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:ws="null" ><soap:Header/><soap:Body><ws:validateUserAndReturnDashBoard></ws:validateUserAndReturnDashBoard></soap:Body></soap:Envelope>
06-13 13:19:49.703: I/System.out(1317): Response Class: com.example.com.loginappapi.ValidateUserAndReturnDashBoardResponse
06-13 13:19:50.134: I/System.out(1317): Status 200
06-13 13:19:50.134: I/System.out(1317): WSInvocationHandler: Status 200
06-13 13:19:50.154: I/System.out(1317): WSInvocationHandler: Response: <?xml version="1.0"?>
06-13 13:19:50.154: I/System.out(1317): <soap12:Envelope xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
06-13 13:19:50.154: I/System.out(1317): <soap12:Body>
06-13 13:19:50.154: I/System.out(1317): <soap12:Fault>
06-13 13:19:50.154: I/System.out(1317): <soap12:Code>
06-13 13:19:50.154: I/System.out(1317): <soap12:Value>soap12:Sender</soap12:Value>
06-13 13:19:50.154: I/System.out(1317): </soap12:Code>
06-13 13:19:50.154: I/System.out(1317): <soap12:Reason>
06-13 13:19:50.163: I/System.out(1317): <soap12:Text xml:lang="">No such operation {null}validateUserAndReturnDashBoard in service com.LoginAppAPI</soap12:Text>
06-13 13:19:50.163: I/System.out(1317): </soap12:Reason>
06-13 13:19:50.186: I/System.out(1317): </soap12:Fault>
06-13 13:19:50.186: I/System.out(1317): </soap12:Body>
06-13 13:19:50.186: I/System.out(1317): </soap12:Envelope>
06-13 13:19:50.186: I/System.out(1317): ReflectionHelper*java.lang.NoSuchFieldException: return
06-13 13:19:50.193: I/System.out(1317): FieldnameFound for return
06-13 13:19:50.193: I/System.out(1317): ReflectionHelper*java.lang.NoSuchFieldException: return
06-13 13:19:50.206: I/System.out(1317): ReflectionHelper*java.lang.NoSuchFieldException: code
06-13 13:19:50.213: W/System.err(1317): org.jinouts.ws.exception.FieldNotMatchedException
06-13 13:19:50.226: W/System.err(1317): at hu.javaforum.commons.ReflectionHelper.getFieldClass(ReflectionHelper.java:504)
06-13 13:19:50.246: W/System.err(1317): at hu.javaforum.android.androidsoap.GenericHandler.startElement(GenericHandler.java:345)
06-13 13:19:50.246: W/System.err(1317): at hu.javaforum.android.androidsoap.GenericHandler.parseWithPullParser(GenericHandler.java:243)
06-13 13:19:50.246: W/System.err(1317): at org.jinouts.ws.WSInvocationHandler.invoke(WSInvocationHandler.java:99)
06-13 13:19:50.253: W/System.err(1317): at $Proxy0.validateUserAndReturnDashBoard(Native Method)
06-13 13:19:50.253: W/System.err(1317): at com.example.myfirstapp.LoginActivity$1.onClick(LoginActivity.java:64)
06-13 13:19:50.266: W/System.err(1317): at android.view.View.performClick(View.java:4204)
06-13 13:19:50.273: W/System.err(1317): at android.view.View$PerformClick.run(View.java:17355)
06-13 13:19:50.273: W/System.err(1317): at android.os.Handler.handleCallback(Handler.java:725)
06-13 13:19:50.273: W/System.err(1317): at android.os.Handler.dispatchMessage(Handler.java:92)
06-13 13:19:50.289: W/System.err(1317): at android.os.Looper.loop(Looper.java:137)
06-13 13:19:50.294: W/System.err(1317): at android.app.ActivityThread.main(ActivityThread.java:5041)
06-13 13:19:50.294: W/System.err(1317): at java.lang.reflect.Method.invokeNative(Native Method)
06-13 13:19:50.294: W/System.err(1317): at java.lang.reflect.Method.invoke(Method.java:511)
06-13 13:19:50.313: W/System.err(1317): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
06-13 13:19:50.313: W/System.err(1317): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
06-13 13:19:50.333: W/System.err(1317): at dalvik.system.NativeStart.main(Native Method)
06-13 13:19:50.333: I/System.out(1317): ReflectionHelper*java.lang.NoSuchFieldException: value
06-13 13:19:50.346: W/System.err(1317): org.jinouts.ws.exception.FieldNotMatchedException
06-13 13:19:50.353: W/System.err(1317): at hu.javaforum.commons.ReflectionHelper.getFieldClass(ReflectionHelper.java:504)
06-13 13:19:50.353: W/System.err(1317): at hu.javaforum.android.androidsoap.GenericHandler.startElement(GenericHandler.java:345)
06-13 13:19:50.366: W/System.err(1317): at hu.javaforum.android.androidsoap.GenericHandler.parseWithPullParser(GenericHandler.java:243)
06-13 13:19:50.366: W/System.err(1317): at org.jinouts.ws.WSInvocationHandler.invoke(WSInvocationHandler.java:99)
06-13 13:19:50.373: W/System.err(1317): at $Proxy0.validateUserAndReturnDashBoard(Native Method)
06-13 13:19:50.373: W/System.err(1317): at com.example.myfirstapp.LoginActivity$1.onClick(LoginActivity.java:64)
06-13 13:19:50.393: W/System.err(1317): at android.view.View.performClick(View.java:4204)
06-13 13:19:50.393: W/System.err(1317): at android.view.View$PerformClick.run(View.java:17355)
06-13 13:19:50.413: W/System.err(1317): at android.os.Handler.handleCallback(Handler.java:725)
06-13 13:19:50.413: W/System.err(1317): at android.os.Handler.dispatchMessage(Handler.java:92)
06-13 13:19:50.413: W/System.err(1317): at android.os.Looper.loop(Looper.java:137)
06-13 13:19:50.413: W/System.err(1317): at android.app.ActivityThread.main(ActivityThread.java:5041)
06-13 13:19:50.433: W/System.err(1317): at java.lang.reflect.Method.invokeNative(Native Method)
06-13 13:19:50.446: W/System.err(1317): at java.lang.reflect.Method.invoke(Method.java:511)
06-13 13:19:50.446: W/System.err(1317): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
06-13 13:19:50.466: W/System.err(1317): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
06-13 13:19:50.466: W/System.err(1317): at dalvik.system.NativeStart.main(Native Method)
06-13 13:19:50.473: W/System.err(1317): java.lang.ArrayIndexOutOfBoundsException: length=12; index=-1
06-13 13:19:50.493: W/System.err(1317): at java.util.ArrayList.remove(ArrayList.java:401)
06-13 13:19:50.493: W/System.err(1317): at hu.javaforum.android.androidsoap.GenericHandler.endElement(GenericHandler.java:468)
06-13 13:19:50.513: W/System.err(1317): at hu.javaforum.android.androidsoap.GenericHandler.parseWithPullParser(GenericHandler.java:266)
06-13 13:19:50.513: W/System.err(1317): at org.jinouts.ws.WSInvocationHandler.invoke(WSInvocationHandler.java:99)
06-13 13:19:50.526: W/System.err(1317): at $Proxy0.validateUserAndReturnDashBoard(Native Method)
06-13 13:19:50.526: W/System.err(1317): at com.example.myfirstapp.LoginActivity$1.onClick(LoginActivity.java:64)
06-13 13:19:50.526: W/System.err(1317): at android.view.View.performClick(View.java:4204)
06-13 13:19:50.546: W/System.err(1317): at android.view.View$PerformClick.run(View.java:17355)
06-13 13:19:50.546: W/System.err(1317): at android.os.Handler.handleCallback(Handler.java:725)
06-13 13:19:50.546: W/System.err(1317): at android.os.Handler.dispatchMessage(Handler.java:92)
06-13 13:19:50.566: W/System.err(1317): at android.os.Looper.loop(Looper.java:137)
06-13 13:19:50.573: W/System.err(1317): at android.app.ActivityThread.main(ActivityThread.java:5041)
06-13 13:19:50.573: W/System.err(1317): at java.lang.reflect.Method.invokeNative(Native Method)
06-13 13:19:50.573: W/System.err(1317): at java.lang.reflect.Method.invoke(Method.java:511)
06-13 13:19:50.573: W/System.err(1317): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
06-13 13:19:50.573: W/System.err(1317): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
06-13 13:19:50.586: W/System.err(1317): at dalvik.system.NativeStart.main(Native Method)
MY code which is calling webservice inside onClick method:
StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder()
.detectDiskReads()
.detectDiskWrites()
.detectNetwork() // or .detectAll() for all detectable problems
.penaltyLog()
.build());
StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder()
.detectLeakedSqlLiteObjects()
.detectLeakedClosableObjects()
.penaltyLog()
.penaltyDeath()
.build());
Log.i("XXXXXXXXXXXXXXXXXXXXXXXXX","");
LoginAppAPI a = new LoginAppAPI();
LoginAppAPIPortType port = a.getLoginAppAPISoap11Port();
Log.i("PPPPPPPPPPPPPPPPP","");
Log.i("YYYYYYYYYYYYYYYYYYYYYYYY", port.validateUserAndReturnDashBoard ());
此代码在 java 客户端中运行良好,唯一的问题是 Android 应用程序
package com.example.myfirstapp;
import org.jinouts.xml.ws.BindingProvider;
import com.example.com.loginappapi.LoginAppAPI;
import com.example.com.loginappapi.LoginAppAPIPortType;
import android.app.Activity;
import android.content.Intent;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.StrictMode;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
//.import com.ws.*;
public class LoginActivity extends Activity {
/** Called when the activity is first created. */
EditText username, password;
Button login;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// setting default screen to login.xml
setContentView(R.layout.login);
username = (EditText) findViewById(R.id.usrname);
password = (EditText) findViewById(R.id.passcode);
login = (Button) findViewById(R.id.btnLogin);
login.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
if (username.getText().toString().equals("rox")
&& password.getText().toString().equals("gw")) {
// responding to the User inputs
Log.i("ABC", "roshan");
Toast.makeText(getApplicationContext(),
"Login Successfully !!!", Toast.LENGTH_LONG).show();
Intent i = new Intent(LoginActivity.this, Dashboard.class);
startActivity(i);
} else {
try {
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder()
.permitAll().build();
StrictMode.setThreadPolicy(policy);
LoginAppAPI api = new LoginAppAPI();
Log.i("XXXXXXXXXXXXX", api.toString());
LoginAppAPIPortType port = api
.getLoginAppAPISoap12Port();
// BindingProvider prov = (BindingProvider)port;
// prov.getRequestContext().put(BindingProvider.USERNAME_PROPERTY,
// "su");
// prov.getRequestContext().put(BindingProvider.PASSWORD_PROPERTY,
// "gw");
// Log.i("ssssssssssssssssss", port.toString());
Log.i("YYYYYYYYYYYYYYYYYYYYYYYY",
port.validateUserAndReturnDashBoard());
Intent i = new Intent(LoginActivity.this,
ListViewSample.class);
startActivity(i);
} catch (Exception e) {
Log.i("errrrorrrrr", e.getMessage());
}
}
}
});
}
}