上图显示了我已创建的Web服务的WSDL,我将soapAction作为“URN:authentication”身份验证是我的方法名称
我想知道soapAction的url,因为我在使用android连接到webservice时遇到了零点异常。 我使用AXIS 2创建了Web服务。
公共类MainActivity扩展Activity { EditText用户名,密码;
private final String NAMESPACE = "http://nepal.blue_book.com";
private final String URL = "http://192.168.1.104:8088/Blue_Book/services/Login_service?wsdl";
private final String SOAP_ACTION = "urn:authentication";
private final String METHOD_NAME = "authentication";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button login = (Button) findViewById(R.id.btnLogin);
login.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
loginAction();
}
});
}
public void loginAction() {
username = (EditText) findViewById(R.id.textusername);
Password = (EditText) findViewById(R.id.textpassword);
if (username.getText().toString().equals("")) {
Toast.makeText(getApplicationContext(), "Please Enter User Name",
Toast.LENGTH_SHORT).show();
}
else if (Password.getText().toString().equals("")) {
Toast.makeText(getApplicationContext(), "Please Enter Password",
Toast.LENGTH_SHORT).show();
}
else
{
Toast.makeText(getApplicationContext(), "login",
Toast.LENGTH_SHORT).show();
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
EditText userName = (EditText) findViewById(R.id.textusername);
String user_Name = userName.getText().toString();
EditText userPassword = (EditText) findViewById(R.id.textpassword);
String user_Password = userPassword.getText().toString();
Log.i("user name ", user_Name);
Log.i("user password ", user_Password);
//Pass value for userName variable of the web service
PropertyInfo unameProp =new PropertyInfo();
unameProp.setName("userName");//Define the variable name in the web service method
unameProp.setValue(user_Name);//set value for userName variable
unameProp.setType(String.class);//Define the type of the variable
request.addProperty(unameProp);//Pass properties to the variable
//Pass value for Password variable of the web service
PropertyInfo passwordProp =new PropertyInfo();
passwordProp.setName("password");
passwordProp.setValue(user_Password);
passwordProp.setType(String.class);
request.addProperty(passwordProp);
Log.i("request ....", request.toString());
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.setOutputSoapObject(request);
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
Log.i("test .........", "hello 0");
try{
androidHttpTransport.call(SOAP_ACTION, envelope);
Log.i("test test.........", "hello 1");
SoapPrimitive response = (SoapPrimitive)envelope.getResponse();
Toast.makeText(getApplicationContext(), response.toString(), Toast.LENGTH_SHORT).show();
Log.d("result ........", response.toString());
/* TextView result = (TextView) findViewById(R.id.tv_status);
result.setText(response.toString());*/
}
catch(Exception e)
{
Log.e("erros ......", e.getMessage().toString());
}
}
}
上面的图片是连接到soap服务的android代码。而且我总是得到一个零点异常,因为控制将会抓住一部分。
上面的图片是logcat错误
答案 0 :(得分:0)
private final String URL = "http://192.168.1.104:8088/Blue_Book/services/Login_service?wsdl";
private final String NAMESPACE = "http://nepal.blue_book.com";
试试这个,
private final String URL = "http://192.168.1.104:8088/Blue_Book/services/Login_service";
private final String NAMESPACE = "http://nepal.blue_book.com/";