eConnect Integration Service exception handling

The eConnect Integration Service includes two classes you use to handle exceptions produced by the eConnect Integration Service. You typically use these classes to catch and handle eConnect exceptions.

To handle exceptions from a WCF client application, use the FaultException generic class from the System.ServiceModel namespace. The FaultException class allows you to specify the exception type. Use the eConnectFault and eConnectSqlFault classes to specify the exception type.

The most common exception handling technique is the Try/Catch block. For example, you place a Try block around a call to the CreateEntity method. You then use a Catch block to handle the eConnectException type. Typically, you add code to the Catch block that attempts to correct the error, reports the error to the user, or records error information to a log.

The following C# example shows how to use FaultException, eConnectFault, and eConnectSqlFault to handle exceptions that occur while using the eConnect Integration Service. Also, notice how the Dispose method is called to release any of the resource used by the eConnectClient.

// Instantiate an eConnectClient object
eConnectClient eConnectObject = new eConnectClient();

	// Use the XML document in the specified file to create 
	// a string representation of the customer
	XmlDocument newCustDoc = new XmlDocument();
	string newCustomerDocument = newCustDoc.OuterXml;

	//Create a connection string
	string connectionString = "Data Source=localhost;
		Integrated Security=SSPI;Persist Security Info=False;
		Initial Catalog=TWO;";

	// Create the customer in Microsoft Dynamics GP
	bool result = eConnectObject.CreateEntity(connectionString,
catch (FaultException<eConnectFault> eFault)
catch (FaultException<eConnectSqlFault> sqlFault)

Documentation Feedback