0

I have written feature which updates web.config in inetpub folder under default port 80. It updates web.config with service model. This is not complete code but some code in featureeventreceiver

string endpointbindings = @"<system.serviceModel>
                        <bindings>
                            <wsHttpBinding>
                            <binding name=""CustomBinding_ICalcService"">
                                <security mode=""None"" />
                            </binding>
                            </wsHttpBinding>
                        </bindings>
                        <client>
                            <endpoint address=""http://myservice/CalcService.svc""
                                binding=""wsHttpBinding"" bindingConfiguration=""CustomBinding_ICalcService""
                                contract=""CalcService.ICalcService"" name=""CustomBinding_ICalcService"" />
                        </client>
                        </system.serviceModel>";

        webApplication = properties.Feature.Parent as SPWebApplication;

        webApplication .Update();

        webApp.Farm.Services.GetValue<SPWebService>().ApplyWebConfigModifications();

Now i want to depoy this package in different environments like Test env, Integration env and Production env. I want to change service model with different endpoint address as per environment where solution will be deployed. How i identify if its production env or test env or integration env.

0

There are many ways to automate this

  1. Identify current URL and put if..else condition to load appropriate endpoint address

  2. Store endpointbindings xml in a list (hidden from end user) or read it from Web Property Bag(User SharePoint Designer or PowerShell for setting the value). On feature activation read it from that list/property bag and make the update in web config file.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.