Partilhar via


Adding an interface for the legacy endpoint

To specify operations for the legacy endpoint, add a separate interface to your project. Typically, the interface is in the file I<projectname>.cs file of your Visual Studio project.

To create an interface for the Dynamics GP Service legacy endpoint, complete the following steps.

  1. Specify the namespace.

    Add a namespace for the legacy endpoint interface and implementation.

    The following code example shows the namespace that the sample Leads service uses with the legacy endpoint.

    namespace SampleLeadService.LegacyContract
    

{

}

  1. Add an interface to the namespace

    Add an interface to the namespace. The name of your interface must begin with I.

    The following example code from the sample Leads service adds an interface named ILeadsLegacy to the namespace used for the legacy endpoint.

    namespace SampleLeadService.LegacyContract
    

{ public interface ILeadsLegacy {

}

}

  1. Add the ServiceContract and XmlSerializerFormat attributes.

    Add the ServiceContract attribute to the interface. Use the Name property to specify a name for the service, Use the Namespace property to specify the XML namespace of the legacy endpoint of the Dynamics GP Service.

    Add the XmlSerializerFormat attribute to the interface. The XmlSerializerFormat instructs the Dynamics GP Service framework to use theXmlSerialzer.

    The following example code from the sample Leads service add the ServiceContract and XmlSerializerFormat attributes to the ILeadsLegacy interface.

    namespace SampleLeadService.LegacyContract
    

{ [ServiceContract(Name = "Leads", Namespace = "https://www.microsoft.com/DynamicsGP/Samples/2006"), XmlSerializerFormat] public interface ILeadsLegacy {

}

}

  1. Specify the service operations.

    Add a method signature for each operation that your service supports. You must specify the method name, return type, and parameters.

    Also, add the OperationContract attribute to each operation of your interface. Use the action property of the attribute to specify the name of the contract method that implements each operation.

    The following code example shows the operations for the ILeads interface of the sample Leads service. Notice how the OperationContract attribute is added to each operation and the action property specifies the name of the contract method that implements the operation. In the action property, https://www.microsoft.com/DynamicsGP/Samples/2006/ specifies the namespace for the legacy endpoint of the Dynamics GP Service.

    namespace SampleLeadService.LegacyContract
    

{ [ServiceContract(Name = "Leads", Namespace = "https://www.microsoft.com/DynamicsGP/Samples/2006"), XmlSerializerFormat] public interface ILeadsLegacy { [OperationContract(Action = "https://www.microsoft.com/DynamicsGP/ Samples/2006/GetLeadByKey")] Lead GetLeadByKey(LeadKey leadKey, Context context);

    [OperationContract(Action = "https://www.microsoft.com/DynamicsGP/
        Samples/2006/GetLeadList")]
    List&lt;LeadSummary&gt; GetLeadList(LeadCriteria criteria,
        Context context);

    [OperationContract(Action = "https://www.microsoft.com/DynamicsGP/
        Samples/2006/CreateLead")]
    void CreateLead(Lead lead, Context context, Policy policy);

    [OperationContract(Action = "https://www.microsoft.com/DynamicsGP/
        Samples/2006/UpdateLead")]
    void UpdateLead(Lead lead, Context context, Policy policy);

    [OperationContract(Action = "https://www.microsoft.com/DynamicsGP/
        Samples/2006/DeleteLead")]
    void DeleteLead(LeadKey leadKey, Context context, Policy policy);

    [OperationContract(Action = "https://www.microsoft.com/DynamicsGP/
        Samples/2006/GetSalespersonByKey")]
    Salesperson GetSalespersonByKey(SalespersonKey salespersonKey,
        Context context);

    [OperationContract(Action = "https://www.microsoft.com/DynamicsGP/
        Samples/2006/GetSalespersonList")]
    List&lt;SalespersonSummary&gt; GetSalespersonList(
        SalespersonCriteria salespersonCriteria, Context context);

    [OperationContract(Action = "https://www.microsoft.com/DynamicsGP/
        Samples/2006/GetPolicyByKey")]
    Policy GetPolicyByKey(PolicyKey policyKey, Context context);
}

}