C++ gSoap EWS“错误模式验证”
我对GetServerTimeZones操作的ewsgSoap有一些问题 我的客户代码是:C++ gSoap EWS“错误模式验证”,c++,xml,exchangewebservices,gsoap,soapfault,C++,Xml,Exchangewebservices,Gsoap,Soapfault,我对GetServerTimeZones操作的ewsgSoap有一些问题 我的客户代码是: //request ews__GetServerTimeZonesType *zoneReq = new ews__GetServerTimeZonesType(); zoneReq->Ids = new ns1__NonEmptyArrayOfTimeZoneIdType(); zoneReq->Ids->Id.push_back("Eastern Standard Time");
//request
ews__GetServerTimeZonesType *zoneReq = new ews__GetServerTimeZonesType();
zoneReq->Ids = new ns1__NonEmptyArrayOfTimeZoneIdType();
zoneReq->Ids->Id.push_back("Eastern Standard Time");
bool val = false;
zoneReq->ReturnFullTimeZoneData = &val;
//response
__ews__GetServerTimeZonesResponse resp;
if( proxy->GetServerTimeZones(zoneReq, resp) == SOAP_OK)
std::cout << "Works!!" << std::endl;
有人能告诉我这张桌子是否需要换零钱吗?谢谢。我似乎无法获得任何版本的EWS的模式,但我怀疑EWS:GetServerTimeZoneType是否具有正确的命名空间前缀。我希望它是一种类型,而不是一条消息,不管这种区别意味着什么,但ews是注定的http://schemas.microsoft.com/exchange/services/2006/messages.
我也不知道您正在使用的库,但其中似乎没有任何东西可以让您控制xsi:type注释的添加,而且它似乎自己也在这样做。因此,这里仍有一些神秘的事情发生。如果无法访问消息和输入模式,我的评论只是一个最佳猜测。首先,由于类型模式与消息模式是分开的,我怀疑ews是ns1:id的xsi:type中使用的错误名称空间前缀,应该是ns1。其次,xsi:type可能是由于从基类型继承/扩展而出现的。我的建议是使用选项-P运行wsdl2h,以删除源于派生自xsd:anyType根类型的不必要的xsi:type属性。如果没有帮助,那么尝试运行时标志SOAP_XML_NOTYPE来初始化SOAP上下文,这将删除所有xsi:type属性。但是要注意,需要xsi:type的派生类型的反序列化将失败。但是,很严重,xsi:type是根据模式对该类型的定义设置的,因此可能与这些定义和上游接收方的XML API不匹配。Hi@Tom W,gSoap库的官方文档链接:,我认为名称空间prifix是正确的,因为在services.h文件中提及约定是:ews=http://schemas.microsoft.com/exchange/services/2006/messages ns1=http://schemas.microsoft.com/exchange/services/2006/types@IStar我有同样的怀疑,你的可能在下面的链接请帮助我。嗨@Tom W,我认为你是对的,问题可能在那里,但你知道如何解决吗?谢谢。Hi@Tom我在代码中使用了document/literal样式,尽管我使用-t命令添加了xsi:type,但问题仍然是一样的。我发送的日志更改为:东部标准时间
SOAP 1.1 fault: ns1:ErrorSchemaValidation[no subcode]
"The request failed schema validation: This is an invalid xsi:type 'http://schemas.microsoft.com/exchange/services/2006/messages:GetServerTimeZonesType'." Detail: <e:ResponseCode xmlns:e="http://schemas.microsoft.com/exchange/services/2006/errors">ErrorSchemaValidation</e:ResponseCode>
<?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:GetServerTimeZones xsi:type="ews:GetServerTimeZonesType">
<ews:Ids>
<ns1:Id>Eastern Standard Time</ns1:Id>
</ews:Ids>
</ews:GetServerTimeZones>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
HTTP/1.1 500 Internal Server Error
<?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: This is an invalid xsi:type 'http://schemas.microsoft.com/exchange/services/2006/messages:GetServerTimeZonesType'.
</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>396</t:LinePosition>
<t:Violation>This is an invalid xsi:type 'http://schemas.microsoft.com/exchange/services/2006/messages:GetServerTimeZonesType'.</t:Violation>
</t:MessageXml>
</detail>
</s:Fault>
</s:Body>
</s:Envelope>
<?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:Header>
<ns1:MailboxCulture></ns1:MailboxCulture>
<ns1:RequestServerVersion Version="Exchange2013_SP1">
</ns1:RequestServerVersion>
</SOAP-ENV:Header>
<SOAP-ENV:Body>
<ews:GetServerTimeZones ReturnFullTimeZoneData="false">
<ews:Ids>
<ns1:Id></ns1:Id>
<ns1:Id></ns1:Id>
</ews:Ids>
</ews:GetServerTimeZones>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
#include "soapH.h"
SOAP_NMAC struct Namespace namespaces[] =
{
{"SOAP-ENV", "http://schemas.xmlsoap.org/soap/envelope/", "http://www.w3.org/*/soap-envelope", NULL},
{"SOAP-ENC", "http://schemas.xmlsoap.org/soap/encoding/", "http://www.w3.org/*/soap-encoding", NULL},
{"xsi", "http://www.w3.org/2001/XMLSchema-instance", "http://www.w3.org/*/XMLSchema-instance", NULL},
{"xsd", "http://www.w3.org/2001/XMLSchema", "http://www.w3.org/*/XMLSchema", NULL},
{"ns1", "http://schemas.microsoft.com/exchange/services/2006/types", NULL, NULL},
{"ews", "http://schemas.microsoft.com/exchange/services/2006/messages", NULL, NULL},
{NULL, NULL, NULL, NULL}
};