Ksoap2 Request parsing.

Problems with WiFi, SQLite ,Bluetooth, WiMax, Proxies, etc...

Ksoap2 Request parsing.

Postby Dannible » Fri Nov 13, 2009 11:45 pm

I am new to Java and Android development.

I have a web service that I am connecting to using ksoap2. I can can
create the soap object and add properties to it create the envelope.

The problem I am having is, when I output the request to a string I
get something like:

Login{user="name";password="password";application="app";}

My web service expects it to look like:

Login("name","password","app")

Can someone point me in the right direction on parsing the request to
look more in line with what my web service is expecting?
Dannible
Junior Developer
Junior Developer
 
Posts: 13
Joined: Fri Nov 13, 2009 11:43 pm

Top

Postby Droid123 » Sat Nov 21, 2009 1:40 pm

Hi, I could help you out, I've been breaking my head over Ksoap2, but i finally got it working properly.

But I'm not sure what you mean, is your problem in setting up a proper soap request or is your problem when extracting the response from the soap reply?

I expected its the former so if you add properties to your request object with this syntax you should be fine:

request.addproperty(WEBSERVICE_PARAMETER_NAME, LOCAL_VARIABLE);

you would get something like this:
request.addproperty("user","name");
request.addproperty("password","password");
request.addproperty("application","app");
Droid123
Experienced Developer
Experienced Developer
 
Posts: 77
Joined: Sat Nov 21, 2009 1:21 pm

Postby Dannible » Mon Nov 23, 2009 5:12 pm

yes, I'm having a problem with the format of the request.

I use:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2.                 SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME );
  3.  
  4.                 request.addProperty("userid", edituname);
  5.  
  6.                 request.addProperty("password", editpass);
  7.  
  8.                 request.addProperty("application", editapp);
Parsed in 0.030 seconds, using GeSHi 1.0.8.4


Not sure how to look at the actual XML, but if I put request.tostring() into a textview it looks like:

Login{userid="name";password="password";application="app";}

the webservice I am using does not like it and gives me a login failure. So what I did next is created a string with the SOAP request.

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. String requestenv =
  2.  
  3.                         "<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
  4.  
  5.                         "<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">"+
  6.  
  7.                                 "<soap:Body>"+
  8.  
  9.                                         "<Login xmlns=\"http://website.com/webData/\">"+
  10.  
  11.                                         "<userid>user</userid>"+
  12.  
  13.                                         "<password>password</password>"+
  14.  
  15.                                         "<application>application</application>"+
  16.  
  17.                                         "</Login>"+
  18.  
  19.                                 "</soap:Body>"+
  20.  
  21.                         "</soap:Envelope>";
  22.  
  23.  
  24.  
  25.                 SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
  26.  
  27.                 envelope.dotNet = true;
  28.  
  29.                 envelope.setOutputSoapObject(requestenv);
  30.  
  31.  
  32.  
  33.  
Parsed in 0.033 seconds, using GeSHi 1.0.8.4


I get the same results.

Is there somehting else I can try?
Dannible
Junior Developer
Junior Developer
 
Posts: 13
Joined: Fri Nov 13, 2009 11:43 pm

Postby Droid123 » Mon Nov 23, 2009 9:01 pm

Well your construction of your request object seems about right.

What kind of request does your webserver expect? Since it's "Login" don't you need to use a real user/pass combination?

Is your Namespace / Webmethod name correct?


What kind of error are you getting exactly? Could you post your log and the rest of the sourcecode?
This might sound stupid but did you include the INTERNET permission in your manifest file?
Droid123
Experienced Developer
Experienced Developer
 
Posts: 77
Joined: Sat Nov 21, 2009 1:21 pm

Postby Dannible » Tue Nov 24, 2009 12:28 am

I know I got my NAMESPACE and METHOD correct. I can send a request for VersionInfo, which requires no parameters and I get the correct response. I guess I'm just having trouble when i try to send a request with parameters. I'll post my Code in the morning.
Dannible
Junior Developer
Junior Developer
 
Posts: 13
Joined: Fri Nov 13, 2009 11:43 pm

Top

Return to Networking & Database Problems

Who is online

Users browsing this forum: No registered users and 5 guests