【问题标题】:Internal Server Error in CreateItem operation of EWSEWS 的 CreateItem 操作中的内部服务器错误
【发布时间】:2015-12-10 16:35:20
【问题描述】:

我正在使用 CreateItem Operation 使用 EWS 和 gSOAP 工具包将消息保存在 Draft 文件夹中,但是当我运行代码时,我响应 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>

【问题讨论】:

    标签: c++ xml exchangewebservices gsoap soapfault


    【解决方案1】:

    我建议你去掉所有 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>
    

    这对我来说没问题。

    干杯 格伦

    【讨论】:

    • 非常感谢 Glen,这正是我的问题的正确解决方案,现在可以正常工作了。谢谢!!
    • 我想知道的一件事,我怎么知道将来,当我必须使用 SOAP_XML_NOTYPE 时,或者不使用时,因为某些操作在不使用此 SOAP_XML_NOTYPE 的情况下工作正常,是 FindItem 和获取项目。
    【解决方案2】:

    我最近探索了 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>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-03-08
      • 1970-01-01
      • 2013-07-04
      • 1970-01-01
      相关资源
      最近更新 更多