Click here to Skip to main content
15,887,267 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
I want to code for android application in which there are three parameters which i want to pass to php-webservice.

What I have tried:

I have wrritten following code to pass three parameters to web service

Code:

private void getProductStock(String productStock_StyleID, String productStock_SizeID, String productStock_colorID){
if(cc.isNetAvailable(context)) {
String url = CommonClass.MainWebUrl + CommonClass.WebApi.GET_PRODUCT_STOCK;
Map params = new HashMap();

params.put("style_id", productStock_StyleID);
params.put("size_id", productStock_SizeID);
params.put("color", productStock_colorID);

fetchProductStockQuantity(ViewBrandsActivity.this, url, params);

} else {
CommonClass.showToast(getApplicationContext(), CommonClass.ErrorMessage.Network_Error);
}
}


public void fetchProductStockQuantity(final Activity activity, String url, Map param) {

Map map = new HashMap();
map = param;
cc.showProgressDialog("Fetching stock quantity..", activity);
CustomRequest customRequest = new CustomRequest(Request.Method.POST,
url, param, new Response.Listener<jsonobject>() {
@Override
public void onResponse(JSONObject jsonObject) {
// Log.e("jsonObject", "" + jsonObject.toString());
handleProductStockDataResponse(jsonObject);
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError volleyError) {
System.out.println("Error In Web : " + volleyError.getMessage());
cc.cancelProgressDialog(activity);
}
}) {
@Override
public Map<string,> getHeaders() throws AuthFailureError {
HashMap<string,> headers = new HashMap<string,>();
//headers.put("Content-Type", "application/x-www-form-urlencoded");
return headers;
}
};
int socketTimeout = 100000;//60 seconds - change to what you want
RetryPolicy policy = new DefaultRetryPolicy(socketTimeout,
DefaultRetryPolicy.DEFAULT_MAX_RETRIES, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT);
customRequest.setRetryPolicy(policy);
// Adding request to request queue
AppController.getInstance().addToRequestQueue(customRequest, url);


}



this webservice returns a value which i want to display in my android application.
How do I check if the 3 parameters are passed to the webservice?
Please tell me above code is currect or not and also tell me how to show that return value in my android application.
Posted
Comments
Richard MacCutchan 3-Jun-16 10:18am    
The way to tell if your code is correct is to run it, either stand-alone, or in the debugger. That way you can then provide some useful information with your question.
Sergey Alexandrovich Kryukov 3-Jun-16 10:44am    
Just checking: do you understand that you work on the client level, in relationship to this Web site, and that it totally abstracted from the server side software; the client code cannot even "know" if it is a PHP code or not?

And "check if... parameters are passed to the Web site" is done on this site; as you say, in PHP. What do you really mean by that "check"? What's the problem. On client side, you just send some HTTP request to the site, receive HTTP response and do something with it.

—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900