To consume web services using the generic entities, software developers can connect to web services with any platform and/or environment which supports the SOAP protocol. This document provides a step-by-step guide using Microsoft Visual Studio 2008 as an example.
1. Open Microsoft Visual Studio 2008.
2. Create a new project with the following information:
3. Add a service reference to Metadata service:
4. Open app.config and increase the sizes of maxBufferSize and maxReceivedMessageSize. You can change the size at anytime in order to receive the metadata information successfully from the service.
5. Open the Form1 class in the Designer window.
6. Open the Form1 class in the Code Editor window and add the following code:
7. Now, open the Form1 class in the Designer window.
8. Open the Form1 class in the Code Editor window and add the following code:
9. You can also add a Try-Catch statement to catch the exception during the CRUD operations.
For example, Try ……. Catch ex As Exception MessageBox.Show("Error Occurred :" & ex.Message, "Entity Error", MessageBoxButtons.OK, MessageBoxIcon.Error) End Try If there is a validation error during the operation, an error message will be displayed, as shown in the following:
For example,
Try
…….
Catch ex As Exception
MessageBox.Show("Error Occurred :" & ex.Message, "Entity Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
If there is a validation error during the operation, an error message will be displayed, as shown in the following: