导入Exchange Web服务(EWS)wsdl文件时如何解决无法解析的类型? [英] How to fix unresolved types when importing Exchange Web Services (EWS) wsdl file?
问题描述
从 https://ourmail.server/ews/services.wsdl ,在生成的services.pas中,最初出现了大量的 WSDL文档中未表示的以下类型在生成的services.pas中。
然后将wdsl文件下载到磁盘,看到它引用了 http://schemas.microsoft.com/exchange/services/2006/邮件和 http://schemas.microsoft.com/exchange/services/2006 / types ,已下载 https://ourmail.server/ews/types.xsd 和 https://ourmail.server/ews/messages.xsd
并修改了从
When importing the wsdl file from https://ourmail.server/ews/services.wsdl, I initially got a ton of "The following types, referred to in the WSDL document are not being represented in this file" in the generated services.pas.
I then downloaded the wdsl file to disk, saw that it referenced http://schemas.microsoft.com/exchange/services/2006/messages and http://schemas.microsoft.com/exchange/services/2006/types, downloaded https://ourmail.server/ews/types.xsd and https://ourmail.server/ews/messages.xsd
and modified the start of services.wdsl from
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:s="http://www.w3.org/2001/XMLSchema" targetNamespace="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
<wsdl:types>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:import namespace="http://schemas.microsoft.com/exchange/services/2006/messages" schemaLocation="messages.xsd"/>
</xs:schema>
</wsdl:types>
至:
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:s="http://www.w3.org/2001/XMLSchema" targetNamespace="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
<wsdl:types>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:import namespace="http://schemas.microsoft.com/exchange/services/2006/messages" schemaLocation="file://d:/testing/web/exchange web services/types.xsd"/>
<xs:import namespace="http://schemas.microsoft.com/exchange/services/2006/messages" schemaLocation="file://d:/testing/web/exchange web services/messages.xsd"/>
</xs:schema>
</wsdl:types>
现在生成的services.pas包含(仅)以下错误:
Now the generated services.pas contains (only) these errors:
// ************************************************************************ //
// The following types, referred to in the WSDL document are not being represented
// in this file. They are either aliases[@] of other types represented or were referred
// to but never[!] declared in the document. The types from the latter category
// typically map to predefined/known XML or Embarcadero types; however, they could also
// indicate incorrect WSDL documents that failed to declare or import a schema type.
// ************************************************************************ //
// !:double - "http://www.w3.org/2001/XMLSchema"[Gbl]
// !:duration - "http://www.w3.org/2001/XMLSchema"[Gbl]
// !:time - "http://www.w3.org/2001/XMLSchema"[Gbl]
// !:base64Binary - "http://www.w3.org/2001/XMLSchema"[Gbl]
// !:boolean - "http://www.w3.org/2001/XMLSchema"[Gbl]
// !:int - "http://www.w3.org/2001/XMLSchema"[Gbl]
// !:string - "http://www.w3.org/2001/XMLSchema"[Gbl]
// !:language - "http://www.w3.org/2001/XMLSchema"[Hdr][Gbl]
// !:dateTime - "http://www.w3.org/2001/XMLSchema"[Gbl]
// !:lang - "http://www.w3.org/2001/XMLSchema"[GblAttr]
// !:nonNegativeInteger - "http://www.w3.org/2001/XMLSchema"[Gbl]
// !:anyURI - "http://www.w3.org/2001/XMLSchema"[Gbl]
// !:short - "http://www.w3.org/2001/XMLSchema"[Gbl]
我可以添加什么 xs:import行来解决这些问题?
我到处搜索了W3C的datatypes.xsd和structure.xsd并尝试了
What "xs:import" line can I add to resolve these?
I have searched around for the W3C's datatypes.xsd and structures.xsd and tried the same approach, but I can't get it to work.
推荐答案
原来,那些类型没有被表示文件很好。
对于大多数这些类型来说,似乎后一类的类型通常映射到预定义/已知的XML或Embarcadero类型。诸如nonNegativeInteger和Base64Binary之类的奇怪变量在源代码中的其他任何地方都没有使用。
It turns out those "types not being represented" in the file are fine. It seems as if "The types from the latter category typically map to predefined/known XML or Embarcadero types" is exactly the case for most of these types. The 'strange' ones like nonNegativeInteger and Base64Binary are not used anywhere else in the source.
另一句话:我在指定初始WDSL时出错。该URL给出了证书错误,阻止了从属文件的导入。一旦尝试了没有证书错误的备用URL, https://webmail.ourmailserver.nl/ews/messages .xsd 和 https://webmail.ourmailserver.nl/ews/types.xsd 已正确导入,而我不再需要从磁盘上导入。
One additional remark: I made an error specifying the initial WDSL. That URL gave a certificate error which prevented the dependent files from being imported. Once I tried an alternate URL without cert errors the https://webmail.ourmailserver.nl/ews/messages.xsd and https://webmail.ourmailserver.nl/ews/types.xsd were imported properly and I no longer had to do that from disk.
由于以下结构,最初生成的文件无法编译:
The generated file initially does not compile because of the following constructs:
type
ProtectionRuleAllInternalType = string;
ProtectionRuleTrueType = string;
ProtectionRuleConditionType = class(TRemotable)
private
FAllInternal: ProtectionRuleAllInternalType;
FAllInternal_Specified: boolean;
procedure SetAllInternal(Index: Integer; const AProtectionRuleAllInternalType: ProtectionRuleAllInternalType);
public
published
property True: ProtectionRuleTrueType;
end;
procedure ProtectionRuleConditionType.SetAllInternal(Index: Integer; const AProtectionRuleAllInternalType: ProtectionRuleAllInternalType);
begin
FAllInternal := AProtectionRuleAllInternalType;
FAllInternal_Specified := True;
end;
在setter中,布尔值是什么意思,但编译器认为它是正确发布的名为True,并会发出不兼容的类型。
我更改了 FAllInternal_Specified:= True;到 FAllInternal_Specified:= System.True;
In the setter, what is meant is the boolean value, but the compiler thinks it is the published properly named True, and will issue an 'Incompatible types'. I changed the "FAllInternal_Specified := True;" to "FAllInternal_Specified := System.True;"
以同样的方式,有两个发布的属性Create,并且编译器认为这些是重写基本调用中的构造函数。我将其名称更改为MyCreate。
In the same manner, there are two published properties Create, and the compiler thinks these are constructors overriding those in the base calls. I changed their names to MyCreate.
这使生成的文件得以编译。
This makes the generated file compile.
这篇关于导入Exchange Web服务(EWS)wsdl文件时如何解决无法解析的类型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!