更新时间:2022-05-30 05:33:39
谷歌为Ksoap2教程U将得到他们中的很多。下面是示例code发送请求的Web服务。
Google for Ksoap2 tutorial u will get a lot of them . Here is sample code for sending request to web service .
public class WebServicePoc extends Activity{
private static final String SOAP_ACTION = "http://tempuri.org/Arnoid";
private static final String METHOD_NAME = "Arnoid";
private static final String NAMESPACE = "http://tempuri.org/";
private static final String URL = "http://ipaddress:port/UserAuthenticationInterfacer.asmx";
EditText editText;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
HashMap<String, String> a=new HashMap<String, String>();
try {
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
request.addProperty("FOSID", "1994");
request.addProperty("IMEINumber", "");
request.addProperty("SIMCardNo", "");
request.addProperty("ApplicationName", "App");
request.addProperty("CurrentVersion", "1.0.0.0");
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet=true;
envelope.setOutputSoapObject(request);
AndroidHttpTransport androidHttpTransport = new AndroidHttpTransport(URL);
androidHttpTransport.call(SOAP_ACTION, envelope);
SoapObject result = (SoapObject)envelope.getResponse();
editText=(EditText)findViewById(R.id.text1);
editText.setText(result.toString());
} catch (Exception e) {
e.printStackTrace();
}
和为XML解析器XML请检查教程,使用SAX而已,因为STAX不支持的Android。对于发送XML请求ü可以发送XML作为字符串和SEVER端,然后去code。
And for xml pls check tutorial for xml parsers,use SAX only, as STAX is not supported in android . For sending xml request u can send xml as string and then decode on sever side .