Export (0) Print
Expand All

XML Validation Errors When You Submit Exchange Web Services Requests

 

Topic Last Modified: 2009-04-24

This topic provides information about how to resolve issues that may occur when you send or receive Microsoft Exchange Web Services requests that contain invalid XML characters.

Scenario 1

You submit an Exchange Web Services request to Exchange Server 2007. The request contains one or more invalid XML characters.

In this scenario, you receive the following ErrorSchemaValidation error:

 

The request failed schema validation: <character>, hexadecimal value <value>, is an invalid character.

Scenario 2

You use Microsoft Visual Studio auto-generated proxy classes in an Exchange Web Services request to Exchange 2007. The request returns item properties from a response that contains invalid XML characters. In this scenario, you may receive the following InvalidOperationException error:

 

There is an error in XML document

<character> hexadecimal value <value>, is an invalid character.

In certain situations, Exchange item properties could have values that contain characters outside the range of valid XML characters.

When an Exchange Web Services client submits a request to retrieve an item property, the Exchange server encodes the property values to make sure that the response may be transmitted successfully. When the client receives the response, the client validates the response against the XML schema. If the response contains invalid XML characters, the response fails XML schema validation.

Also, if an Exchange Web Services client tries to send invalid XML characters in a request, the request fails. Although the values are encoded in the request, Exchange tries to validate the request against the XML schema. If the request contains invalid XML characters, the validation operation fails.

Scenario 1

You cannot post an Exchange Web Service request that contains invalid XML characters. If you want to update the value of a property that contains invalid XML characters, you must replace or omit the invalid characters.

Scenario 2

To read Exchange Web Services responses that contain invalid XML characters from Exchange 2007, you must skip XML validation. If you use the Visual Studio auto-generated proxy classes for Exchange Web Services, you can create a special partial class that overrides the GetReaderForMessage method of the ExchangeServiceBinding class. This turns off XML validation.

The following code example illustrates this type of partial class:

public partial class MyExchangeServiceBinding: ExchangeServiceBinding 
{ 
    protected overrideXmlReader GetReaderForMessage( 
        SoapClientMessage message, 
        int bufferSize) 
    { 
        XmlReader retval = base.GetReaderForMessage( 
            message, 
            bufferSize); 

        XmlTextReader xrt = retval asXmlTextReader; 

        if(null!= xrt) 
        { 
            xrt.Normalization = false; 
        } 

        returnretval; 
    } 
}

For more information about valid XML characters, see this W3C Web site.

noteNote:
The third-party Web site information in this topic is provided to help you find the technical information you need. The URLs are subject to change without notice.

For more information about how to use Exchange Web Services proxy programming, see Getting Started With Exchange Web Services Proxy Programming.

For more information about Exchange Web Services, see Exchange Web Services Developer Overview.

 
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft