TWSDLHTMLPublish 生成错误的 wsdl?
TWSDLHTMLPublish generates wrong wsdl?
我正在使用 Delphi 10.4.2 并且正在编写 SOAP 服务器应用程序。
为了生成 WSDL,我正在使用 TWSDLHTMLPublish 组件放在我的 TWebModule 后代上。我在将属性和可选元素公开到 wsdl 文件时遇到问题。
我的界面这样定义对象:
// TRemotable Property Index constants.
// Quelle: http://www.codenewsfast.com/cnf/article/0/permalink.art-ng1920q2865
const
IS_OPTN = [=10=]01; // This element is optional (minOccurs=0); Don't serialize it if its value was not explicitly set
IS_UNBD = [=10=]02; // This array element is unbounded (The runtime serializes dyn arrays as either collection or unbounded elements)
IS_NLBL = [=10=]04; // This element is nillable (xsi:nillable=true)
IS_UNQL = [=10=]08; // This element is unqualified (see http://www.w3schools.com/schema/el_schema.asp) Runtime defaults to qualified otherwise
IS_ATTR = [=10=]10; // This property is an attribute (otherwise the runtime serializes it as an element)
IS_TEXT = [=10=]20; // This property is text (typically of the parent element) (see http://www.w3schools.com/schema/schema_complex_text.asp)
IS_ANY = [=10=]40; // This property represents an xsd:any element (not really used by runtime)
IS_REF = [=10=]80; // This property is a ref (i.e. ref=QName) element (see http://www.w3schools.com/schema/el_element.asp)
IS_QUAL = 00; // This attribute is qualified (the runtime defaults to unqualified otherwise)
type
OrderDirection = (OrderNONE, OrderASC, OrderDESC);
ProjektOrderField = (pofNONE, pofID, pofNummer, pofStatus);
ProjektStatus = (psAll, psAnfrage, psAuftrag, psAbgeschlossen);
ProjektFilterType = class(TRemotable)
private
FStatus : ProjektStatus;
FStatus_specified : Boolean;
FOrderField : ProjektOrderField;
FOrderField_specified : Boolean;
FOrderDir : OrderDirection;
FOrderDir_specified : Boolean;
FTestAttribut : string;
Procedure SetStatus (Index: Integer; const Value: ProjektStatus);
Procedure SetOrderDir (Index: Integer; const Value: OrderDirection);
Procedure SetOrderField (Index: Integer; const Value: ProjektOrderField);
public
Function Status_Specified (Index: Integer) : Boolean;
Function OrderDir_Specified (Index: Integer) : Boolean;
Function OrderField_Specified(Index: Integer) : Boolean;
published
property TestAttribut : string Index (IS_UNQL OR IS_ATTR) read FTestAttribut write FTestAttribut;
property Status : ProjektStatus Index (IS_UNQL OR IS_OPTN) read FStatus write SetStatus stored Status_specified;
property OrderField : ProjektOrderField Index (IS_UNQL OR IS_OPTN) read FOrderField write SetOrderField stored OrderField_specified;
property OrderDir : OrderDirection Index (IS_UNQL OR IS_OPTN) read FOrderDir write SetOrderDir stored OrderDir_specified;
end;
// ================================================================================
{$REGION ' ==================== ProjektFilterType ===================='}
Function ProjektFilterType.Status_Specified(Index: Integer) : Boolean;
begin
Result := FStatus_Specified;
end;
Function ProjektFilterType.OrderDir_Specified(Index: Integer) : Boolean;
begin
Result := FOrderDir_Specified;
end;
Function ProjektFilterType.OrderField_Specified(Index: Integer) : Boolean;
begin
Result := FOrderField_Specified;
end;
Procedure ProjektFilterType.SetStatus(Index: Integer; const Value: ProjektStatus);
begin
FStatus := Value;
FStatus_Specified := true;
end;
Procedure ProjektFilterType.SetOrderDir(Index: Integer; const Value: OrderDirection);
begin
FOrderDir := Value;
FOrderDir_Specified := true;
end;
Procedure ProjektFilterType.SetOrderField(Index: Integer; const Value: ProjektOrderField);
begin
FOrderField := Value;
FOrderField_Specified := true;
end;
{$ENDREGION}
// ================================================================================
输出的 wsdl 文件如下所示:
<xs:complexType name="ProjektFilterType">
<sequence xmlns="http://www.w3.org/2001/XMLSchema">
<xs:element name="TestAttribut" type="xs:string"/>
<xs:element name="Status" type="ns1:ProjektStatus"/>
<xs:element name="OrderField" type="ns1:ProjektOrderField"/>
<xs:element name="OrderDir" type="ns1:OrderDirection"/>
</sequence>
</xs:complexType>
问题:IS_ATTR 根本不起作用 - 输出是 xs:element 而不是 xs.attribute 并且元素缺少 MinOccurs="0" 和 MaxOccurs="1" 属性.
我做错了什么?除了 属性-Index?
之外,我必须定义任何 RTTI 属性
好的,我在 Embarcaqdero Sourrces 中找到了这个:
注意:目前序列化选项仅供客户端使用。即,当从 WSDL 创建类型时,它们由 WSDL 导入器使用。服务器应该 NOT 使用这些选项注册任何类型,因为 WSDL 发布逻辑将忽略所有序列化选项。 IOW,这些标志在这里是为了使语言绑定适应不容易映射到本机类型的构造——比如带有属性的数组示例。服务器不需要求助于任何这些标志,因为服务器的所有需求都可以映射到 SOAP,而无需使用 holder 类.
所以我将手动生成我的 wdsl 并使用 wsdl-importer 生成接口单元。我希望有更简单的方法(对我来说 :-))但我可以忍受这个...
我正在使用 Delphi 10.4.2 并且正在编写 SOAP 服务器应用程序。 为了生成 WSDL,我正在使用 TWSDLHTMLPublish 组件放在我的 TWebModule 后代上。我在将属性和可选元素公开到 wsdl 文件时遇到问题。
我的界面这样定义对象:
// TRemotable Property Index constants.
// Quelle: http://www.codenewsfast.com/cnf/article/0/permalink.art-ng1920q2865
const
IS_OPTN = [=10=]01; // This element is optional (minOccurs=0); Don't serialize it if its value was not explicitly set
IS_UNBD = [=10=]02; // This array element is unbounded (The runtime serializes dyn arrays as either collection or unbounded elements)
IS_NLBL = [=10=]04; // This element is nillable (xsi:nillable=true)
IS_UNQL = [=10=]08; // This element is unqualified (see http://www.w3schools.com/schema/el_schema.asp) Runtime defaults to qualified otherwise
IS_ATTR = [=10=]10; // This property is an attribute (otherwise the runtime serializes it as an element)
IS_TEXT = [=10=]20; // This property is text (typically of the parent element) (see http://www.w3schools.com/schema/schema_complex_text.asp)
IS_ANY = [=10=]40; // This property represents an xsd:any element (not really used by runtime)
IS_REF = [=10=]80; // This property is a ref (i.e. ref=QName) element (see http://www.w3schools.com/schema/el_element.asp)
IS_QUAL = 00; // This attribute is qualified (the runtime defaults to unqualified otherwise)
type
OrderDirection = (OrderNONE, OrderASC, OrderDESC);
ProjektOrderField = (pofNONE, pofID, pofNummer, pofStatus);
ProjektStatus = (psAll, psAnfrage, psAuftrag, psAbgeschlossen);
ProjektFilterType = class(TRemotable)
private
FStatus : ProjektStatus;
FStatus_specified : Boolean;
FOrderField : ProjektOrderField;
FOrderField_specified : Boolean;
FOrderDir : OrderDirection;
FOrderDir_specified : Boolean;
FTestAttribut : string;
Procedure SetStatus (Index: Integer; const Value: ProjektStatus);
Procedure SetOrderDir (Index: Integer; const Value: OrderDirection);
Procedure SetOrderField (Index: Integer; const Value: ProjektOrderField);
public
Function Status_Specified (Index: Integer) : Boolean;
Function OrderDir_Specified (Index: Integer) : Boolean;
Function OrderField_Specified(Index: Integer) : Boolean;
published
property TestAttribut : string Index (IS_UNQL OR IS_ATTR) read FTestAttribut write FTestAttribut;
property Status : ProjektStatus Index (IS_UNQL OR IS_OPTN) read FStatus write SetStatus stored Status_specified;
property OrderField : ProjektOrderField Index (IS_UNQL OR IS_OPTN) read FOrderField write SetOrderField stored OrderField_specified;
property OrderDir : OrderDirection Index (IS_UNQL OR IS_OPTN) read FOrderDir write SetOrderDir stored OrderDir_specified;
end;
// ================================================================================
{$REGION ' ==================== ProjektFilterType ===================='}
Function ProjektFilterType.Status_Specified(Index: Integer) : Boolean;
begin
Result := FStatus_Specified;
end;
Function ProjektFilterType.OrderDir_Specified(Index: Integer) : Boolean;
begin
Result := FOrderDir_Specified;
end;
Function ProjektFilterType.OrderField_Specified(Index: Integer) : Boolean;
begin
Result := FOrderField_Specified;
end;
Procedure ProjektFilterType.SetStatus(Index: Integer; const Value: ProjektStatus);
begin
FStatus := Value;
FStatus_Specified := true;
end;
Procedure ProjektFilterType.SetOrderDir(Index: Integer; const Value: OrderDirection);
begin
FOrderDir := Value;
FOrderDir_Specified := true;
end;
Procedure ProjektFilterType.SetOrderField(Index: Integer; const Value: ProjektOrderField);
begin
FOrderField := Value;
FOrderField_Specified := true;
end;
{$ENDREGION}
// ================================================================================
输出的 wsdl 文件如下所示:
<xs:complexType name="ProjektFilterType">
<sequence xmlns="http://www.w3.org/2001/XMLSchema">
<xs:element name="TestAttribut" type="xs:string"/>
<xs:element name="Status" type="ns1:ProjektStatus"/>
<xs:element name="OrderField" type="ns1:ProjektOrderField"/>
<xs:element name="OrderDir" type="ns1:OrderDirection"/>
</sequence>
</xs:complexType>
问题:IS_ATTR 根本不起作用 - 输出是 xs:element 而不是 xs.attribute 并且元素缺少 MinOccurs="0" 和 MaxOccurs="1" 属性.
我做错了什么?除了 属性-Index?
之外,我必须定义任何 RTTI 属性好的,我在 Embarcaqdero Sourrces 中找到了这个:
注意:目前序列化选项仅供客户端使用。即,当从 WSDL 创建类型时,它们由 WSDL 导入器使用。服务器应该 NOT 使用这些选项注册任何类型,因为 WSDL 发布逻辑将忽略所有序列化选项。 IOW,这些标志在这里是为了使语言绑定适应不容易映射到本机类型的构造——比如带有属性的数组示例。服务器不需要求助于任何这些标志,因为服务器的所有需求都可以映射到 SOAP,而无需使用 holder 类.
所以我将手动生成我的 wdsl 并使用 wsdl-importer 生成接口单元。我希望有更简单的方法(对我来说 :-))但我可以忍受这个...