gSoap EWS“错误500:内部服务器错误” [英] gSoap EWS "Error 500: Internal Server Error"

查看:430
本文介绍了gSoap EWS“错误500:内部服务器错误”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些ews(gSoap)的问题。



我有下一个代码:

  ExchangeServiceBindingProxy * proxy = new ExchangeServiceBindingProxy(endpoint.c_str()); 

soap * pSoap = proxy-> soap;
pSoap-> userid =Ivan1;
pSoap-> passwd =1;
pSoap-> ntlm_challenge =;
pSoap-> authrealm =Ursa-Minor

pSoap-> ssl_flags = SOAP_SSL_NO_AUTHENTICATION;
pSoap-> keep_alive = true;
pSoap-> mode = SOAP_IO_KEEPALIVE;

//获取根文件夹ID
ns3__DistinguishedFolderIdType * dfit = new ns3__DistinguishedFolderIdType();
dfit-> Id = ns3__DistinguishedFolderIdNameType__inbox;

//设置我们要检索的道具
ns3__FolderResponseShapeType * frst = new ns3__FolderResponseShapeType();
frst-> BaseShape = ns3__DefaultShapeNamesType__AllProperties;

//获取文件夹
ns1__GetFolderType * gftRoot = new ns1__GetFolderType();
gftRoot-> FolderIds = new ns3__NonEmptyArrayOfBaseFolderIdsType();
gftRoot-> FolderIds-> __ size_NonEmptyArrayOfBaseFolderIdsType = 1;
gftRoot-> FolderIds-> __ union_NonEmptyArrayOfBaseFolderIdsType = new __ns3__union_NonEmptyArrayOfBaseFolderIdsType();
gftRoot-> FolderIds-> __ union_NonEmptyArrayOfBaseFolderIdsType-> union_NonEmptyArrayOfBaseFolderIdsType.DistinguishedFolderId = dfit;
gftRoot-> FolderIds =(ns3__NonEmptyArrayOfBaseFolderIdsType *)dfit;
gftRoot-> FolderShape = frst;
__ns1__GetFolderResponse response;

int ret = proxy-> GetFolder(gftRoot,response);

我使用OpenSSL和NTLM库(WITH_OPENSSL,WITH_NTLM)。



作为一个resault gSoap生成此SOAP:

 <?xml version =1.0encoding =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:ns3 =http://schemas.microsoft.com/exchange/services/2006/types
xmlns:ns1 =http:/ /schemas.microsoft.com/exchange/services/2006/messages\">
< SOAP-ENV:Header>
< ns3:RequestServerVersion SOAP-ENV:mustUnderstand =1Version =Exchange2010>
< / ns3:RequestServerVersion>
< / SOAP-ENV:Header>
< SOAP-ENV:Body>
< ns1:GetFolder xsi:type =ns1:GetFolderType>
< ns1:FolderShape>
< ns3:BaseShape> AllProperties< / ns3:BaseShape>
< / ns1:FolderShape>
< ns1:FolderIds Id =inboxxsi:type =ns3:DistinguishedFolderIdType> < / ns1:FolderIds>
< / ns1:GetFolder>
< / SOAP-ENV:Body>
< / SOAP-ENV:Envelope>

服务器响应:

  HTTP / 1.1 500内部服务器错误
缓存控制:私人
传输编码:分块
Content-Type:text / xml; charset = utf-8
服务器:Microsoft-IIS / 7.0
Set-Cookie:exchangesecookie = 88bb510ab2ef4191a42c6cf9aada1614; expires = Fri,24-Oct-2014 09:45:45 GMT; path = /; HtpOnly
X-EwsPerformanceData:RpcC = 0; RpcL = 0; LdapC = 0; LdapL = 0;
X-AspNet-Version:2.0.50727
X-Powered-By:ASP.NET
日期:Thu,24 Oct 2013 09:45:45 GMT
连接:close

