Add jar : - ksoap2-android-assembly-2.4-jar-with-dependencies.jar
1)//***************************************************************************************************************************** //**********************************************************************************************************************************
//This function is used for get Go button Json data
private class GetServerDataGo extends AsyncTask<String, String,String>{
private ProcessDialog mProcessDialog=null;
@Override
protected void onPreExecute() {
mProcessDialog = new ProcessDialog(Report.this,Constant.SERVER,Constant.LOADING);
super.onPreExecute();
cleardata();
mReportAdapter=new ReportAdapter(Report.this,alstProduct,alstUnitName,alstQuality,alstQuantity,alstAmount);;
updateDisplay();
}
@Override
protected String doInBackground(String... params) {
final String strListURL = getResources().getString(R.string.REPORT_URL);
ArrayList<NameValuePair> mNameValuePair = new ArrayList<NameValuePair>();
mNameValuePair.add(new BasicNameValuePair(Constant.REPORT_REQUEST.HDNACTION,Constant.REPORT_REQUEST.COLLECTION_REPORT));
mNameValuePair.add(new BasicNameValuePair(Constant.REPORT_REQUEST.ADMINUSERID,strUserid));
mNameValuePair.add(new BasicNameValuePair(Constant.REPORT_REQUEST.REPORT_PERIOD, "4"));
mNameValuePair.add(new BasicNameValuePair(Constant.REPORT_REQUEST.REPORT_STARTTIME,btnFrom.getText().toString()));
mNameValuePair.add(new BasicNameValuePair(Constant.REPORT_REQUEST.REPORT_ENDTIME,btnTo.getText().toString()));
return mCommonClass.PostConnection(strListURL, mNameValuePair);
}
@Override
protected void onPostExecute(String result) {
mProcessDialog.dismiss();
if(result != null){
try{
GetJSONData(new JSONObject(result));
mListView.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, alstProduct.size()*(30)));
}
catch(Exception e){
e.printStackTrace();
}
}
else{
Toast.makeText(Report.this, Constant.SERVERCONNERROR,Toast.LENGTH_SHORT).show();
}
super.onPostExecute(result);
}
}
***********************************
//*****************************************************************************************************************************
// For get data for report
public void GetJSONData(JSONObject mJSONObject){
String strRfp = null,strRfpAccepted = null,strGrossAmount = null,strTransactionAmount = null,strLeadTime = null,strGrossMargin = null,strAvgServiceTime = null;
try {
if(mJSONObject.getString(Constant.COMMON_JSON.TYPE).equals(Constant.COMMON_JSON.OK)){
strRfp = mJSONObject.getString(Constant.REPORT_JSON.RFP);
strRfpAccepted = mJSONObject.getString(Constant.REPORT_JSON.RFP_ACCEPTED);
strGrossAmount = mJSONObject.getString(Constant.REPORT_JSON.GROSS_AMOUNT);
strTransactionAmount = mJSONObject.getString(Constant.REPORT_JSON.AVG_AMOUNT);
strLeadTime =mJSONObject.getString(Constant.REPORT_JSON.AVG_LEAD_TIME);
strGrossMargin = mJSONObject.getString(Constant.REPORT_JSON.GROSS_MARGIN);
strAvgServiceTime = mJSONObject.getString(Constant.REPORT_JSON.AVG_SERVICE_TIME);
JSONArray mJSONArray1=mJSONObject.getJSONArray(Constant.REPORT_JSON.COLLECTION_DETAIL);
JSONArray mJSONArray2=mJSONObject.getJSONArray(Constant.REPORT_JSON.ACCEPCTED);
if (mJSONArray1 != null)
{
for (int i = 0; i < mJSONArray1.length(); i++) {
JSONObject mJSONObject2=mJSONArray1.getJSONObject(i);
alstProduct.add(mJSONObject2.getString(Constant.REPORT_JSON.PRODUCT_NAME).toString());
alstQuality.add(mJSONObject2.getString(Constant.REPORT_JSON.PRODUCT_QUALITY).toString());
alstQuantity.add(mJSONObject2.getString(Constant.REPORT_JSON.TOTAL_QUANTITY).toString());
alstUnitName.add(mJSONObject2.getString(Constant.REPORT_JSON.UNIT_NAME).toString());
alstAmount.add(mJSONObject2.getString(Constant.REPORT_JSON.TOTAL_PRICE).toString());
}
mReportAdapter=new ReportAdapter(Report.this,alstProduct,alstUnitName,alstQuality,alstQuantity,alstAmount);
mListView.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View arg1,int arg2, long arg3) {
if(mReportAdapter!=null){
DisplayListDialog(mReportAdapter);
}
}
});
mListView.setAdapter(mReportAdapter);
}
if (mJSONArray2 != null)
{
for (int i = 0; i < mJSONArray2.length(); i++) {
JSONObject mJSONObject3 = mJSONArray2.getJSONObject(i);
alstCNT.add(mJSONObject3.getString(Constant.REPORT_JSON.CNT));
alstAppStatus.add(mJSONObject3.getString(Constant.REPORT_JSON.APP_STATUS));
}
if(alstCNT.size()==0){
txtScheduled.setText("");
txtAppCompleted.setText("");
}
else if(alstCNT.size()==1){
txtScheduled.setText(alstAppStatus.get(0).toString()+"("+alstCNT.get(0).toString()+")");
}
else if(alstCNT.size()==2){
txtScheduled.setText(alstAppStatus.get(0).toString()+"("+alstCNT.get(0).toString()+")");
txtAppCompleted.setText(alstAppStatus.get(1).toString()+"("+alstCNT.get(1).toString()+")");
}
}
int intRfp = Integer.parseInt(strRfp);
int intRfpAccepted = Integer.parseInt(strRfpAccepted);
if(intRfp!=0 && intRfpAccepted!=0){
intEfficiency = intRfpAccepted*100/intRfp;
}
else {
intEfficiency = 0;
}
String strEfficiency = String.valueOf(intEfficiency).toString();
txtRFP.setText(strRfp.toString());
txtAccepted.setText(strRfpAccepted.toString());
txtEfficiency.setText(strEfficiency.toString());
txtCollectionGross.setText(strGrossAmount.toString());
txtTotalAmount.setText(strTransactionAmount.toString());
txtAvgLeadTime.setText(strLeadTime.toString());
txtServiceTime.setText(strAvgServiceTime.toString());
txtGrossMargin.setText(strGrossMargin.toString());
}else{
Toast.makeText(Report.this,mJSONObject.getString(Constant.COMMON_JSON.ERR_MSG).toString(), Toast.LENGTH_SHORT).show();
}
} catch (JSONException e) {
e.printStackTrace();
}
}
**************************************
/**This method use for PostConnection to Server
*/
public String PostConnection(String strUrl,ArrayList<NameValuePair> alstNameValuePair) {
InputStream mInputStream = null;
try {
//This is the default apacheconnection.
HttpClient mHttpClient = new DefaultHttpClient();
// HttpConnectionParams.setConnectionTimeout(mHttpClient.getParams(), 60000); //Timeout Limit
//Pathe of serverside
HttpPost mHttpPost = new HttpPost(strUrl);
if(alstNameValuePair!=null)
{
//post the valur you want to pass.
mHttpPost.setEntity(new UrlEncodedFormEntity(alstNameValuePair));
}
//get the valu from the saerverside as response.
HttpResponse mHttpResponse = mHttpClient.execute(mHttpPost);
HttpEntity mHttpEntity = mHttpResponse.getEntity();
mInputStream = mHttpEntity.getContent();
}
catch (Exception e) {
e.printStackTrace();
}
String strLine = null;
String strResult = "";
//convert response in to the string.
try {
if(mInputStream!=null){
BufferedReader mBufferedReader = new BufferedReader(new InputStreamReader(mInputStream,HTTP.UTF_8), 8);
StringBuilder mStringBuilder = new StringBuilder();
while((strLine = mBufferedReader.readLine()) != null) {
mStringBuilder.append(strLine + "\n");
}
strResult = mStringBuilder.toString();
mInputStream.close();
}
}
catch (Exception e) {
e.printStackTrace();
}
return strResult;
}
================================================
1)SoapService.java
package com.ovte.sadbhavna;
import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransportSE;
public class SOAPService {
private String SOAP_URL = null;
private String SOAP_ACTION =null;
private String SOAP_NAMESPACE = null;
private String SOAP_METHOD = null;
//default constructor
public SOAPService(String SOAP_URL,String SOAP_ACTION,String SOAP_NAMESPACE,String SOAP_METHOD) {
this.SOAP_URL=SOAP_URL;
this.SOAP_ACTION=SOAP_ACTION;
this.SOAP_NAMESPACE=SOAP_NAMESPACE;
this.SOAP_METHOD=SOAP_METHOD;
}
//**************************************************************************************************************************
//soap service for get server data
public String getSoapData(String keyName[],Object keyValue[]){
SoapObject soapRequest = null;
SoapSerializationEnvelope mSoapSerializationEnvelope = null;
HttpTransportSE androidHttpTransport = null;
Object soapResponse = null;
try{
soapRequest = new SoapObject(SOAP_NAMESPACE, SOAP_METHOD);
if(keyName!=null){
for(int i=0;i<keyName.length;i++){
soapRequest.addProperty(keyName[i], keyValue[i]);
}
}
mSoapSerializationEnvelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
mSoapSerializationEnvelope.setOutputSoapObject(soapRequest);
androidHttpTransport = new HttpTransportSE(SOAP_URL);
androidHttpTransport.call(SOAP_ACTION + SOAP_METHOD, mSoapSerializationEnvelope);
soapResponse = mSoapSerializationEnvelope.getResponse();
return (String)soapResponse.toString();
}catch(Exception e){
System.out.println("\nSoap Error : "+e.getMessage().toString());
return null;
}
}
}
===========================================
************************************************************************
============================================
//****************************************************************************************************************************
//This class is used for get Favourite Quote
private ProcessDialog mProcessDialog = null;
private class getFavouriteEventData extends AsyncTask<String, String, String> {
@Override
protected void onPreExecute() {
// TODO Auto-generated method stub
mProcessDialog = new ProcessDialog(EventFavourite.this, "FavouriteQuote", Constant.LOADING);
alstEvent_Id.clear();
alstEvent_Title.clear();
alstEvent_Start_Dt.clear();
alstEvent_End_Dt.clear();
alstEvent_Thumb_Image.clear();
alstEvent_Original_Image.clear();
alstEvent_Discription.clear();
super.onPreExecute();
}
@Override
protected String doInBackground(String... params) {
String SOAP_URL = getResources().getString(R.string.Webservice_URL);
String SOAP_ACTION = getResources().getString(R.string.SOAP_Action);
String SOAP_NAMESPACE = getResources().getString(R.string.SOAP_NAMESPACE);
String SOAP_METHOD = "GetFavouriteList";
mSoapService = new SOAPService(SOAP_URL, SOAP_ACTION, SOAP_NAMESPACE, SOAP_METHOD);
String keyName[] = {"user_id","type"};
Object keyValue[] = {strUserID.toString(),Constant.EVENT_FAVOURITE_RESPONSE};
return mSoapService.getSoapData(keyName, keyValue);
}
@Override
protected void onPostExecute(String result) {
mProcessDialog.dismiss();
if(result != null){
System.out.println("Favourite Quote ="+result);
String strSuccess,strMessage;
try {
JSONObject json_Add_Fav_Quote = new JSONObject(result);
if(json_Add_Fav_Quote != null)
{
strSuccess = json_Add_Fav_Quote.getString("SUCCESS").toString();
System.out.println("Favourite Quote strSuccess ="+strSuccess);
if(strSuccess.equals("OK")){
JSONArray json_quoteList = json_Add_Fav_Quote.getJSONArray("EVENT");
if(json_quoteList !=null){
for(int i=0;i<json_quoteList.length();i++){
JSONObject job = json_quoteList.getJSONObject(i);
alstEvent_Id.add(job.getString("ID").toString());
alstEvent_Title.add(job.getString("TITLE").toString());
alstEvent_Start_Dt.add(job.getString("EVENT_START_DT").toString());
alstEvent_End_Dt.add(job.getString("EVENT_END_DT").toString());
alstEvent_Thumb_Image.add(job.getString("THUMB_IMAGE").toString());
alstEvent_Original_Image.add(job.getString("ORIGINAL_IMAGE").toString());
alstEvent_Discription.add(job.getString("DETAIL").toString());
}
mEventFavouriteAdapter = new EventFavouriteAdapter(EventFavourite.this,alstEvent_Id,alstEvent_Title,alstEvent_Start_Dt,alstEvent_End_Dt,alstEvent_Thumb_Image,alstEvent_Original_Image,alstEvent_Discription);
lstEventFavourite.setAdapter(mEventFavouriteAdapter);
}
}
else{
strMessage = json_Add_Fav_Quote.getString("MESSAGE").toString();
Toast.makeText(EventFavourite.this,Html.fromHtml(strMessage), Toast.LENGTH_LONG).show();
}
}
} catch ( Exception e ) {
e.printStackTrace();
}
}
else{
Toast.makeText(EventFavourite.this,Html.fromHtml(Constant.SERVERCONNERROR),Toast.LENGTH_SHORT).show();
}
super.onPostExecute(result);
}
}
================================================
2)//****************************************************************************************************************************
//This class is used for get list of More By Author
private class getMoreByAuthorQuoteData extends AsyncTask<String, String, String> {
private ProcessDialog mProcessDialog = null;
@Override
protected void onPreExecute() {
// TODO Auto-generated method stub
mProcessDialog = new ProcessDialog(MoreByAuthor.this, "More By Author", Constant.LOADING);
super.onPreExecute();
}
// @Override
// protected String doInBackground(String... params)
// {
// String communityId=GetCommunity();
// String categoryId=GetCategory();
// String RequestEnvelope=String.format(Constant.CREATESUBSCRIPTION_REQUEST,strUserID.toString(),strAuthorName.toString(),communityId,categoryId);
// return GlobalClass.SOAPPostConnection(Constant.Webservice_URL,Constant.SOAP_Action, RequestEnvelope);
// }
@Override
protected String doInBackground(String... params) {
String SOAP_URL = getResources().getString(R.string.Webservice_URL);
String SOAP_ACTION = getResources().getString(R.string.SOAP_Action);
String SOAP_NAMESPACE = getResources().getString(R.string.SOAP_NAMESPACE);
String SOAP_METHOD = "SearchQuoteByAuthor";
mSoapService = new SOAPService(SOAP_URL, SOAP_ACTION, SOAP_NAMESPACE, SOAP_METHOD);
String keyName[] = {"user_id","SearchText","commnunity_id","category_id"};
String communityId=GetCommunity();
System.out.println("community id output===="+ communityId);
String categoryId=GetCategory();
System.out.println("categoryId output===="+ categoryId);
Object keyValue[] = {strUserID.toString(),strAuthorName.toString(),communityId,categoryId};
return mSoapService.getSoapData(keyName, keyValue);
}
@Override
protected void onPostExecute(String result) {
mProcessDialog.dismiss();
if(result != null){
Log.i("Sadbhavna",result.toString());
String strSuccess,strMessage;
try {
JSONObject json_MoreByAuthor = new JSONObject(result);
System.out.println("More by author==="+result.toString());
if(json_MoreByAuthor != null)
{
strSuccess = json_MoreByAuthor.getString("SUCCESS").toString();
if(strSuccess.equals("OK")){
JSONArray json_quoteList = json_MoreByAuthor.getJSONArray("QUOTE");
if(json_quoteList !=null){
for(int i=0;i<json_quoteList.length();i++){
JSONObject job = json_quoteList.getJSONObject(i);
alstID.add(job.getString("ID").toString());
alstQuote.add(job.getString("QUOTE").toString());
alstAuthor.add(job.getString("AUTHOR").toString());
}
mMoreByauthorAdapter = new MoreByAuthorAdapter(MoreByAuthor.this,alstID,alstQuote,alstAuthor);
lstMoreByAuthor.setAdapter(mMoreByauthorAdapter);
}
}
else{
strMessage = json_MoreByAuthor.getString("MESSAGE").toString();
Toast.makeText(MoreByAuthor.this, Html.fromHtml(strMessage), Toast.LENGTH_LONG).show();
}
}
} catch ( Exception e ) {
e.printStackTrace();
}
}
else{
Toast.makeText(MoreByAuthor.this, Html.fromHtml(Constant.SERVERCONNERROR),Toast.LENGTH_SHORT).show();
}
super.onPostExecute(result);
}
}
===========================================
3)////This class is used for get Category List
private class GetCategoryListData extends AsyncTask<String, String, String> {
private ProcessDialog mProcesCategoryDialog = null;
@Override
protected void onPreExecute() {
mProcesCategoryDialog = new ProcessDialog(SettingActivity.this, "Category", Constant.LOADING);
super.onPreExecute();
}
@Override
protected String doInBackground(String... params) {
String SOAP_URL = getResources().getString(R.string.Webservice_URL);
String SOAP_ACTION = getResources().getString(R.string.SOAP_Action);
String SOAP_NAMESPACE = getResources().getString(R.string.SOAP_NAMESPACE);
String SOAP_METHOD = "GetCategoryTable";
mSoapService = new SOAPService(SOAP_URL, SOAP_ACTION, SOAP_NAMESPACE, SOAP_METHOD);
String keyName[] = {"user_id"};
Object keyValue[] = {strUserID};
return mSoapService.getSoapData(keyName, keyValue);
}
@Override
protected void onPostExecute(String result) {
mProcesCategoryDialog.dismiss();
if(result != null){
String strSuccess,strMessage;
try {
System.out.println("Category Response : " + result);
JSONObject json_Category = new JSONObject(result);
if(json_Category != null)
{
strSuccess = json_Category.getString("SUCCESS").toString();
if(strSuccess.equals("OK")){
JSONArray jsonArray_CategoryList = json_Category.getJSONArray("CATEGORY");
if(jsonArray_CategoryList!=null){
OpenDatabase();
mDbHelper.DeleteCategoryList(mSQLiteDatabase);
for(int i=0;i<jsonArray_CategoryList.length();i++){
JSONObject jsonCategory_attribute=jsonArray_CategoryList.getJSONObject(i);
if(jsonCategory_attribute!=null){
int id =jsonCategory_attribute.getInt("id");
int root=jsonCategory_attribute.getInt("root");
int parent_id =jsonCategory_attribute.getInt("parent_id");
int lft=jsonCategory_attribute.getInt("lft");
int rgt =jsonCategory_attribute.getInt("rgt");
int level=jsonCategory_attribute.getInt("level");
String name=jsonCategory_attribute.getString("name").toString();
String status=jsonCategory_attribute.getString("status").toString();
int CNT=jsonCategory_attribute.getInt("CNT");
int selected =jsonCategory_attribute.getInt("selected");
mDbHelper.InsertCategoryList(mSQLiteDatabase, id, root, parent_id, lft, rgt, level, name, status,CNT,selected);
}
}
CloseDataBase();
Intent mIntent=new Intent(SettingActivity.this,ChangeCategory.class);
startActivity(mIntent);
}
}
else{
strMessage = json_Category.getString("MESSAGE").toString();
Toast.makeText(SettingActivity.this, Html.fromHtml(strMessage), Toast.LENGTH_LONG).show();
}
}
} catch ( Exception e ) {
e.printStackTrace();
}
}
else{
Toast.makeText(SettingActivity.this, Html.fromHtml(Constant.SERVERCONNERROR),Toast.LENGTH_SHORT).show();
}
super.onPostExecute(result);
}
}
================================================
4)//***************************************************************************************************************************
//This class is used for get More by author quote
private class getMoreByAuthorQuote extends AsyncTask<String, String, String> {
private ProcessDialog mProcessDialog = null;
@Override
protected void onPreExecute() {
// TODO Auto-generated method stub
mProcessDialog = new ProcessDialog(SearchActivity.this, "Quote data", Constant.LOADING);
ClearData();
super.onPreExecute();
}
@Override
protected String doInBackground(String... params) {
String SOAP_URL = getResources().getString(R.string.Webservice_URL);
String SOAP_ACTION = getResources().getString(R.string.SOAP_Action);
String SOAP_NAMESPACE = getResources().getString(R.string.SOAP_NAMESPACE);
String SOAP_METHOD = "SearchQuoteByAuthor";
mSoapService = new SOAPService(SOAP_URL, SOAP_ACTION, SOAP_NAMESPACE, SOAP_METHOD);
String communityId=GetCommunity();
String categoryId=GetCategory();
// System.out.println("categoryId output===="+ categoryId);
String keyName[] = {"user_id","SearchText","commnunity_id","category_id"};
Object keyValue[] = {strUserID.toString(),edtSearch.getText().toString(),communityId,categoryId};
return mSoapService.getSoapData(keyName, keyValue);
}
@Override
protected void onPostExecute(String result) {
mProcessDialog.dismiss();
GetSearchQuoteResponse(result);
super.onPostExecute(result);
}
}
//***************************************************************************************************************************
//This class is used for get serch quote by text
private class SearchQuoteText extends AsyncTask<String, String, String> {
private ProcessDialog mProcessDialog = null;
@Override
protected void onPreExecute() {
// TODO Auto-generated method stub
mProcessDialog = new ProcessDialog(SearchActivity.this, "Quote data", Constant.LOADING);
ClearData();
super.onPreExecute();
}
@Override
protected String doInBackground(String... params) {
String SOAP_URL = getResources().getString(R.string.Webservice_URL);
String SOAP_ACTION = getResources().getString(R.string.SOAP_Action);
String SOAP_NAMESPACE = getResources().getString(R.string.SOAP_NAMESPACE);
String SOAP_METHOD = "SearchQuote";
mSoapService = new SOAPService(SOAP_URL, SOAP_ACTION, SOAP_NAMESPACE, SOAP_METHOD);
String keyName[] = {"user_id","SearchText","commnunity_id","category_id"};
String communityId=GetCommunity();
String categoryId=GetCategory();
Object keyValue[] = {strUserID.toString(),edtSearch.getText().toString(),communityId,categoryId};
return mSoapService.getSoapData(keyName, keyValue);
}
@Override
protected void onPostExecute(String result) {
mProcessDialog.dismiss();
GetSearchQuoteResponse(result);
super.onPostExecute(result);
}
}
//********************************************************************************************************************************
//This function is used for get all search data
private void GetSearchQuoteResponse(String result){
ClearData();
if(result != null){
String strSuccess,strMessage;
try {
JSONObject json_MoreByAuthor = new JSONObject(result);
if(json_MoreByAuthor != null)
{
strSuccess = json_MoreByAuthor.getString("SUCCESS").toString();
if(strSuccess.equals("OK")){
JSONArray json_quoteList = json_MoreByAuthor.getJSONArray("QUOTE");
if(json_quoteList !=null){
for(int i=0;i<json_quoteList.length();i++){
JSONObject job = json_quoteList.getJSONObject(i);
alstID.add(job.getString("ID").toString());
alstQuote.add(job.getString("QUOTE").toString());
alstAuthorName.add(job.getString("AUTHOR").toString());
}
mSearchActivityAdapter = new SearchActivityAdapter(SearchActivity.this,alstID,alstQuote,alstAuthorName);
lstSearchAllQuoteList.setAdapter(mSearchActivityAdapter);
}
}
else{
strMessage = json_MoreByAuthor.getString("MESSAGE").toString();
ClearData();
mSearchActivityAdapter = new SearchActivityAdapter(SearchActivity.this,alstID,alstQuote,alstAuthorName);
lstSearchAllQuoteList.setAdapter(mSearchActivityAdapter);
Toast.makeText(SearchActivity.this, Html.fromHtml(strMessage), Toast.LENGTH_LONG).show();
}
}
} catch ( Exception e ) {
e.printStackTrace();
}
}
else{
Toast.makeText(SearchActivity.this, Html.fromHtml(Constant.SERVERCONNERROR),Toast.LENGTH_SHORT).show();
}
}
public void ClearData() {
alstID.clear();
alstAuthorName.clear();
alstQuote.clear();
========================================
5)//******************************************************************************************************************************
//This class is used for get Language list
private ProcessDialog mProcessDialog1 = null;
private class getDataForLanguage extends AsyncTask<String, String, String> {
@Override
protected void onPreExecute() {
// TODO Auto-generated method stub
mProcessDialog1 = new ProcessDialog(Register.this, "Login", Constant.LOADING);
super.onPreExecute();
}
@Override
protected String doInBackground(String... params) {
String SOAP_URL = getResources().getString(R.string.Webservice_URL);
String SOAP_ACTION = getResources().getString(R.string.SOAP_Action);
String SOAP_NAMESPACE = getResources().getString(R.string.SOAP_NAMESPACE);
String SOAP_METHOD = "getLanaguage";
mSoapService = new SOAPService(SOAP_URL, SOAP_ACTION, SOAP_NAMESPACE, SOAP_METHOD);
return mSoapService.getSoapData(null, null);
}
@Override
protected void onPostExecute(String result) {
mProcessDialog1.dismiss();
if(result != null){
String strSuccess,strMessage;
try {
JSONObject json_language = new JSONObject(result);
if(json_language != null)
{
strSuccess = json_language.getString("SUCCESS").toString();
if(strSuccess.equals("OK")){
JSONArray json_LanguageList = json_language.getJSONArray("LANGUAGE");
System.out.println("str_LanguageList==="+json_LanguageList.toString());
if(json_LanguageList !=null){
for(int i=0;i<json_LanguageList.length();i++){
JSONObject job = json_LanguageList.getJSONObject(i);
alstLanguageID.add(job.getString("ID").toString());
mArrayAdapterLanguageName.add(job.getString("LANAGUGE").toString());
alstLanguage_Short_Name.add(job.getString("SHORT_NAME").toString());
}
}
}
else{
strMessage = json_language.getString("MESSAGE").toString();
Toast.makeText(Register.this, Html.fromHtml(strMessage), Toast.LENGTH_LONG).show();
}
}
} catch ( Exception e ) {
e.printStackTrace();
}
}
else{
Toast.makeText(Register.this, Html.fromHtml(Constant.SERVERCONNERROR),Toast.LENGTH_SHORT).show();
}
super.onPostExecute(result);
}
}
======================================
<string name="Webservice_URL">http://180.211.110.196/php-projects/quote/admin/webservices/actions?ws=1</string>
<string name="SOAP_Action">http://180.211.110.196/php-projects/quote/admin/webservices/actions</string>
<string name="SOAP_NAMESPACE">http://180.211.110.196</string>
================================================
6) //**********************************************************************************************************************
//This class is used for get list ofEvents
private ProcessDialog mProcessDialog = null;
private class GetInfoDRC extends AsyncTask<String, String, String> {
@Override
protected void onPreExecute() {
// TODO Auto-generated method stub
mProcessDialog = new ProcessDialog(InfoDRC.this, "Get Info DRC", Constant.LOADING);
super.onPreExecute();
}
@Override
protected String doInBackground(String... params) {
String SOAP_URL = getResources().getString(R.string.Webservice_URL);
String SOAP_ACTION = getResources().getString(R.string.SOAP_Action);
String SOAP_NAMESPACE = getResources().getString(R.string.SOAP_NAMESPACE);
String SOAP_METHOD = "DrcInfo";
mSoapService = new SOAPService(SOAP_URL, SOAP_ACTION, SOAP_NAMESPACE, SOAP_METHOD);
String keyName[] = {};
Object keyValue[] = {};
return mSoapService.getSoapData(keyName,keyValue);
}
@Override
protected void onPostExecute(String result) {
mProcessDialog.dismiss();
if(result != null){
String strSuccess,strMessage;
try {
System.out.println("Info DRC Response =="+result);
JSONObject json_Event = new JSONObject(result);
if(json_Event != null)
{
strSuccess = json_Event.getString("SUCCESS").toString();
if(strSuccess.equals("OK")){
JSONArray json_quoteList = json_Event.getJSONArray("DRC_DETAIL");
if(json_quoteList !=null){
for(int i=0;i<json_quoteList.length();i++){
JSONObject job = json_quoteList.getJSONObject(i);
strWebtext = job.getString("content").toString();
System.out.println("strWebtext"+strWebtext);
}
mWebView.setBackgroundColor(Color.TRANSPARENT);
mWebView.loadData(strWebtext, "text/html", "utf-8");
}
}
else{
strMessage = json_Event.getString("MESSAGE").toString();
Toast.makeText(InfoDRC.this, Html.fromHtml(strMessage), Toast.LENGTH_LONG).show();
}
}
} catch ( Exception e ) {
e.printStackTrace();
}
}
else{
Toast.makeText(InfoDRC.this, Html.fromHtml(Constant.SERVERCONNERROR),Toast.LENGTH_SHORT).show();
}
super.onPostExecute(result);
}
}
=========================================================================
use soap library :- ksoap2-android-assembly-2.4-jar-with-dependencies.jar
1)//***************************************************************************************************************************** //**********************************************************************************************************************************
//This function is used for get Go button Json data
private class GetServerDataGo extends AsyncTask<String, String,String>{
private ProcessDialog mProcessDialog=null;
@Override
protected void onPreExecute() {
mProcessDialog = new ProcessDialog(Report.this,Constant.SERVER,Constant.LOADING);
super.onPreExecute();
cleardata();
mReportAdapter=new ReportAdapter(Report.this,alstProduct,alstUnitName,alstQuality,alstQuantity,alstAmount);;
updateDisplay();
}
@Override
protected String doInBackground(String... params) {
final String strListURL = getResources().getString(R.string.REPORT_URL);
ArrayList<NameValuePair> mNameValuePair = new ArrayList<NameValuePair>();
mNameValuePair.add(new BasicNameValuePair(Constant.REPORT_REQUEST.HDNACTION,Constant.REPORT_REQUEST.COLLECTION_REPORT));
mNameValuePair.add(new BasicNameValuePair(Constant.REPORT_REQUEST.ADMINUSERID,strUserid));
mNameValuePair.add(new BasicNameValuePair(Constant.REPORT_REQUEST.REPORT_PERIOD, "4"));
mNameValuePair.add(new BasicNameValuePair(Constant.REPORT_REQUEST.REPORT_STARTTIME,btnFrom.getText().toString()));
mNameValuePair.add(new BasicNameValuePair(Constant.REPORT_REQUEST.REPORT_ENDTIME,btnTo.getText().toString()));
return mCommonClass.PostConnection(strListURL, mNameValuePair);
}
@Override
protected void onPostExecute(String result) {
mProcessDialog.dismiss();
if(result != null){
try{
GetJSONData(new JSONObject(result));
mListView.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, alstProduct.size()*(30)));
}
catch(Exception e){
e.printStackTrace();
}
}
else{
Toast.makeText(Report.this, Constant.SERVERCONNERROR,Toast.LENGTH_SHORT).show();
}
super.onPostExecute(result);
}
}
***********************************
//*****************************************************************************************************************************
// For get data for report
public void GetJSONData(JSONObject mJSONObject){
String strRfp = null,strRfpAccepted = null,strGrossAmount = null,strTransactionAmount = null,strLeadTime = null,strGrossMargin = null,strAvgServiceTime = null;
try {
if(mJSONObject.getString(Constant.COMMON_JSON.TYPE).equals(Constant.COMMON_JSON.OK)){
strRfp = mJSONObject.getString(Constant.REPORT_JSON.RFP);
strRfpAccepted = mJSONObject.getString(Constant.REPORT_JSON.RFP_ACCEPTED);
strGrossAmount = mJSONObject.getString(Constant.REPORT_JSON.GROSS_AMOUNT);
strTransactionAmount = mJSONObject.getString(Constant.REPORT_JSON.AVG_AMOUNT);
strLeadTime =mJSONObject.getString(Constant.REPORT_JSON.AVG_LEAD_TIME);
strGrossMargin = mJSONObject.getString(Constant.REPORT_JSON.GROSS_MARGIN);
strAvgServiceTime = mJSONObject.getString(Constant.REPORT_JSON.AVG_SERVICE_TIME);
JSONArray mJSONArray1=mJSONObject.getJSONArray(Constant.REPORT_JSON.COLLECTION_DETAIL);
JSONArray mJSONArray2=mJSONObject.getJSONArray(Constant.REPORT_JSON.ACCEPCTED);
if (mJSONArray1 != null)
{
for (int i = 0; i < mJSONArray1.length(); i++) {
JSONObject mJSONObject2=mJSONArray1.getJSONObject(i);
alstProduct.add(mJSONObject2.getString(Constant.REPORT_JSON.PRODUCT_NAME).toString());
alstQuality.add(mJSONObject2.getString(Constant.REPORT_JSON.PRODUCT_QUALITY).toString());
alstQuantity.add(mJSONObject2.getString(Constant.REPORT_JSON.TOTAL_QUANTITY).toString());
alstUnitName.add(mJSONObject2.getString(Constant.REPORT_JSON.UNIT_NAME).toString());
alstAmount.add(mJSONObject2.getString(Constant.REPORT_JSON.TOTAL_PRICE).toString());
}
mReportAdapter=new ReportAdapter(Report.this,alstProduct,alstUnitName,alstQuality,alstQuantity,alstAmount);
mListView.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View arg1,int arg2, long arg3) {
if(mReportAdapter!=null){
DisplayListDialog(mReportAdapter);
}
}
});
mListView.setAdapter(mReportAdapter);
}
if (mJSONArray2 != null)
{
for (int i = 0; i < mJSONArray2.length(); i++) {
JSONObject mJSONObject3 = mJSONArray2.getJSONObject(i);
alstCNT.add(mJSONObject3.getString(Constant.REPORT_JSON.CNT));
alstAppStatus.add(mJSONObject3.getString(Constant.REPORT_JSON.APP_STATUS));
}
if(alstCNT.size()==0){
txtScheduled.setText("");
txtAppCompleted.setText("");
}
else if(alstCNT.size()==1){
txtScheduled.setText(alstAppStatus.get(0).toString()+"("+alstCNT.get(0).toString()+")");
}
else if(alstCNT.size()==2){
txtScheduled.setText(alstAppStatus.get(0).toString()+"("+alstCNT.get(0).toString()+")");
txtAppCompleted.setText(alstAppStatus.get(1).toString()+"("+alstCNT.get(1).toString()+")");
}
}
int intRfp = Integer.parseInt(strRfp);
int intRfpAccepted = Integer.parseInt(strRfpAccepted);
if(intRfp!=0 && intRfpAccepted!=0){
intEfficiency = intRfpAccepted*100/intRfp;
}
else {
intEfficiency = 0;
}
String strEfficiency = String.valueOf(intEfficiency).toString();
txtRFP.setText(strRfp.toString());
txtAccepted.setText(strRfpAccepted.toString());
txtEfficiency.setText(strEfficiency.toString());
txtCollectionGross.setText(strGrossAmount.toString());
txtTotalAmount.setText(strTransactionAmount.toString());
txtAvgLeadTime.setText(strLeadTime.toString());
txtServiceTime.setText(strAvgServiceTime.toString());
txtGrossMargin.setText(strGrossMargin.toString());
}else{
Toast.makeText(Report.this,mJSONObject.getString(Constant.COMMON_JSON.ERR_MSG).toString(), Toast.LENGTH_SHORT).show();
}
} catch (JSONException e) {
e.printStackTrace();
}
}
**************************************
/**This method use for PostConnection to Server
*/
public String PostConnection(String strUrl,ArrayList<NameValuePair> alstNameValuePair) {
InputStream mInputStream = null;
try {
//This is the default apacheconnection.
HttpClient mHttpClient = new DefaultHttpClient();
// HttpConnectionParams.setConnectionTimeout(mHttpClient.getParams(), 60000); //Timeout Limit
//Pathe of serverside
HttpPost mHttpPost = new HttpPost(strUrl);
if(alstNameValuePair!=null)
{
//post the valur you want to pass.
mHttpPost.setEntity(new UrlEncodedFormEntity(alstNameValuePair));
}
//get the valu from the saerverside as response.
HttpResponse mHttpResponse = mHttpClient.execute(mHttpPost);
HttpEntity mHttpEntity = mHttpResponse.getEntity();
mInputStream = mHttpEntity.getContent();
}
catch (Exception e) {
e.printStackTrace();
}
String strLine = null;
String strResult = "";
//convert response in to the string.
try {
if(mInputStream!=null){
BufferedReader mBufferedReader = new BufferedReader(new InputStreamReader(mInputStream,HTTP.UTF_8), 8);
StringBuilder mStringBuilder = new StringBuilder();
while((strLine = mBufferedReader.readLine()) != null) {
mStringBuilder.append(strLine + "\n");
}
strResult = mStringBuilder.toString();
mInputStream.close();
}
}
catch (Exception e) {
e.printStackTrace();
}
return strResult;
}
================================================
1)SoapService.java
package com.ovte.sadbhavna;
import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransportSE;
public class SOAPService {
private String SOAP_URL = null;
private String SOAP_ACTION =null;
private String SOAP_NAMESPACE = null;
private String SOAP_METHOD = null;
//default constructor
public SOAPService(String SOAP_URL,String SOAP_ACTION,String SOAP_NAMESPACE,String SOAP_METHOD) {
this.SOAP_URL=SOAP_URL;
this.SOAP_ACTION=SOAP_ACTION;
this.SOAP_NAMESPACE=SOAP_NAMESPACE;
this.SOAP_METHOD=SOAP_METHOD;
}
//**************************************************************************************************************************
//soap service for get server data
public String getSoapData(String keyName[],Object keyValue[]){
SoapObject soapRequest = null;
SoapSerializationEnvelope mSoapSerializationEnvelope = null;
HttpTransportSE androidHttpTransport = null;
Object soapResponse = null;
try{
soapRequest = new SoapObject(SOAP_NAMESPACE, SOAP_METHOD);
if(keyName!=null){
for(int i=0;i<keyName.length;i++){
soapRequest.addProperty(keyName[i], keyValue[i]);
}
}
mSoapSerializationEnvelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
mSoapSerializationEnvelope.setOutputSoapObject(soapRequest);
androidHttpTransport = new HttpTransportSE(SOAP_URL);
androidHttpTransport.call(SOAP_ACTION + SOAP_METHOD, mSoapSerializationEnvelope);
soapResponse = mSoapSerializationEnvelope.getResponse();
return (String)soapResponse.toString();
}catch(Exception e){
System.out.println("\nSoap Error : "+e.getMessage().toString());
return null;
}
}
}
===========================================
************************************************************************
============================================
//****************************************************************************************************************************
//This class is used for get Favourite Quote
private ProcessDialog mProcessDialog = null;
private class getFavouriteEventData extends AsyncTask<String, String, String> {
@Override
protected void onPreExecute() {
// TODO Auto-generated method stub
mProcessDialog = new ProcessDialog(EventFavourite.this, "FavouriteQuote", Constant.LOADING);
alstEvent_Id.clear();
alstEvent_Title.clear();
alstEvent_Start_Dt.clear();
alstEvent_End_Dt.clear();
alstEvent_Thumb_Image.clear();
alstEvent_Original_Image.clear();
alstEvent_Discription.clear();
super.onPreExecute();
}
@Override
protected String doInBackground(String... params) {
String SOAP_URL = getResources().getString(R.string.Webservice_URL);
String SOAP_ACTION = getResources().getString(R.string.SOAP_Action);
String SOAP_NAMESPACE = getResources().getString(R.string.SOAP_NAMESPACE);
String SOAP_METHOD = "GetFavouriteList";
mSoapService = new SOAPService(SOAP_URL, SOAP_ACTION, SOAP_NAMESPACE, SOAP_METHOD);
String keyName[] = {"user_id","type"};
Object keyValue[] = {strUserID.toString(),Constant.EVENT_FAVOURITE_RESPONSE};
return mSoapService.getSoapData(keyName, keyValue);
}
@Override
protected void onPostExecute(String result) {
mProcessDialog.dismiss();
if(result != null){
System.out.println("Favourite Quote ="+result);
String strSuccess,strMessage;
try {
JSONObject json_Add_Fav_Quote = new JSONObject(result);
if(json_Add_Fav_Quote != null)
{
strSuccess = json_Add_Fav_Quote.getString("SUCCESS").toString();
System.out.println("Favourite Quote strSuccess ="+strSuccess);
if(strSuccess.equals("OK")){
JSONArray json_quoteList = json_Add_Fav_Quote.getJSONArray("EVENT");
if(json_quoteList !=null){
for(int i=0;i<json_quoteList.length();i++){
JSONObject job = json_quoteList.getJSONObject(i);
alstEvent_Id.add(job.getString("ID").toString());
alstEvent_Title.add(job.getString("TITLE").toString());
alstEvent_Start_Dt.add(job.getString("EVENT_START_DT").toString());
alstEvent_End_Dt.add(job.getString("EVENT_END_DT").toString());
alstEvent_Thumb_Image.add(job.getString("THUMB_IMAGE").toString());
alstEvent_Original_Image.add(job.getString("ORIGINAL_IMAGE").toString());
alstEvent_Discription.add(job.getString("DETAIL").toString());
}
mEventFavouriteAdapter = new EventFavouriteAdapter(EventFavourite.this,alstEvent_Id,alstEvent_Title,alstEvent_Start_Dt,alstEvent_End_Dt,alstEvent_Thumb_Image,alstEvent_Original_Image,alstEvent_Discription);
lstEventFavourite.setAdapter(mEventFavouriteAdapter);
}
}
else{
strMessage = json_Add_Fav_Quote.getString("MESSAGE").toString();
Toast.makeText(EventFavourite.this,Html.fromHtml(strMessage), Toast.LENGTH_LONG).show();
}
}
} catch ( Exception e ) {
e.printStackTrace();
}
}
else{
Toast.makeText(EventFavourite.this,Html.fromHtml(Constant.SERVERCONNERROR),Toast.LENGTH_SHORT).show();
}
super.onPostExecute(result);
}
}
================================================
2)//****************************************************************************************************************************
//This class is used for get list of More By Author
private class getMoreByAuthorQuoteData extends AsyncTask<String, String, String> {
private ProcessDialog mProcessDialog = null;
@Override
protected void onPreExecute() {
// TODO Auto-generated method stub
mProcessDialog = new ProcessDialog(MoreByAuthor.this, "More By Author", Constant.LOADING);
super.onPreExecute();
}
// @Override
// protected String doInBackground(String... params)
// {
// String communityId=GetCommunity();
// String categoryId=GetCategory();
// String RequestEnvelope=String.format(Constant.CREATESUBSCRIPTION_REQUEST,strUserID.toString(),strAuthorName.toString(),communityId,categoryId);
// return GlobalClass.SOAPPostConnection(Constant.Webservice_URL,Constant.SOAP_Action, RequestEnvelope);
// }
@Override
protected String doInBackground(String... params) {
String SOAP_URL = getResources().getString(R.string.Webservice_URL);
String SOAP_ACTION = getResources().getString(R.string.SOAP_Action);
String SOAP_NAMESPACE = getResources().getString(R.string.SOAP_NAMESPACE);
String SOAP_METHOD = "SearchQuoteByAuthor";
mSoapService = new SOAPService(SOAP_URL, SOAP_ACTION, SOAP_NAMESPACE, SOAP_METHOD);
String keyName[] = {"user_id","SearchText","commnunity_id","category_id"};
String communityId=GetCommunity();
System.out.println("community id output===="+ communityId);
String categoryId=GetCategory();
System.out.println("categoryId output===="+ categoryId);
Object keyValue[] = {strUserID.toString(),strAuthorName.toString(),communityId,categoryId};
return mSoapService.getSoapData(keyName, keyValue);
}
@Override
protected void onPostExecute(String result) {
mProcessDialog.dismiss();
if(result != null){
Log.i("Sadbhavna",result.toString());
String strSuccess,strMessage;
try {
JSONObject json_MoreByAuthor = new JSONObject(result);
System.out.println("More by author==="+result.toString());
if(json_MoreByAuthor != null)
{
strSuccess = json_MoreByAuthor.getString("SUCCESS").toString();
if(strSuccess.equals("OK")){
JSONArray json_quoteList = json_MoreByAuthor.getJSONArray("QUOTE");
if(json_quoteList !=null){
for(int i=0;i<json_quoteList.length();i++){
JSONObject job = json_quoteList.getJSONObject(i);
alstID.add(job.getString("ID").toString());
alstQuote.add(job.getString("QUOTE").toString());
alstAuthor.add(job.getString("AUTHOR").toString());
}
mMoreByauthorAdapter = new MoreByAuthorAdapter(MoreByAuthor.this,alstID,alstQuote,alstAuthor);
lstMoreByAuthor.setAdapter(mMoreByauthorAdapter);
}
}
else{
strMessage = json_MoreByAuthor.getString("MESSAGE").toString();
Toast.makeText(MoreByAuthor.this, Html.fromHtml(strMessage), Toast.LENGTH_LONG).show();
}
}
} catch ( Exception e ) {
e.printStackTrace();
}
}
else{
Toast.makeText(MoreByAuthor.this, Html.fromHtml(Constant.SERVERCONNERROR),Toast.LENGTH_SHORT).show();
}
super.onPostExecute(result);
}
}
===========================================
3)////This class is used for get Category List
private class GetCategoryListData extends AsyncTask<String, String, String> {
private ProcessDialog mProcesCategoryDialog = null;
@Override
protected void onPreExecute() {
mProcesCategoryDialog = new ProcessDialog(SettingActivity.this, "Category", Constant.LOADING);
super.onPreExecute();
}
@Override
protected String doInBackground(String... params) {
String SOAP_URL = getResources().getString(R.string.Webservice_URL);
String SOAP_ACTION = getResources().getString(R.string.SOAP_Action);
String SOAP_NAMESPACE = getResources().getString(R.string.SOAP_NAMESPACE);
String SOAP_METHOD = "GetCategoryTable";
mSoapService = new SOAPService(SOAP_URL, SOAP_ACTION, SOAP_NAMESPACE, SOAP_METHOD);
String keyName[] = {"user_id"};
Object keyValue[] = {strUserID};
return mSoapService.getSoapData(keyName, keyValue);
}
@Override
protected void onPostExecute(String result) {
mProcesCategoryDialog.dismiss();
if(result != null){
String strSuccess,strMessage;
try {
System.out.println("Category Response : " + result);
JSONObject json_Category = new JSONObject(result);
if(json_Category != null)
{
strSuccess = json_Category.getString("SUCCESS").toString();
if(strSuccess.equals("OK")){
JSONArray jsonArray_CategoryList = json_Category.getJSONArray("CATEGORY");
if(jsonArray_CategoryList!=null){
OpenDatabase();
mDbHelper.DeleteCategoryList(mSQLiteDatabase);
for(int i=0;i<jsonArray_CategoryList.length();i++){
JSONObject jsonCategory_attribute=jsonArray_CategoryList.getJSONObject(i);
if(jsonCategory_attribute!=null){
int id =jsonCategory_attribute.getInt("id");
int root=jsonCategory_attribute.getInt("root");
int parent_id =jsonCategory_attribute.getInt("parent_id");
int lft=jsonCategory_attribute.getInt("lft");
int rgt =jsonCategory_attribute.getInt("rgt");
int level=jsonCategory_attribute.getInt("level");
String name=jsonCategory_attribute.getString("name").toString();
String status=jsonCategory_attribute.getString("status").toString();
int CNT=jsonCategory_attribute.getInt("CNT");
int selected =jsonCategory_attribute.getInt("selected");
mDbHelper.InsertCategoryList(mSQLiteDatabase, id, root, parent_id, lft, rgt, level, name, status,CNT,selected);
}
}
CloseDataBase();
Intent mIntent=new Intent(SettingActivity.this,ChangeCategory.class);
startActivity(mIntent);
}
}
else{
strMessage = json_Category.getString("MESSAGE").toString();
Toast.makeText(SettingActivity.this, Html.fromHtml(strMessage), Toast.LENGTH_LONG).show();
}
}
} catch ( Exception e ) {
e.printStackTrace();
}
}
else{
Toast.makeText(SettingActivity.this, Html.fromHtml(Constant.SERVERCONNERROR),Toast.LENGTH_SHORT).show();
}
super.onPostExecute(result);
}
}
================================================
4)//***************************************************************************************************************************
//This class is used for get More by author quote
private class getMoreByAuthorQuote extends AsyncTask<String, String, String> {
private ProcessDialog mProcessDialog = null;
@Override
protected void onPreExecute() {
// TODO Auto-generated method stub
mProcessDialog = new ProcessDialog(SearchActivity.this, "Quote data", Constant.LOADING);
ClearData();
super.onPreExecute();
}
@Override
protected String doInBackground(String... params) {
String SOAP_URL = getResources().getString(R.string.Webservice_URL);
String SOAP_ACTION = getResources().getString(R.string.SOAP_Action);
String SOAP_NAMESPACE = getResources().getString(R.string.SOAP_NAMESPACE);
String SOAP_METHOD = "SearchQuoteByAuthor";
mSoapService = new SOAPService(SOAP_URL, SOAP_ACTION, SOAP_NAMESPACE, SOAP_METHOD);
String communityId=GetCommunity();
String categoryId=GetCategory();
// System.out.println("categoryId output===="+ categoryId);
String keyName[] = {"user_id","SearchText","commnunity_id","category_id"};
Object keyValue[] = {strUserID.toString(),edtSearch.getText().toString(),communityId,categoryId};
return mSoapService.getSoapData(keyName, keyValue);
}
@Override
protected void onPostExecute(String result) {
mProcessDialog.dismiss();
GetSearchQuoteResponse(result);
super.onPostExecute(result);
}
}
//***************************************************************************************************************************
//This class is used for get serch quote by text
private class SearchQuoteText extends AsyncTask<String, String, String> {
private ProcessDialog mProcessDialog = null;
@Override
protected void onPreExecute() {
// TODO Auto-generated method stub
mProcessDialog = new ProcessDialog(SearchActivity.this, "Quote data", Constant.LOADING);
ClearData();
super.onPreExecute();
}
@Override
protected String doInBackground(String... params) {
String SOAP_URL = getResources().getString(R.string.Webservice_URL);
String SOAP_ACTION = getResources().getString(R.string.SOAP_Action);
String SOAP_NAMESPACE = getResources().getString(R.string.SOAP_NAMESPACE);
String SOAP_METHOD = "SearchQuote";
mSoapService = new SOAPService(SOAP_URL, SOAP_ACTION, SOAP_NAMESPACE, SOAP_METHOD);
String keyName[] = {"user_id","SearchText","commnunity_id","category_id"};
String communityId=GetCommunity();
String categoryId=GetCategory();
Object keyValue[] = {strUserID.toString(),edtSearch.getText().toString(),communityId,categoryId};
return mSoapService.getSoapData(keyName, keyValue);
}
@Override
protected void onPostExecute(String result) {
mProcessDialog.dismiss();
GetSearchQuoteResponse(result);
super.onPostExecute(result);
}
}
//********************************************************************************************************************************
//This function is used for get all search data
private void GetSearchQuoteResponse(String result){
ClearData();
if(result != null){
String strSuccess,strMessage;
try {
JSONObject json_MoreByAuthor = new JSONObject(result);
if(json_MoreByAuthor != null)
{
strSuccess = json_MoreByAuthor.getString("SUCCESS").toString();
if(strSuccess.equals("OK")){
JSONArray json_quoteList = json_MoreByAuthor.getJSONArray("QUOTE");
if(json_quoteList !=null){
for(int i=0;i<json_quoteList.length();i++){
JSONObject job = json_quoteList.getJSONObject(i);
alstID.add(job.getString("ID").toString());
alstQuote.add(job.getString("QUOTE").toString());
alstAuthorName.add(job.getString("AUTHOR").toString());
}
mSearchActivityAdapter = new SearchActivityAdapter(SearchActivity.this,alstID,alstQuote,alstAuthorName);
lstSearchAllQuoteList.setAdapter(mSearchActivityAdapter);
}
}
else{
strMessage = json_MoreByAuthor.getString("MESSAGE").toString();
ClearData();
mSearchActivityAdapter = new SearchActivityAdapter(SearchActivity.this,alstID,alstQuote,alstAuthorName);
lstSearchAllQuoteList.setAdapter(mSearchActivityAdapter);
Toast.makeText(SearchActivity.this, Html.fromHtml(strMessage), Toast.LENGTH_LONG).show();
}
}
} catch ( Exception e ) {
e.printStackTrace();
}
}
else{
Toast.makeText(SearchActivity.this, Html.fromHtml(Constant.SERVERCONNERROR),Toast.LENGTH_SHORT).show();
}
}
public void ClearData() {
alstID.clear();
alstAuthorName.clear();
alstQuote.clear();
========================================
5)//******************************************************************************************************************************
//This class is used for get Language list
private ProcessDialog mProcessDialog1 = null;
private class getDataForLanguage extends AsyncTask<String, String, String> {
@Override
protected void onPreExecute() {
// TODO Auto-generated method stub
mProcessDialog1 = new ProcessDialog(Register.this, "Login", Constant.LOADING);
super.onPreExecute();
}
@Override
protected String doInBackground(String... params) {
String SOAP_URL = getResources().getString(R.string.Webservice_URL);
String SOAP_ACTION = getResources().getString(R.string.SOAP_Action);
String SOAP_NAMESPACE = getResources().getString(R.string.SOAP_NAMESPACE);
String SOAP_METHOD = "getLanaguage";
mSoapService = new SOAPService(SOAP_URL, SOAP_ACTION, SOAP_NAMESPACE, SOAP_METHOD);
return mSoapService.getSoapData(null, null);
}
@Override
protected void onPostExecute(String result) {
mProcessDialog1.dismiss();
if(result != null){
String strSuccess,strMessage;
try {
JSONObject json_language = new JSONObject(result);
if(json_language != null)
{
strSuccess = json_language.getString("SUCCESS").toString();
if(strSuccess.equals("OK")){
JSONArray json_LanguageList = json_language.getJSONArray("LANGUAGE");
System.out.println("str_LanguageList==="+json_LanguageList.toString());
if(json_LanguageList !=null){
for(int i=0;i<json_LanguageList.length();i++){
JSONObject job = json_LanguageList.getJSONObject(i);
alstLanguageID.add(job.getString("ID").toString());
mArrayAdapterLanguageName.add(job.getString("LANAGUGE").toString());
alstLanguage_Short_Name.add(job.getString("SHORT_NAME").toString());
}
}
}
else{
strMessage = json_language.getString("MESSAGE").toString();
Toast.makeText(Register.this, Html.fromHtml(strMessage), Toast.LENGTH_LONG).show();
}
}
} catch ( Exception e ) {
e.printStackTrace();
}
}
else{
Toast.makeText(Register.this, Html.fromHtml(Constant.SERVERCONNERROR),Toast.LENGTH_SHORT).show();
}
super.onPostExecute(result);
}
}
======================================
<string name="Webservice_URL">http://180.211.110.196/php-projects/quote/admin/webservices/actions?ws=1</string>
<string name="SOAP_Action">http://180.211.110.196/php-projects/quote/admin/webservices/actions</string>
<string name="SOAP_NAMESPACE">http://180.211.110.196</string>
================================================
6) //**********************************************************************************************************************
//This class is used for get list ofEvents
private ProcessDialog mProcessDialog = null;
private class GetInfoDRC extends AsyncTask<String, String, String> {
@Override
protected void onPreExecute() {
// TODO Auto-generated method stub
mProcessDialog = new ProcessDialog(InfoDRC.this, "Get Info DRC", Constant.LOADING);
super.onPreExecute();
}
@Override
protected String doInBackground(String... params) {
String SOAP_URL = getResources().getString(R.string.Webservice_URL);
String SOAP_ACTION = getResources().getString(R.string.SOAP_Action);
String SOAP_NAMESPACE = getResources().getString(R.string.SOAP_NAMESPACE);
String SOAP_METHOD = "DrcInfo";
mSoapService = new SOAPService(SOAP_URL, SOAP_ACTION, SOAP_NAMESPACE, SOAP_METHOD);
String keyName[] = {};
Object keyValue[] = {};
return mSoapService.getSoapData(keyName,keyValue);
}
@Override
protected void onPostExecute(String result) {
mProcessDialog.dismiss();
if(result != null){
String strSuccess,strMessage;
try {
System.out.println("Info DRC Response =="+result);
JSONObject json_Event = new JSONObject(result);
if(json_Event != null)
{
strSuccess = json_Event.getString("SUCCESS").toString();
if(strSuccess.equals("OK")){
JSONArray json_quoteList = json_Event.getJSONArray("DRC_DETAIL");
if(json_quoteList !=null){
for(int i=0;i<json_quoteList.length();i++){
JSONObject job = json_quoteList.getJSONObject(i);
strWebtext = job.getString("content").toString();
System.out.println("strWebtext"+strWebtext);
}
mWebView.setBackgroundColor(Color.TRANSPARENT);
mWebView.loadData(strWebtext, "text/html", "utf-8");
}
}
else{
strMessage = json_Event.getString("MESSAGE").toString();
Toast.makeText(InfoDRC.this, Html.fromHtml(strMessage), Toast.LENGTH_LONG).show();
}
}
} catch ( Exception e ) {
e.printStackTrace();
}
}
else{
Toast.makeText(InfoDRC.this, Html.fromHtml(Constant.SERVERCONNERROR),Toast.LENGTH_SHORT).show();
}
super.onPostExecute(result);
}
}
=========================================================================
use soap library :- ksoap2-android-assembly-2.4-jar-with-dependencies.jar
No comments:
Post a Comment