Android Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsMobile ProgrammingAndroid Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old January 23rd, 2013, 03:07 AM
kandroid kandroid is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2013
Posts: 1 kandroid User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 34 m 22 sec
Reputation Power: 0
Send object to webservice via kSoap

I have a login view, from the view, when user types username, password, I need to send them to a webservice. The service will then validate the credentials and return an ID.(customerid).

The service needs to be sent an object of 'Credential' class.

The class:
public class Credetials {

private String username;
private String password;


public Credetials(){}

public String getUserName(){
return this.username;
}
public void setUserName(String uname){
this.username=uname;
}

public String getPassword(){
return this.password;
}
public void setPassword(String password){
this.password=password;
}


}

The view/activity:

loginButton.setOnClickListener(new View.OnClickListener() {

public void onClick(View v) {

/* reading username and password*/
String username=loginname.getText().toString();
String password=logincode.getText().toString();

Credetials credentials=new Credetials();
credentials.setUserName(username);
credentials.setPassword(password);

Log.d("username", credentials.getUserName());
Log.d("password", credentials.getPassword());
**// here i have proper username and password.**

new callGetCustomerId().execute(credentials);


}
});
class callGetCustomerId extends AsyncTask<Object, Void, String>{
@Override
protected String doInBackground(Object... params) {

SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
request.addProperty("credentials", params[0]);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);

envelope.setOutputSoapObject(request);
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);

try{
androidHttpTransport.call(SOAP_ACTION, envelope);
SoapObject response = (SoapObject) envelope.getResponse();

return response.toString();


}catch(Exception e){
return e.getMessage();
}

}
@Override
protected void onPostExecute(String result){
super.onPostExecute(result);
Toast.makeText(getApplicationContext(), result, Toast.LENGTH_SHORT).show();

}
}


web service:

<xs:complexType name="getCustomerId">
<xs:sequence>
<xs:element name="credetials" type="tns:credentials" minOccurs="0"/>
</xs:sequence>

Problem:

Now the problem is it always goes to the catch block. The error is shows somehting like "Cannot serialize: blah blah..Credentials@413...." Can anybody help me out with what am I doing wrong. ??

I have sent single string parameter before which works fine...so I believe my way of sending 'credential' object may be wrong..!!

Reply With Quote
Reply

Viewing: Dev Shed ForumsMobile ProgrammingAndroid Development > Send object to webservice via kSoap

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap