Compartilhar via


Creating a service instance

After you have made a web reference to connect to the legacy endpoint of Dynamics GP service, you will create an instance of the service so you can access the service methods. The "DynamicsGP" class in the generated proxy represents the base service. You will create an instance of this class that provides access to the service methods.

The following example shows the C# code required to create an instance of the Dynamics GP service for the legacy endpoint.

// Create an instance of the web service
DynamicsGP wsDynamicsGP = new DynamicsGP();

Hint: Throughout the code examples for the legacy endpoint in this documentation, the service instance is named "wsDynamicsGP".

The service instance also provides access to properties that control how the service is called. For instance, when accessing the Dynamics GP service you can specify that the current user's login credentials will be used for the service call. The following C# code shows how this is done for a project created in Visual Studio 2005 or later.

// Be sure that default credentials are being used
wsDynamicsGP.UseDefaultCredentials = true;

The Timeout property is another important property of the service instance. It specifies how long the client application will wait for a service request to be completed. If your web service application is working with a large number of documents, it may encounter timeout errors. You can use the Timeout property to increase the timeout value. The following C# example sets the timeout to infinite.

wsDynamicsGP.Timeout = System.Threading.Timeout.Infinite;

Hint: Refer to the troubleshooting information in the Web Services Installation and Administration Guide for more information about timeout issues.