I'm using KSoap within my Android application.
My application using Web Service for communicate with the server.
I have found a code sample of a KSoap wev service client.
In the sample, the client uses the following code for communication with the server -
Request = new SoapObject(NAMESPACE, METHOD_NAME);
How do I pass arguments to the server?
How do I invoke the return value form the server?
You should use SoapObject.addProperty() to add argument and SoapSerializationEnvelope.getResponse() to get data returned by server.
Here is example: http://android-devblog.blogspot.com/2010/06/soap-on-android.html
Related
I would like to connect my android with my own web service with nested like wsdl SOAP request
Using SOAPUI tool i found the method name is login .but unable to pass params user ,pass under Userlogin. how does specifically call the User login in android (Web service).
androidHttpTransport.responseDump returns error as
refer: androidHttpTransport.responseDump
wsdl SOAP request: SOPA Request WSDL
I'm new to soap web service.I want to ping my server using https and i want to use soap.I referred the following links
Not trusted certificate using ksoap2-android
KSOAP 2 Android with HTTPS
but,it doesn't worked in my code. here is my code snippet
SSLConection.allowAllSSL();
HttpsTransportSE httpstransport = new HttpsTransportSE("myserver", 443, "rmo_t_json_v2.asmx", 1000);
httpstransport.call(SOAP_ACTION, envelope);
Where I have to call allowssl(). what is third param in httpstransportSE.
someone may asked my question already but I cannot find any suggestions.
I writing an Android app which needs to access my Django server by using HttpsURLConnection then Django server will return a JSON array to Android.
The view function in Django will receive the parameters from request.POST and generate the JSON array then return using HTTPResponse Django method. It does not need any Templates and Forms.
When I call the Django view function from Android, it returns 403 error. I know that it is because the POST data does not contains "csrf_token".
My problem is: How can I get the "csrf_token" and put it into my POST data before I send it to Django? I try disable the CSRF checking by "#csrf_exempt" it can return the correct result to Android app but I would not disable the CSRF checking.
Thanks,
Wilson
You have to send the cookies and also have to send a header 'X-CSRFToken' with csrftoken.
This is what I do (may not be the best way):
Get csrf token via a get request.But first try to see if you get a csrftoken cookie by doing same request on your browser with developer tools. If not, you should use ensure_csrf_cookie decorator
from django.views.decorators.csrf import ensure_csrf_cookie
#ensure_csrf_cookie
def your_view(request):
pass
Now using the same HttpUrlConnection object do this :
String cookieString="";
String csrftoken="";
// The below code can be shortened using for-each loop
List<HttpCookie> cookies=cookieManager.getCookieStore().getCookies();
Iterator<HttpCookie> cookieIterator=cookies.iterator();
while(cookieIterator.hasNext()){
HttpCookie cookie=cookieIterator.next();
cookieString+=cookie.getName()+"="+cookie.getValue()+";";
if(cookie.getName().equals("csrftoken")){
csrftoken=cookie.getValue();
}
}
Add the following to your post request:
urlConnection.setRequestProperty("X-CSRFToken", csrftoken);
urlConnection.setRequestProperty("Cookie", cookieString);
My project is in symfony where I need to get some data from android. So I implemented json encoding on both parts but my web application does not receive the data from android. I found the android is being unable to send data to symfony..
The code for android where the web link is written is as follows:
JSONObject json = jsonParser.getJSONFromUrl("http://external.apostle.digibiz.com/web/app_dev.php/api/test", params);
What is the error ??
so i need to send a SoapObject as a parameter of a SoapObject............ from the request dump above it seems that the envelope structure is fine.......but the server always gets null when i try get "filter.street" from the request......any ideas?
Look at the ksoap2 android wiki about debugging and check out the request and response.
http://code.google.com/p/ksoap2-android/wiki/CodingTipsAndTricks