Handling Faults

If a sender requests a response, then one will be sent regardless of whether the operation was successful or not. Therefore, whenever an operation includes a response port, you should include the World Wide Web Consortium (W3C) SOAP fault body with the port set for that message. For example, the fault body is included in this Get operation, which was included in Service Tutorial 2:

public Get(Microsoft.Dss.ServiceModel.Dssp.GetRequestType body,
         Microsoft.Ccr.Core.PortSet<ServiceTutorial2State,W3C.Soap.Fault>
         responsePort) : base(body, responsePort)
{
}

DSSP provides a set of fault codes (see Table 2-6 for a list of DSSP fault codes) that can be used to check for specific conditions. For example, when performing an insert, you could first check to see if the state item already exists using the DuplicateEntry fault code. The following code provides an example of this scenario:

if ( /* the item already exists */)
{
 insert.ResponsePort.Post(Fault.FromCodeSubcodeReason(
FaultCodes.Sender, DsspFaultCodes.DuplicateEntry));
  yield break;
}

Table 2-6. DSSP Fault Codes Provided with the DSSP Service Model

Fault Code

Description

ActionNotSupported

The operation is not supported by the service.

DuplicateEntry

A duplicate entry already exists for the state item.

InsufficientResources

The operation failed due to insufficient resources.

MessageNotSupported

The DSSP body type supplied is not supported.

OperationCancelled

The operation was cancelled.

OperationFailed

The operation failed.

QueuingLimitExceeded

The operation failed because the queuing limit on the target port exceeded the limit.

ResponseTimeout

The response timed out.

UnknownEntry

A query, update, or upsert operation failed because the state item does not exist.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.116.37.62