如何在Android请求中添加自定义[回调]字符串?
下面是我在android中调用soap webservice的代码,并得到一个json响应。如何在android中传递调用back=?callback=jQuery15
?
有关相同内容的任何想法如何在网址中包含callback-jquery15
个参数?
private static String SOAP_ACTION1 = "http://www.example.com/NewsServices/AuthenticateApplication";
private static String NAMESPACE = "http://www.example.com/NewsServices/";
private static String METHOD_NAME1 = "AuthenticateApplication";
private static String URL = "http://www.example.com/services/webServices/MobileServices/exampleMobilejson.asmx";
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME1);
request.addProperty("xyz", "xyzaa");
request.addProperty("abc", "abcxx");
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
SoapEnvelope.VER11);
envelope.setOutputSoapObject(request);
envelope.dotNet = true;
try {
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
androidHttpTransport.call(SOAP_ACTION1, envelope);
SoapObject result = (SoapObject) envelope.bodyIn;
Toast.makeText(getApplicationContext(), result.toString(),
Toast.LENGTH_LONG).show();
txtCel.setText(result.getProperty(0).toString());
但我的问题是我的webservice接受参数,回调如何使用ex:
http://www.example.com/services/webServices/MobileServices/exampleMobileJson.asmx/AuthenticateApplication?callback=jQuery15&xyz=xyzaa&abc=abcxx
答案 0 :(得分:0)
回调通常用于JSONP。当您在浏览器中对位于其他域中的Web服务器执行AJAX请求时。由于“同源政策”,它将被阻止。使用JSONP,您可以避免添加回调参数。此参数是您网页中定义的函数调用。
关于添加额外参数:
request.addProperty("callback", "jQuery15");
就像你已经用于'xyz'和'abc'。