1

I have created a SharePoint feature that has an application page which uses a wcf service to get some data. I have added a service reference to the WCF service using vs2010 service reference options. At the moment I have hard coded the service url (for ex., http://localhost:2000/vti_bin/service1.svc) and passing the url to the proxy.

When I add the service reference it also creates app.config which contains the necessary service bindings settings. When I deploy the feature how does the application page use service bindings and do I need to manually add the Service URL and Service Bindings settings to the web.config file for each web application.

What is the recommended approach to reference a WCF service in a application page?

1 Answer 1

0

You can consume WCF in configless way by providing the necessary settings programmatically. Below is an example when using WSHttpbinding with relevant settings:

 WSHttpBinding bind = new WSHttpBinding(SecurityMode.None); bind.MaxBufferPoolSize = 2147483647; bind.MaxReceivedMessageSize = 2147483647; EndpointAddress endpoint = new EndpointAddress(new Uri(serviceURL));

serviceClient=new serviceClient(bind, endpoint);

The second option is to create a new folder for your application page and convert it to virtual directory. Here, You can place a custom web.config with just the service settings you need.

2
  • Thanks Amit... Do I need to copy the ServiceURL to the web.config file of each web application? At present I have hardcoded the service URL in application page. Commented Dec 13, 2011 at 23:20
  • You can keep the url in the same web.config as I mentioned above. No need to do it for separate web applications then. Commented Dec 14, 2011 at 17:01

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.