Skip to main content

Microsoft Silverlight

Unanswered Question REST Service in SilverlightRSS Feed

(0)

gareesilver
gareesilver

Member

Member

17 points

14 Posts

REST Service in Silverlight

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.Lutay
Sergey.L...

Contributor

Contributor

7198 points

1,340 Posts

Re: REST Service in Silverlight

Hi,

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.

 

 

(If this has answered your question, please click on "mark as answer" on this post. Thank you!)

Blog

Twitter

Sincerely,
Sergey Lutay

Min-Hong Tang - MSFT
Min-Hong...

Contributor

Contributor

3375 points

377 Posts

Re: REST Service in Silverlight

Hi,

   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

Min-Hong Tang
Microsoft Online Community Support

Please remember to mark the replies as answers if they help and unmark them if they provide no help.
  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities