Tuesday, July 28, 2015

WCF Service to Internet

 
 
Here are the steps to convert the WCF Service to be accessed from the browser over the internet.
 
1. Add the 'WebGet' parameter to the interface.
2. Add the endpoint binding to the Web config file.
3. Add the endpoint behavior to the Web config file.
 
Now the service should be exposed over the internet.
    
[ServiceContract]
    public interface IServiceSomeName
    {
        [WebGet(UriTemplate = "gettoken", ResponseFormat = WebMessageFormat.Json)]
        [OperationContract]
        string GetToken();
        [OperationContract]
        string GetData(int value);
 
        [OperationContract]
        CompositeType GetDataUsingDataContract(CompositeType composite);
        // TODO: Add your service operations here
    }
    <services><service name="WcfServiceSomeName.ServiceSomeName">
        <endpoint binding="webHttpBinding" contract="WcfServiceSomeName.IServiceSomeName"  behaviorConfiguration="webHttp"/>
      </service>
    </services>
 
 
 
 
      <endpointBehaviors>
        <behavior name="webHttp">
          <webHttp/>
        </behavior>
      </endpointBehaviors>
 Also I noticed one more interesting fact.
Quote
- WCF Data Services don't support passing parameters in the request body or headers, they have to be present in the URL of the request. This makes it hard to pass long values.

Unquote
I found this info in the below link.
 
 
Hope these tips will come in handy when working with WCF web services.
Cheers
Adam
 
 

No comments:

Post a Comment

All Blogs so far ...