3

https://ourmail.server/ews/services.wsdl导入 wsdl 文件时,我最初在生成的服务中得到了大量“WSDL 文档中引用的以下类型在此文件中未表示”。帕斯
然后我将 wdsl 文件下载到磁盘,看到它引用了http://schemas.microsoft.com/exchange/services/2006/messageshttp://schemas.microsoft.com/exchange/services/2006/types,下载https://ourmail.server/ews/types.xsdhttps://ourmail.server/ews/messages.xsd 并修改 services.wdsl 的开头

<?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 包含(仅)这些错误:

// ************************************************************************ //
// 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 并尝试了相同的方法,但我无法让它工作。

4

2 回答 2

1

有一个用于 Delphi 和 Free Pascal 的 Web 服务工具包,它也有一个 WSDL 导入器。

也许这个能够处理 WSDL,我会试一试。

于 2012-10-26T11:08:21.260 回答
0

事实证明,文件中的那些“未表示的类型”很好。似乎“后一种类型的类型通常映射到预定义/已知的 XML 或 Embarcadero 类型”对于这些类型中的大多数来说正是这种情况。像 nonNegativeInteger 和 Base64Binary 这样的“奇怪”的没有在源代码的其他任何地方使用。

补充一点:我在指定初始 WDSL 时出错。该 URL 给出了一个证书错误,导致无法导入依赖文件。一旦我尝试了没有证书错误的备用 URL,https ://webmail.ourmailserver.nl/ews/messages.xsd和https://webmail.ourmailserver.nl/ews/types.xsd被正确导入,我不再需要从磁盘执行此操作。

由于以下构造,生成的文件最初不会编译:

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;”

同样,有两个已发布的属性 Create,编译器认为这些是覆盖基调用中的构造函数。我将它们的名称更改为 MyCreate。

这使得生成的文件编译。

于 2012-10-31T12:23:06.790 回答