Shone
Shone

Reputation: 86

How can a WCF Service obtain Query Parameters?

I'm working on an Azure service for a Windows Phone app. I need the Azure Service to access the users' OneDrive. Following this article, my scenario should be:

After investigating a lot in Service, I still can't find a way to capture the query parameter in my web service. As I am new to this area, I don't know where to focus on. I'll be really appreciated if you can give my an advise or answer my following questions:

  1. Can I access the service just using the url with parameter in a browser? How can I see if the service is working properly?
  2. An article mentioned using WCF [Web Get] attribute to get Query Parameters, but I still don't know how to implement both the IService1.cs and Service1.cs file, could you give me a sample about how to access the value of Query Parameter?

Thanks!

Upvotes: 3

Views: 1432

Answers (1)

codeworx
codeworx

Reputation: 2745

I'm not sure if i understand your problem properly but if you want your RESTfull WCF service to be the callback receiver for the request code, your Service must be hosted with a WebHttpBinding and a ServiceContract similar to this one.

[ServiceContract]
public interface IService
{
    [WebGet(UriTemplate = "callback?code={requestCode}")]
    void OAuthCallback(string requestCode);
}

So if the base address of your Service is "http://service.mydomain.com/MyService.svc" the OAuthCallback Method will be called when a http GET request to "http://service.mydomain.com/MyService.svc/callback?code=RequestCode" is made.

Upvotes: 1

Related Questions