5d0
<?xml version =1.0encoding =utf-8?>
< s:Envelope xmlns:s =http://schemas.xmlsoap.org/soap/envelope/>
< s:Body>
< s:Fault>
< faultcode xmlns:a =http://schemas.microsoft.com/exchange/services/2006/types> a:ErrorSchemaValidation< / faultcode>
< faultstring xml:lang =en-US>请求失败的模式验证:xsi:type属性值'http://schemas.microsoft.com/exchange/services/2006/types:DistinguishedFolderIdType '对元素http://schemas.microsoft.com/exchange/services/2006/messages:FolderIds无效,因为它不是有效地从模式中的类型派生的类型,或者因为它具有xsi :type derivation blocked。< / faultstring>
< detail>
< e:ResponseCode xmlns:e =http://schemas.microsoft.com/exchange/services/2006/errors> ErrorSchemaValidation< / e:ResponseCode>
< e:Message xmlns:e =http://schemas.microsoft.com/exchange/services/2006/errors>请求失败了模式验证。< / e:Message>
< t:MessageXml xmlns:t =http://schemas.microsoft.com/exchange/services/2006/types>
< t:LineNumber> 2< / t:LineNumber>
< t:LinePosition> 519< / t:LinePosition>
< t:Violation> xsi:type属性值http://schemas.microsoft.com/exchange/services/2006/types:DistinguishedFolderIdType对于元素http:// schemas无效。 microsoft.com/exchange/services/2006/messages:FolderIds',因为它不是有效地从模式中的类型派生的类型,或者因为它阻止了xsi:type派生。
< / t:Violation>
< / t:MessageXml>
< / detail>
< / s:fault>
< / s:Body>
< / s:Envelope>

如您所见,问题是行

 < ns1:FolderIds Id =inboxxsi:type =ns3:DistinguishedFolderIdType

服务器不希望在此行中看到xsi:type =ns3:DistinguishedFolderIdType。在原始SOAP中它看起来像:

 < FolderIds> 
< DistinguishedFolderId Id =inboxxmlns =http://schemas.microsoft.com/exchange/services/2006/types/>
< / FolderIds>

如何解决这个问题?

解决方案

好吧,我想出了如何使它工作:

  //获取文件夹
ns1__GetFolderType * gftRoot = new ns1__GetFolderType();
gftRoot-> FolderIds = new ns3__NonEmptyArrayOfBaseFolderIdsType();
gftRoot-> FolderIds-> __ size_NonEmptyArrayOfBaseFolderIdsType = 1; //我们在FolderIds数组中指定多少个文件夹元素
gftRoot-> FolderIds-> __ union_NonEmptyArrayOfBaseFolderIdsType = new __ns3__union_NonEmptyArrayOfBaseFolderIdsType(); //创建数组的一个元素
gftRoot-> FolderIds-> __ union_NonEmptyArrayOfBaseFolderIdsType-> __ union_NonEmptyArrayOfBaseFolderIdsType = 2; //这表示哪个类/结构取自union
gftRoot-> FolderIds-> __ union_NonEmptyArrayOfBaseFolderIdsType-> union_NonEmptyArrayOfBaseFolderIdsType.DistinguishedFolderId = dfit; // push dfit to element
gftRoot-> FolderShape = frst;

__ns1__GetFolderResponse response;

int ret = proxy-> GetFolder(gftRoot,response);


I have some problems with ews(gSoap).

I have next code:

ExchangeServiceBindingProxy *proxy = new ExchangeServiceBindingProxy(endpoint.c_str());

soap *pSoap = proxy->soap;
pSoap->userid = "Ivan1";
pSoap->passwd = "1";
pSoap->ntlm_challenge = "";
pSoap->authrealm = "Ursa-Minor";

pSoap->ssl_flags = SOAP_SSL_NO_AUTHENTICATION;
pSoap->keep_alive = true;   
pSoap->mode = SOAP_IO_KEEPALIVE;

//get root folder ID
ns3__DistinguishedFolderIdType *dfit = new ns3__DistinguishedFolderIdType();
dfit->Id = ns3__DistinguishedFolderIdNameType__inbox;

//set the props that we want to retrieve
ns3__FolderResponseShapeType *frst = new ns3__FolderResponseShapeType();
frst->BaseShape = ns3__DefaultShapeNamesType__AllProperties;

//get folder
ns1__GetFolderType *gftRoot = new ns1__GetFolderType();
gftRoot->FolderIds = new ns3__NonEmptyArrayOfBaseFolderIdsType();
gftRoot->FolderIds->__size_NonEmptyArrayOfBaseFolderIdsType = 1;
gftRoot->FolderIds->__union_NonEmptyArrayOfBaseFolderIdsType = new __ns3__union_NonEmptyArrayOfBaseFolderIdsType();
gftRoot->FolderIds->__union_NonEmptyArrayOfBaseFolderIdsType->union_NonEmptyArrayOfBaseFolderIdsType.DistinguishedFolderId = dfit;
gftRoot->FolderIds = (ns3__NonEmptyArrayOfBaseFolderIdsType*)dfit;
gftRoot->FolderShape = frst;
__ns1__GetFolderResponse response;

int ret = proxy->GetFolder(gftRoot, response);

