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>
- 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
Hope these tips will come in handy when working with WCF web services.
Cheers
Adam
Adam
No comments:
Post a Comment