连接Webservice一直连接不上.代码在ht.call(SOAP_ACTION,envelope)跳入catch中e.getMessage()打印错误信息如下:
06-02 02:55:59.555: INFO/System.out(571):
expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope (position:START_TAG <{http://schemas.xmlsoap.org/wsdl/}wsdl:definitions targetNamespace='http://axisservices.app.sc.com'>@2:487 in java.io.InputStreamReader@437b9cb0) 代码:
package mars.ToMoveOA;import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.AndroidHttpTransport;import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
public class MoveActivity extends Activity {
//命名空间
private static final String NAMESPACE ="http://axisservices.app.sc.com/";
// WebService地址
private static String URL = "http://10.41.105.211:8080/hnhboa/services/OaService?wsdl";
//方法名
private static final String METHOD_NAME = "verifyUserPassword";
//方法地址
private static String SOAP_ACTION = "http://axisservices.app.sc.com/verifyUserPassword";
//声明界面控件
private Button qdbtn=null;
private Button tuichu=null;
private EditText userEit=null;
private EditText passwordEit=null;
String userEdt,passwordEdt;
//
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
//为各个按钮赋上相应的ID
tuichu=(Button)findViewById(R.id.denglutc);
qdbtn=(Button)findViewById(R.id.dengluqd);
userEit=(EditText)findViewById(R.id.dengluyhm);
passwordEit=(EditText)findViewById(R.id.denglumm);
//设置退出按钮点击事件
tuichu.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
finish();
}
});
//设置确定按钮点击事件
qdbtn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
//实现页面跳转,以及传值
// Intent intent=new Intent();
// intent.setClass(MoveActivity.this, MoveSy.class);
// MoveActivity.this.startActivity(intent);
userEdt=userEit.getText().toString();
passwordEdt=passwordEit.getText().toString();
getUser(userEdt,passwordEdt);
// Toast.makeText(MoveActivity.this, "test", Toast.LENGTH_LONG).show();
System.out.println("Test");
}
});
}
public void getUser(String username,String password) {
System.out.println("username:"+username);
try {
System.out.println("rpc------");
SoapObject rpc = new SoapObject(NAMESPACE, METHOD_NAME);
System.out.println("rpc invoked:" + rpc);
System.out.println("user is: " + username);
rpc.addProperty("username", username);
rpc.addProperty("password",password); AndroidHttpTransport ht = new AndroidHttpTransport(URL);
System.out.println("ht is:"+ht);
ht.debug = false;
// 设置Soap的请求信息,参数部分为Soap协议的版本号
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
System.out.println("envelope is:"+envelope);
envelope.bodyOut = rpc;
envelope.dotNet = true;
envelope.setOutputSoapObject(rpc);
System.out.println("before method call:" + rpc);
ht.call(SOAP_ACTION, envelope);
System.out.println("after method call:" + rpc);
SoapObject result = (SoapObject) envelope.bodyIn;
System.out.println("result is:" + result);
SoapObject detail = (SoapObject) result.getProperty("verifyUserPasswordResponse");
System.out.println("detail is:" + detail);
Toast.makeText(MoveActivity.this, detail.toString(),Toast.LENGTH_LONG).show();
return;
}
catch (Exception e) {
System.out.println("调用出错!");
System.out.println(e.getMessage());
e.printStackTrace();
}
}
}
06-02 02:55:59.555: INFO/System.out(571):
expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope (position:START_TAG <{http://schemas.xmlsoap.org/wsdl/}wsdl:definitions targetNamespace='http://axisservices.app.sc.com'>@2:487 in java.io.InputStreamReader@437b9cb0) 代码:
package mars.ToMoveOA;import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.AndroidHttpTransport;import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
public class MoveActivity extends Activity {
//命名空间
private static final String NAMESPACE ="http://axisservices.app.sc.com/";
// WebService地址
private static String URL = "http://10.41.105.211:8080/hnhboa/services/OaService?wsdl";
//方法名
private static final String METHOD_NAME = "verifyUserPassword";
//方法地址
private static String SOAP_ACTION = "http://axisservices.app.sc.com/verifyUserPassword";
//声明界面控件
private Button qdbtn=null;
private Button tuichu=null;
private EditText userEit=null;
private EditText passwordEit=null;
String userEdt,passwordEdt;
//
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
//为各个按钮赋上相应的ID
tuichu=(Button)findViewById(R.id.denglutc);
qdbtn=(Button)findViewById(R.id.dengluqd);
userEit=(EditText)findViewById(R.id.dengluyhm);
passwordEit=(EditText)findViewById(R.id.denglumm);
//设置退出按钮点击事件
tuichu.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
finish();
}
});
//设置确定按钮点击事件
qdbtn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
//实现页面跳转,以及传值
// Intent intent=new Intent();
// intent.setClass(MoveActivity.this, MoveSy.class);
// MoveActivity.this.startActivity(intent);
userEdt=userEit.getText().toString();
passwordEdt=passwordEit.getText().toString();
getUser(userEdt,passwordEdt);
// Toast.makeText(MoveActivity.this, "test", Toast.LENGTH_LONG).show();
System.out.println("Test");
}
});
}
public void getUser(String username,String password) {
System.out.println("username:"+username);
try {
System.out.println("rpc------");
SoapObject rpc = new SoapObject(NAMESPACE, METHOD_NAME);
System.out.println("rpc invoked:" + rpc);
System.out.println("user is: " + username);
rpc.addProperty("username", username);
rpc.addProperty("password",password); AndroidHttpTransport ht = new AndroidHttpTransport(URL);
System.out.println("ht is:"+ht);
ht.debug = false;
// 设置Soap的请求信息,参数部分为Soap协议的版本号
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
System.out.println("envelope is:"+envelope);
envelope.bodyOut = rpc;
envelope.dotNet = true;
envelope.setOutputSoapObject(rpc);
System.out.println("before method call:" + rpc);
ht.call(SOAP_ACTION, envelope);
System.out.println("after method call:" + rpc);
SoapObject result = (SoapObject) envelope.bodyIn;
System.out.println("result is:" + result);
SoapObject detail = (SoapObject) result.getProperty("verifyUserPasswordResponse");
System.out.println("detail is:" + detail);
Toast.makeText(MoveActivity.this, detail.toString(),Toast.LENGTH_LONG).show();
return;
}
catch (Exception e) {
System.out.println("调用出错!");
System.out.println(e.getMessage());
e.printStackTrace();
}
}
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货