Wonder how many open connections you have? Run this:
SELECT DB_NAME(dbid) as 'Database', COUNT(dbid) as 'Open Connections' from master.dbo.sysprocesses with (nolock)
GROUP BY dbid
Results are:
Database Open Connections
SomeDBName 1
Friday, July 22, 2011
Wednesday, July 20, 2011
UnknownHostException in Android
Following the last post, if you get UnknownHostException when calling your web service from Android verify that your element is set under your manifest and not as an attribute in your element.
NetworkOnMainThreadException in Android
Something that used to work in Android 2.2 but stopped working in Android 3.0+ (Honeycomb) is executing long running processes (Http calls for example) from the main thread. The exception you get is NetworkOnMainThreadException. To fix this either utilize AsyncTask OR Handler patterns.
The following is my example for AsyncTask:
... this is inside an activity ...
public void onCallService(View v){
ServiceTask task = new ServiceTask();
task.execute(new String[]{"http://www.ultimateworkoutdiary.com/BestStocksService.svc/10/DAY/1/ACTUAL"});
}
private class ServiceTask extends AsyncTask {
@Override
protected String doInBackground(String... urls) {
String response = "";
for (String url : urls) {
DefaultHttpClient client = new DefaultHttpClient();
HttpGet httpGet = new HttpGet(url);
try {
HttpResponse execute = client.execute(httpGet);
InputStream content = execute.getEntity().getContent();
BufferedReader buffer = new BufferedReader(
new InputStreamReader(content));
String s = "";
while ((s = buffer.readLine()) != null) {
response += s;
}
} catch (Exception e) {
e.printStackTrace();
}
}
return response;
}
@Override
protected void onPostExecute(String result) {
Log.d("output", result);
}
}
The following is my example for AsyncTask:
... this is inside an activity ...
public void onCallService(View v){
ServiceTask task = new ServiceTask();
task.execute(new String[]{"http://www.ultimateworkoutdiary.com/BestStocksService.svc/10/DAY/1/ACTUAL"});
}
private class ServiceTask extends AsyncTask
@Override
protected String doInBackground(String... urls) {
String response = "";
for (String url : urls) {
DefaultHttpClient client = new DefaultHttpClient();
HttpGet httpGet = new HttpGet(url);
try {
HttpResponse execute = client.execute(httpGet);
InputStream content = execute.getEntity().getContent();
BufferedReader buffer = new BufferedReader(
new InputStreamReader(content));
String s = "";
while ((s = buffer.readLine()) != null) {
response += s;
}
} catch (Exception e) {
e.printStackTrace();
}
}
return response;
}
@Override
protected void onPostExecute(String result) {
Log.d("output", result);
}
}
Monday, July 18, 2011
WCF - Authentication Scheme error
So your wcf service works locally but not on IIS and the error you get is a combination
IIS by default selects a number of authentication schemes. For me, the defaults were Anonymous and Windows. WCF binding only supports specification for one scheme.
What to do?
Go to your Authentication settings in IIS and uncheck all but one scheme (I left anonymous on since I don't care about securing my specific service).
IIS specified authentication schemes 'IntegratedWindowsAuthentication, Anonymous', but the binding only supports specification of exactly one authentication scheme. Valid authentication schemes are Digest, Negotiate, NTLM, Basic, or Anonymous. Change the IIS settings so that only a single authentication scheme is used.
What does this mean?IIS by default selects a number of authentication schemes. For me, the defaults were Anonymous and Windows. WCF binding only supports specification for one scheme.
What to do?
Go to your Authentication settings in IIS and uncheck all but one scheme (I left anonymous on since I don't care about securing my specific service).
Subscribe to:
Posts (Atom)