XML Validation Errors When You Submit Exchange Web Services Requests

Exchange 2007
 

上次修改主題的時間: 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.

note附註:
本主題也提供協力廠商網站資訊,協助您找到需要的技術資訊。 URL 如有變更,恕不另行通知。

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.

若要確保您目前閱讀的是最新資訊,並尋找其他的 Exchange Server 2007 說明文件,請造訪 Exchange Server 技術資源中心.
顯示: