2

I have a SharePoint site that makes calls to a public web API (Melissa Data) using a WCF client. I have the endpoints configured in the web.config like so:

<system.serviceModel>
    <bindings>
        <basicHttpBinding>
            <binding name="PropertyWSSOAPEndpoint">
                <security mode="Transport" />
            </binding>
        </basicHttpBinding>
    </bindings>
    <client>
        <endpoint address="https://property.melissadata.net/v3/SOAP/Service.svc"
            binding="basicHttpBinding" bindingConfiguration="PropertyWSSOAPEndpoint"
            contract="MelissaDataPropertyService.IService" name="PropertyWSSOAPEndpoint" />
    </client>
</system.serviceModel>

I instantiate my client like so:

MelissaDataPropertyService.ServiceClient PropertyServiceClient = new MelissaDataPropertyService.ServiceClient();

This all works fine and dandy, but I've heard it is bad practice to put site configuration values into the SharePoint IIS web.config. Can someone please explain to me a.) why this is a bad practice, and b.) how to configure and instantiate the WCF client object without using the web.config?

Your Answer

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

Browse other questions tagged or ask your own question.