TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Rupesh Kahane
102
19.1k
4.2m
WCF Service Connection Failure In Xamarin Android
Nov 10 2016 5:18 AM
I have created an WCF Service and hosted it on Server.
This application having simple functionality like Get record from a SQL Server database.
Now I am executing this WCF Service on button click event in Xamarin Android of MainActivity.cs
But this is not working. Give me some solution. If I run the same service code in Normal C# application then it is working fine.
Bellow is my code.
public
class
MainActivity : Activity
{
TextView myLabel;
EditText txtUserName;
Button myButton;
HttpClient Client;
private
string
URIString;
protected
override
void
OnCreate(Bundle bundle)
{
Microsoft.WindowsAzure.MobileServices.CurrentPlatform.Init();
base
.OnCreate(bundle);
SetContentView(Resource.Layout.Main);
myLabel = FindViewById<TextView>(Resource.Id.myLabel);
txtUserName = FindViewById<EditText>(Resource.Id.txtUserName);
myButton = FindViewById<Button>(Resource.Id.myButton);
myButton.Click += myButton_Click;
}
void
myButton_Click(
object
sender, EventArgs e)
{
var textview = FindViewById<TextView>(Resource.Id.textView3);
var s = GetData();
var finalResult = s;
textview.Text = finalResult.ToString();
}
public
string
GetData()
{
try
{
var request = HttpWebRequest.Create(
"http://xxxxx:2498/MyRestService.svc/GetEmployee/1"
);
request.ContentType =
"application/json"
;
request.Method =
"GET"
;
using
(HttpWebResponse response = request.GetResponse()
as
HttpWebResponse)
{
using
(StreamReader reader =
new
StreamReader(response.GetResponseStream()))
{
var content = reader.ReadToEnd();
var cleanValue = System.Text.RegularExpressions.Regex.Replace(content, @
"[^a-zA-Z0-9]"
,
""
);
return
cleanValue.ToString();
}
}
}
catch
(Exception ex)
{
return
ex.Message.ToString();
}
var t =
"error occured !!!"
;
return
Convert.ToString(t);
}
}
Getting error : Connection failure (Access denied)
Give me some solution.
Thanks
Reply
Answers (
1
)
how to import material design google icons into android
How to create session in Xamarin Android after login