Skip to main content
Home Forums General Silverlight New Features in Silverlight 3 REST Service in Silverlight
2 replies. Latest Post by Min-Hong Tang - MSFT on November 3, 2009.
(0)
gareesilver
Member
17 points
14 Posts
10-28-2009 5:21 AM |
Hi,
I wrote a Rest Service in WCF. My method look like this
[OperationContract] [WebInvoke(UriTemplate = "/Insert", BodyStyle = WebMessageBodyStyle.Bare, RequestFormat = WebMessageFormat.Xml, ResponseFormat = WebMessageFormat.Xml)] string InsertNumbers(NumberService num);
I hosted my service in IIS and when i try to run it using my ip addr, It asks for username and Password. But when i gave it is not accepting.
Also i am unable to call this service from Silverlight. I used like this in Xaml.cs file.
WebClient cnt = new WebClient(); Uri uri = new Uri(baseuri); cnt.DownloadStringAsync(uri); cnt.DownloadStringCompleted += new DownloadStringCompletedEventHandler(cnt_DownloadStringCompleted);
Can anyone help me in this issue?
Sergey.L...
Contributor
7198 points
1,340 Posts
10-28-2009 5:29 AM |
gareesilver: It asks for username and Password.
Seems like request to your IIS over network need authentication. Can you show a format of data which you enters for that box?
gareesilver:Also i am unable to call this service from Silverlight
Does your application and serivce host in one domain? If not, so there are cross domain request, look http://msdn.microsoft.com/en-us/library/cc645032(VS.95,classic).aspx.
Min-Hong...
3375 points
377 Posts
11-03-2009 1:12 AM |
My opinion is , there is something wrong when you call the wcf service. May i see the download uri string there.
Here is my example, I tested it.
My Service Contract :
public interface IRestService { [OperationContract] [WebGet(UriTemplate = "/GetData?id={s}", BodyStyle = WebMessageBodyStyle.Bare, RequestFormat = WebMessageFormat.Xml, ResponseFormat = WebMessageFormat.Xml)] string GetData(string s); }
My Calling:
WebClient webClient = new WebClient(); WebClient.DownloadStringCompleted += new DownloadStringCompletedEventHandler(webClient_DownloadStringCompleted); webClient.DownloadStringAsync(new Uri("http://localhost:29595/MyRestService.svc/GetData?id=3333"));
Best Regards