0151 355 4555

.NET 3.5 and later Service References

To add a reference to any of data8's web services, first identify the URL for the service. This can be found in the service documentation section - the URL for each service is listed at the top of the first documentation page for each service. For example, the URL for the address validation service is http://webservices.data-8.co.uk/addresscapture.asmx and can be found on the documentation page for the address validation service.

Once you have the URL for the service you are interested in, in Visual Studio, expand the project node in Solution Explorer, right-click on References and click on "Add Service Reference". You will now see the "Add Service Reference" dialog.

Add Service Reference dialog

Paste in the URL for the service you identified from the service documentation earlier and click "Go". You will now be shown the details of the service and supported operations, and the "Namespace" box will be enabled.

Add Service Reference dialog with URL entered

Enter a more useful name in the "Namespace" text box. For example, when adding a reference to the AddressCapture service you might use the name "AddressCapture". Finally, click on "OK" and a reference to the web service will be added to your project.

Service Reference in Solution Explorer

In order to call the web service, first include the appropriate namespace. This will be the default namespace of your project followed by the namespace you entered in the "Add Service Reference" dialog.

You can then create an instance of the web service and start calling methods on it as illustrated in the sample below.

Please refer to the service documentation for details on what methods are available for each service and how they should be used. C# and VB.NET samples are included at the bottom of each documentation page to illustrate the use of the method once the appropriate service reference has been added.

using YourProject.AddressCapture;

namespace YourProject
  public class YourClass
    public void Sample()
      var proxy = new AddressCaptureSoapClient();
      var result = proxy.GetFullAddressSimple(
        "CH2 4NE",

The proxy class uses the app.config or web.config file to determine the URL of the service and a number of configuration options. The project you added the service reference to will have the following details added to its config file automatically:

      <binding name="AddressCaptureSoap" />
      <binding name="AddressCaptureSoap12">
        <textMessageEncoding messageVersion="Soap12" />
        <httpTransport />
    <endpoint address="http://webservices.data-8.co.uk/addresscapture.asmx"
      binding="basicHttpBinding" bindingConfiguration="AddressCaptureSoap"
      contract="AddressCapture.AddressCaptureSoap" name="AddressCaptureSoap" />
    <endpoint address="http://webservices.data-8.co.uk/addresscapture.asmx"
      binding="customBinding" bindingConfiguration="AddressCaptureSoap12"
      contract="AddressCapture.AddressCaptureSoap" name="AddressCaptureSoap12" />

If you try to run your code with this default configuration, you will receive the exception:

"An endpoint configuration section for contract 'AddressCapture.AddressCaptureSoap' could not be loaded because more than one endpoint configuration for that contract was found. Please indicate the preferred endpoint configuration section by name."

Because our services support two versions of the SOAP standard, the Add Service Reference procedure added support for both versions and the .NET runtime now does not know which version to use. To fix this problem, delete the second <endpoint> element from the config file.

If you have added the service reference to a class library project, you will need to incorporate the <system.serviceModel> element in the main app.config or web.config file for your application or website. Otherwise you will receive the exception:

"Could not find default endpoint element that references contract 'AddressCapture.AddressCaptureSoap' in the ServiceModel client configuration section. This might be because no configuration file was found for your application, or because no endpoint element matching this contract could be found in the client element."