0

我正在使用 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>
4

2 回答 2

2

我建议您摆脱所有 xsi:type 属性,例如如何从 gSoap 消息中删除 xsi:type 信息?

简化您的请求应如下所示

<?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>

这对我来说没问题。

干杯格伦

于 2015-12-11T05:34:26.557 回答
1

我最近探索了 EWS api,发现一个Sender标签会导致请求的 500 响应CreateItem。相反,您应该使用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>
于 2016-02-02T18:47:44.500 回答