Compartilhar via


Adding configuration information

To add a service to the Dynamics GP Service framework, you must configure your service to work with the framework. Typically, configuration information is added to a configuration file for your service..

To add a configuration file for you service, complete the following steps:

  1. Add a configuration file to your service project.

    In the Visual Studio, click Project, and then click Add New Item. From the Add New Item window, click General in the Categories list. In the list of Templates, click Application Configuration File. In the Name box, enter a name that uniquely identifies your service configuration file. Click Add. The file is added to your service project.

    For example, the sample Leads service includes a file named SampleLeadService.config.

  2. Add cache settings for the service.

    Add a section to the configuration file that specifies cache settings for your service. Typically, you use the same cache configuration as the Dynamic GP Service. Use the cache configuration settings found in the WSCachingConfiguration.config file.

    The following code example shows how to import the caching setting from the Dynamics GP Service into the configuration file of sample Leads service. Notice how the cachingConfiguration node specifies the WSCachingConfiguration.config file.

    <?xml version="1.0" encoding="utf-8" ?>
    

<configuration> <configSections> <section name="cachingConfiguration" type="Microsoft.Dynamics.EnterpriseLibrary.Caching. Configuration.CacheManagerSettings, Microsoft.Dynamics.EnterpriseLibrary.Caching, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/> </configSections> <cachingConfiguration configSource="WSCachingConfiguration.config"/> </configuration>

  1. Add application settings.

    To use the same application setting as the Dynamics GP Service, add <appSettings> to your configuration. Import the application setting from the WSServiceAppSettings.config file of the Dynamic GP Service.

    <appSettings file="WSServiceAppSettings.config"/>
    
  1. Add bindings.

    Add a <system.serviceModel> node to your configuration file. Add the <bindings> node as a child of <system.serviceModel>, and add binding entries for the Tenant Discovery Service endpoint.

    <system.serviceModel>
    <bindings configSource="WSBindings.config"/>
    

</system.serviceModel>

  1. Add services.

    After <bindings>, add <services> as a child node of <system.serviceModel>. Use <services> to add configuration information for each endpoint.

    <system.serviceModel>
    <bindings configSource="WSBindings.config"/>
    <services>
    
    </services>
    

</system.serviceModel>

  1. Add the native service

    If your service uses the native endpoint of the Dynamics GP Service framework, add <service> as child of <services>. Use the service name attribute to specify the native endpoint namespace and class name. Set behaviorConfiguration to StandardBehavior.

    <service name="SampleLeadService.Contract.Leads"
    behaviorConfiguration="StandardBehavior">
    
Add the default endpoint to \<service\>. The endpoint uses the following settings.

<pre class="checklistscript" IsFakePre="true" xmlns="http://www.w3.org/1999/xhtml">    &lt;endpoint address="mex" name="http"
    binding="customBinding" bindingConfiguration="CustomBinding"
    contract="IMetadataExchange"/&gt;
Add a custom endpoint to \<service\>. Use address to specify the name of your contract class. Use name to specify a name for your service. Set binding to wsHttpBinding. Set bindingConfiguration to WSHttpBindingTarget. Use contract to specify the namespace and name of your native endpoint interface.

<pre class="checklistscript" IsFakePre="true" xmlns="http://www.w3.org/1999/xhtml">    &lt;endpoint address="Leads" name="SampleLeadService"
    binding="wsHttpBinding"
    bindingConfiguration="WSHttpBindingTarget"
    contract="SampleLeadService.Contract.ILeads" /&gt;
Add host information to service. Use baseAddress to specify the URL for your native endpoint. The URL must use the same server name and port as the Dynamics GP Service. The following code example shows the base address used for the native endpoint of the sample Leads service.

<pre class="checklistscript" IsFakePre="true" xmlns="http://www.w3.org/1999/xhtml">    &lt;host&gt;
    &lt;baseAddresses&gt;
        &lt;add baseAddress = "https://localhost:48620/Sample/Leads" /&gt;
    &lt;/baseAddresses&gt;
&lt;/host&gt;

</service>

  1. Add the legacy service

    If your service uses the legacy endpoint of the Dynamics GP Service framework, add <service> as a child of <services>. Use the service name attribute to specify your legacy endpoint namespace and class name. Set behaviorConfiguration to StandardBehavior.

    <service name="SampleLeadService.LegacyContract.Leads"
    behaviorConfiguration="StandardBehavior">
    
Add the default endpoint to \<service\>. The endpoint uses the following settings.

<pre class="checklistscript" IsFakePre="true" xmlns="http://www.w3.org/1999/xhtml">    &lt;endpoint address="Mex" name="http" binding="customBinding"
    bindingConfiguration="CustomBinding"
    contract="IMetadataExchange"/&gt;
Add a custom endpoint to \<service\>. Set address to be empty. Use name to specify a name for your service. Set binding to basicHttpBinding. Set bindingConfiguration to BasicHttpBindingTarget. Use contract to specify the namespace and name of your legacy endpoint interface.

<pre class="checklistscript" IsFakePre="true" xmlns="http://www.w3.org/1999/xhtml">    &lt;endpoint address="" name="SampleLeadServiceLegacy"
    binding="basicHttpBinding"
    bindingConfiguration="BasicHttpBindingTarget"
    contract="SampleLeadService.LegacyContract.ILeadsLegacy"/&gt;
Add host information to service. Use baseAddress to specify the URL for your legacy endpoint. The URL must use the same server name and port as the Dynamics GP Service. Add DynamicsGPWebServices to the URL and then specify the name of an .asmx file. The following code example shows the base address used for the legacy endpoint of the sample Leads service.

<pre class="checklistscript" IsFakePre="true" xmlns="http://www.w3.org/1999/xhtml">    &lt;host&gt;
    &lt;baseAddresses&gt;
        &lt;add baseAddress="https://localhost:48620/
            DynamicsGPWebServices/SampleLeadWebService.asmx"/&gt;
    &lt;/baseAddresses&gt;
&lt;/host&gt;

</service>

  1. Add behavior settings.

    After <services> in the <system.serviceModel> node, add <behaviors>. Use the configSource to import the behavior setting in the WSBehaviors.config file of the Dynamics GP Service.

    <behaviors configSource="WSBehaviors.config"/>
    
  1. Add client settings.

    Immediately after the <behaviors> node, add a <client> node. Use the <endpoint> nodes to reference the Tenant Discovery Service nodes.

    <client>
    <endpoint name="DiscoveryServiceHttp" binding="wsHttpBinding" bindingConfiguration="DiscoveryServiceBindingHttp" contract="Microsoft.Dynamics.MultitenantServices.ServicesInterface.ITenantDiscoveryService" address=""/>
    <endpoint name="DiscoveryServiceHttps" binding="wsHttpBinding" bindingConfiguration="DiscoveryServiceBindingHttps" contract="Microsoft.Dynamics.MultitenantServices.ServicesInterface.ITenantDiscoveryService" address=""/>
    

</client>

  1. Save the configuration file

    When you have completed work on the configuration file, click File, and then click Save.