如何将参数值传递给android中的webservice

时间:2010-09-28 06:55:42

标签: android

嗨朋友们       我在android中使用kso​​ap2可以任何人告诉如何将参数值传递给android中的webservice

由于

1 个答案:

答案 0 :(得分:0)

 public class AndroidClientService extends Activity {
private static final String SOAP_ACTION = "http://10.120.10.87:8080/TestService/services/TestService/saveServices";

private static final String OPERATION_NAME = "saveServices";

private static final String WSDL_TARGET_NAMESPACE = "http://10.120.10.87:8080/TestService/services/TestService?WSDL";

private static final String SOAP_ADDRESS = "http://10.120.10.87:8080/TestService/services/TestService";

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);


   TextView textView = new TextView(this);

setContentView(textView);

SoapObject request = new SoapObject(WSDL_TARGET_NAMESPACE,
    OPERATION_NAME);

/*
 * PropertyInfo pi = new PropertyInfo(); pi.setName("celcius"); pi.type
 * = PropertyInfo.OBJECT_CLASS; pi.setValue(100);
 * request.addProperty(pi);
 */

request.addProperty("number", "8806007");

SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
    SoapEnvelope.VER11);
envelope.dotNet = true;

envelope.setOutputSoapObject(request);

HttpTransportSE httpTransport = new HttpTransportSE(SOAP_ADDRESS);

try

{

    httpTransport.call(SOAP_ACTION, envelope);

    Object response = envelope.getResponse();


    textView.setText(response.toString());

        }

catch (Exception exception)

{

    textView.setText(exception.toString());

}

}

}

参考:WEBSERVICE