Hi,
I have a webservice like:
[WebMethod()]
[ScriptMethod(ResponseFormat = ResponseFormat.Xml)]
public string userRequest(ClsRequest objClsRequest)
{
string sMessage = string.Empty;
ClsUserRequestProcess objClsUserRequestProcess = new ClsUserRequestProcess();
sMessage = objClsUserRequestProcess.userRequestProcess(objClsRequest);
return sMessage;
}
---------------------------
public class ClsUserRequestProcess
{
public string userRequestProcess(ClsRequest objClsRequest)
{
ClsResult objClsResult = new ClsResult();
ClsCommonMethods objClsCommonMethods = new ClsCommonMethods();
string sMessage = string.Empty;
string sRequestType = objClsRequest.sRequestType;
string sRequestFor = objClsRequest.sServiceRequest;
int iSuccess = 0;
try
{
if (sRequestType.ToUpper() == "APP")
{
#region App requests
using (SqlConnection con = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["myConnectionString"].ConnectionString))
{
con.Open();
if (objClsCommonMethods.validateUser(objClsRequest.iUserId, objClsRequest.sProvideId))
{
if (objClsCommonMethods.validateApp(objClsRequest.iAppId, objClsRequest.sBundleId))
{
if (sRequestFor.ToUpper() == "FIRSTREQUEST")
{
#region User record update after app request and before installation
string sUserAppQry = "Select Count(*) as UserAppCount from tblUserActivityTracking" +
" where UserId=" + objClsRequest.iUserId + " and ProviderId='" + objClsRequest.sProvideId + "'" +
" and AppId=" + objClsRequest.iAppId + " and BundleId='" + objClsRequest.sBundleId + "'" +
" and Activity='App'";
using (SqlDataAdapter sqlDa = new SqlDataAdapter(sUserAppQry, con))
{
DataSet dsUserApp = new DataSet();
sqlDa.Fill(dsUserApp);
if (dsUserApp != null && dsUserApp.Tables.Count > 0 && dsUserApp.Tables[0].Rows.Count > 0 && Convert.ToInt32(dsUserApp.Tables[0].Rows[0]["UserAppCount"]) == 0)
{
string sAddUserAppQry = "Insert into tblUserActivityTracking(Activity, UserId, ProviderId, BundleId, " +
" AppId, IsRequest, RequestDate, EarnPoint, Status)" +
" values('App'," + objClsRequest.iUserId + ",'" + objClsRequest.sProvideId + "'," +
" '" + objClsRequest.sBundleId + "'," + objClsRequest.iAppId + "," +
" 1, getDate(), 0, 1)";
SqlCommand cmdAddUserApp = new SqlCommand(sAddUserAppQry);
cmdAddUserApp.Connection = con;
iSuccess = cmdAddUserApp.ExecuteNonQuery();
if (iSuccess > 0)
{
objClsResult.bResult = true;
objClsResult.sMessage = "Success";
}
else
{
objClsResult.bResult = false;
objClsResult.sMessage = "Error";
}
}
else
{
string sUpdateUserAppQry = "Update tblUserActivityTracking set IsRequest=1, RequestDate=getDate()" +
" where UserId=" + objClsRequest.iUserId + " and ProviderId='" + objClsRequest.sProvideId + "'" +
" and AppId=" + objClsRequest.iAppId + " and BundleId='" + objClsRequest.sBundleId + "'" +
" and Activity='App'";
SqlCommand cmdUpdateUserApp = new SqlCommand(sUpdateUserAppQry);
cmdUpdateUserApp.Connection = con;
iSuccess = cmdUpdateUserApp.ExecuteNonQuery();
if (iSuccess > 0)
{
objClsResult.bResult = true;
objClsResult.sMessage = "Success";
}
else
{
objClsResult.bResult = false;
objClsResult.sMessage = "Error";
}
}
}
#endregion
}
else if (sRequestFor.ToUpper() == "INSTALL")
{
#region User record update after app installation
string sUserAppQry = "Select Count(*) as UserAppCount from tblUserActivityTracking" +
" where UserId=" + objClsRequest.iUserId + " and ProviderId='" + objClsRequest.sProvideId + "'" +
" and AppId=" + objClsRequest.iAppId + " and BundleId='" + objClsRequest.sBundleId + "'" +
" and Activity='App' and IsRequest=1";
using (SqlDataAdapter sqlDa = new SqlDataAdapter(sUserAppQry, con))
{
DataSet dsUserApp = new DataSet();
sqlDa.Fill(dsUserApp);
if (dsUserApp != null && dsUserApp.Tables.Count > 0 && dsUserApp.Tables[0].Rows.Count > 0 && Convert.ToInt32(dsUserApp.Tables[0].Rows[0]["UserAppCount"]) > 0)
{
string sUpdateUserAppQry = "Update tblUserActivityTracking set IsInstall=1, InstallDate=getDate()" +
" where UserId=" + objClsRequest.iUserId + " and ProviderId='" + objClsRequest.sProvideId + "'" +
" and AppId=" + objClsRequest.iAppId + " and BundleId='" + objClsRequest.sBundleId + "'" +
" and Activity='App' and IsRequest=1";
SqlCommand cmdUpdateUserApp = new SqlCommand(sUpdateUserAppQry);
cmdUpdateUserApp.Connection = con;
iSuccess = cmdUpdateUserApp.ExecuteNonQuery();
if (iSuccess > 0)
{
objClsResult.bResult = true;
objClsResult.sMessage = "Success";
}
else
{
objClsResult.bResult = false;
objClsResult.sMessage = "Error";
}
}
else
{
objClsResult.bResult = false;
objClsResult.sMessage = "Error";
}
}
#endregion
}
}
else
{
objClsResult.bResult = false;
objClsResult.sMessage = "Invalid Request";
}
}
else
{
objClsResult.bResult = false;
objClsResult.sMessage = "Invalid User";
}
}
#endregion
}
}
catch (Exception ex)
{
objClsResult.bResult = false;
objClsResult.sMessage = "Error";
}
finally
{
sMessage = JsonConvert.SerializeObject(objClsResult);
}
return sMessage;
}
}
and consumming in MVC 4.0 project by adding service reference and code like:
public class AppRequestsController : Controller
{
InstaearnEntities objInstaearnEntities = new InstaearnEntities();
public ActionResult FirstRequest(int userId, string providerId, string bundleId, int appId)
{
OnlineInstaearnServiceRef.InstaearnServiceSoapClient objInstaearnServiceSoapClient = new OnlineInstaearnServiceRef.InstaearnServiceSoapClient("InstaearnServiceSoap1");
OnlineInstaearnServiceRef.ClsRequest objClsRequest = new OnlineInstaearnServiceRef.ClsRequest();
objClsRequest.iUserId = userId;
objClsRequest.sProvideId = providerId;
objClsRequest.sBundleId = bundleId;
objClsRequest.iAppId = appId;
objClsRequest.sRequestType = "App";
objClsRequest.sServiceRequest = "FirstRequest";
string sMessage = string.Empty;
sMessage = objInstaearnServiceSoapClient.userRequest(objClsRequest);
objInstaearnServiceSoapClient.as
return Redirect("https://play.google.com/store/apps/details?id=" + bundleId);
}
}
It is working fine on localhost but throwing error on online server :
A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond XXX.XXX.XX.XX.XX
Please suggest me some solution.
Thanks in advance