public static final String NAME_SPACE = "http://webService.sxthnet/";
public static String URL = "http://100.123.68.166:8080/wbs1/Server1Port";
public static String Method2="sayhello2";
public final String Action2=NAME_SPACE+Method2;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ed1=(EditText)findViewById(R.id.editText1);
btn1=(Button)findViewById(R.id.button1);
btn1.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v)
{
ed1.setText("bkkd");
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
SoapObject request = new SoapObject(NAME_SPACE,Method2);
//传递参数必须是arg开头,//写真实的变量名也没有用,必须是 arg0 ,arg1 一直排下去,好像只支持10个参数.//其他人说的都弱毙了
request.addProperty("arg0", "张木生" );
// request.addProperty("username", "我的" );
envelope.setOutputSoapObject(request);
envelope.bodyOut = request;
envelope.dotNet = false;
HttpTransportSE ht = new HttpTransportSE(URL);
// AndroidHttpTransport ht=new AndroidHttpTransport(URL);
try{
// ht.call(fullUrl, envelope);
ht.call(null,envelope);
if(envelope.getResponse()!=null){
ed1.setText(envelope.getResponse().toString());
}
else
ed1.setText("No");
} catch(Exception e){
System.out.println(e.toString());
e.printStackTrace();
ed1.setText(e.toString());
安卓开发 调用java写的jax-ws 格式的webservices