EWS 的 CreateItem 操作中的内部服务器错误

Internal Server Error in CreateItem operation of EWS

我使用 CreateItem 操作将消息保存在 Draft 文件夹中,使用带有 gSOAP 工具包的 EWS,但是当我 运行 我的代码响应 XML 如下:

<?xml version="1.0" encoding="utf-8"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
    <s:Header>
        <Action s:mustUnderstand="1" xmlns="http://schemas.microsoft.com/ws/2005/05/addressing/none">*</Action>
    </s:Header>
    <s:Body>
        <s:Fault>
            <faultcode xmlns:a="http://schemas.microsoft.com/exchange/services/2006/types">a:ErrorInternalServerError</faultcode>
            <faultstring xml:lang="en-US">An internal server error occurred. The operation failed.</faultstring>
            <detail>
                <e:ResponseCode xmlns:e="http://schemas.microsoft.com/exchange/services/2006/errors">ErrorInternalServerError</e:ResponseCode>
                <e:Message xmlns:e="http://schemas.microsoft.com/exchange/services/2006/errors">An internal server error occurred. The operation failed.</e:Message>
            </detail>
        </s:Fault>
    </s:Body>
</s:Envelope>

在终端中,我遇到的错误是:

SOAP 1.1 fault: SOAP-ENV:MustUnderstand[no subcode]
"The data in element 'Action' must be understood but cannot be processed"
Detail: [no detail]

并且没有编译时错误。如果您需要代码,请告诉我,我也会提供。请帮助我,我已经尝试了很多,但没有找到解决方案,无论我更改代码,响应 XML 保持不变。

请求XML如下:

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:ns1="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:ews="http://schemas.microsoft.com/exchange/services/2006/messages">
    <SOAP-ENV:Body>
        <ews:CreateItem xsi:type="ews:CreateItemType" MessageDisposition="SaveOnly"><ews:SavedItemFolderId xsi:type="ns1:TargetFolderIdType">
            <ns1:DistinguishedFolderId Id="drafts" xsi:type="ns1:DistinguishedFolderIdType"></ns1:DistinguishedFolderId>
        </ews:SavedItemFolderId>
        <ews:Items xsi:type="ns1:NonEmptyArrayOfAllItemsType">
            <ns1:Message xsi:type="ns1:MessageType">
                <ns1:ItemClass xsi:type="ns1:ItemClassType">IPM.Note</ns1:ItemClass>
                <ns1:Subject xsi:type="xsd:string">Project Action</ns1:Subject>
                <ns1:Body BodyType="Text" xsi:type="ns1:BodyType">Priority - Update specification</ns1:Body>
                <ns1:Sender xsi:type="ns1:SingleRecipientType">
                    <ns1:Mailbox xsi:type="ns1:EmailAddressType">
                        <ns1:EmailAddress xsi:type="ns1:NonEmptyStringType">markzuck93@live.com</ns1:EmailAddress>
                    </ns1:Mailbox>
                </ns1:Sender>
                <ns1:ToRecipients xsi:type="ns1:ArrayOfRecipientsType">
                    <ns1:Mailbox xsi:type="ns1:EmailAddressType">
                        <ns1:EmailAddress xsi:type="ns1:NonEmptyStringType">openuib@openuib.onmicrosoft.com</ns1:EmailAddress>
                    </ns1:Mailbox>
                </ns1:ToRecipients>
            </ns1:Message>
        </ews:Items>
    </ews:CreateItem>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

我建议您删除所有 xsi:type 属性,例如 how to remove xsi:type information from gSoap message?

简化后您的请求应如下所示

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:ns1="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:ews="http://schemas.microsoft.com/exchange/services/2006/messages">
    <SOAP-ENV:Body>
       <ews:CreateItem MessageDisposition="SaveOnly">
       <ews:SavedItemFolderId>
           <ns1:DistinguishedFolderId Id="drafts" />
        </ews:SavedItemFolderId>
        <ews:Items>
            <ns1:Message>
                <ns1:ItemClass>IPM.Note</ns1:ItemClass>
                <ns1:Subject>Project Action</ns1:Subject>
            </ns1:Message>
        </ews:Items>
    </ews:CreateItem>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

这对我来说没问题。

干杯 格伦

我最近研究了 EWS api,发现 Sender 标记导致 CreateItem 请求的 500 响应。相反,您应该使用 From 标签。

            <ns1:From xsi:type="ns1:SingleRecipientType">
                <ns1:Mailbox xsi:type="ns1:EmailAddressType">
                    <ns1:EmailAddress xsi:type="ns1:NonEmptyStringType">markzuck93@live.com</ns1:EmailAddress>
                </ns1:Mailbox>
            </ns1:From>