I`m using OpenSSL and NTLM libs(WITH_OPENSSL, WITH_NTLM).

As a resault gSoap generates this SOAP:

<?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:ns3="http://schemas.microsoft.com/exchange/services/2006/types" 
xmlns:ns1="http://schemas.microsoft.com/exchange/services/2006/messages">
<SOAP-ENV:Header>
<ns3:RequestServerVersion SOAP-ENV:mustUnderstand="1" Version="Exchange2010">
</ns3:RequestServerVersion>
</SOAP-ENV:Header>
<SOAP-ENV:Body>
<ns1:GetFolder xsi:type="ns1:GetFolderType">
<ns1:FolderShape>
<ns3:BaseShape>AllProperties</ns3:BaseShape>
</ns1:FolderShape>
<ns1:FolderIds Id="inbox" xsi:type="ns3:DistinguishedFolderIdType"> </ns1:FolderIds>
</ns1:GetFolder>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

Response from server:

HTTP/1.1 500 Internal Server Error
Cache-Control: private
Transfer-Encoding: chunked
Content-Type: text/xml; charset=utf-8
Server: Microsoft-IIS/7.0
Set-Cookie: exchangecookie=88bb510ab2ef4191a42c6cf9aada1614; expires=Fri, 24-Oct-2014 09:45:45 GMT; path=/; HttpOnly
X-EwsPerformanceData: RpcC=0;RpcL=0;LdapC=0;LdapL=0;
X-AspNet-Version: 2.0.50727
X-Powered-By: ASP.NET
Date: Thu, 24 Oct 2013 09:45:45 GMT
Connection: close

5d0
<?xml version="1.0" encoding="utf-8"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
    <s:Body>
        <s:Fault>
            <faultcode xmlns:a="http://schemas.microsoft.com/exchange/services/2006/types">a:ErrorSchemaValidation</faultcode>
            <faultstring xml:lang="en-US">The request failed schema validation: The xsi:type attribute value 'http://schemas.microsoft.com/exchange/services/2006/types:DistinguishedFolderIdType' is not valid for the element 'http://schemas.microsoft.com/exchange/services/2006/messages:FolderIds', either because it is not a type validly derived from the type in the schema, or because it has xsi:type derivation blocked.</faultstring>
            <detail>
                <e:ResponseCode xmlns:e="http://schemas.microsoft.com/exchange/services/2006/errors">ErrorSchemaValidation</e:ResponseCode>
                <e:Message xmlns:e="http://schemas.microsoft.com/exchange/services/2006/errors">The request failed schema validation.</e:Message>
                <t:MessageXml xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
                    <t:LineNumber>2</t:LineNumber>
                    <t:LinePosition>519</t:LinePosition>
                    <t:Violation>The xsi:type attribute value 'http://schemas.microsoft.com/exchange/services/2006/types:DistinguishedFolderIdType' is not valid for the element 'http://schemas.microsoft.com/exchange/services/2006/messages:FolderIds', either because it is not a type validly derived from the type in the schema, or because it has xsi:type derivation blocked.
                    </t:Violation>
                </t:MessageXml>
            </detail>
        </s:Fault>
    </s:Body>
</s:Envelope>

As you can see, the problem is in line

<ns1:FolderIds Id="inbox" xsi:type="ns3:DistinguishedFolderIdType"

Server don`t want to see xsi:type="ns3:DistinguishedFolderIdType" in this line. In original SOAP it looks like:

 <FolderIds>
  <DistinguishedFolderId Id="inbox" xmlns="http://schemas.microsoft.com/exchange/services/2006/types" /> 
  </FolderIds>

So. How to solve this problem?

解决方案

Well, i figured out how to make it works:

//get folder
    ns1__GetFolderType *gftRoot = new ns1__GetFolderType(); 
    gftRoot->FolderIds = new ns3__NonEmptyArrayOfBaseFolderIdsType();
    gftRoot->FolderIds->__size_NonEmptyArrayOfBaseFolderIdsType = 1; //there we specify how many folders elements in FolderIds array
    gftRoot->FolderIds->__union_NonEmptyArrayOfBaseFolderIdsType = new __ns3__union_NonEmptyArrayOfBaseFolderIdsType(); //create one element of array
    gftRoot->FolderIds->__union_NonEmptyArrayOfBaseFolderIdsType->__union_NonEmptyArrayOfBaseFolderIdsType = 2; //this indicates, which class/structure are taken from union
    gftRoot->FolderIds->__union_NonEmptyArrayOfBaseFolderIdsType->union_NonEmptyArrayOfBaseFolderIdsType.DistinguishedFolderId = dfit; //push dfit to element
    gftRoot->FolderShape = frst;

    __ns1__GetFolderResponse response;

    int ret = proxy->GetFolder(gftRoot, response);

这篇关于gSoap EWS“错误500:内部服务器错误”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