0

How can i add Custom [call back] string in android request?

Below is my code for call soap webservice in android and get a json response. How can i pass call back=?callback=jQuery15 in android?

Any idea about the same how can I include a callback-jquery15 parameters in url?

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());

but my problem is my webservice accept parameters with call back how can i use for ex:

http://www.example.com/services/webServices/MobileServices/exampleMobileJson.asmx/AuthenticateApplication?callback=jQuery15&xyz=xyzaa&abc=abcxx
4

1 回答 1

0

Callback is normally used for JSONP. When you do an AJAX request in the browser to a webserver which is in a other domain. It will be blocked due 'same origin policy'. With JSONP you can circumvent this be adding a callback parameter. This parameter is a function call defined in your webpage.

About adding an extra parameter:

request.addProperty("callback", "jQuery15");

Like you already used for 'xyz' and 'abc'.

于 2013-07-02T12:13:00.707 回答