Web 服务扩展文件
本部分概述了 Web 服务扩展文件。
WSX 文件 (WCF 服务扩展) 是扩展文件,允许应用程序操作不影响线路数据表示形式的本地行为。 在将来,我们可以在不中断互操作性的情况下添加新功能,这应该是可扩展的。
WSX 的整体结构将模拟 XSD 或 WSDL 文件的结构,这是一个 XML 文件,它维护与主输入文件相同的结构。 主文件中同一命名令牌上的额外属性将指定应用程序想要控制默认行为的属性。
我们可能在 M3 中没有任何作用。 在 V1 中,我可以看到我们支持以下属性:
使用指定计数参数/参数字段。
这是一个元素属性,但仅适用于数组类型。 IsCountOf 属性指定数组元素。 计数字段/参数不显示在网络上。
<xs:schema xmlns:tns="http://Example.org" elementFormDefault="qualified"
targetNamespace="http://Example.org" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<element name="FooInParam">
<complexType>
<!-- MyArray field is presented in WSDL file as an element -->
<element name="MyArrayCount" IsCountOf="MyArray"></element>
</complexType>
</element>
</xs:schema>
为自定义类型指定读/写回调
这些属性强制wsutil.exe为指定类型生成 WS_CUSTOM_TYPE 。 custom_readcallback属性指定 读取回调 例程,custom_writecallback指定 写入回调 例程。
<xs:schema xmlns:tns="http://Example.org" elementFormDefault="qualified"
targetNamespace="http://Example.org" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<element name="mytype" custom_readcallback="myreadcallback" custom_writecallback="mywritecallback">
</element>
</xs:schema>
我们可以有一个匹配的 WSX 文件来描述其本地行为:
<xs:schema xmlns:tns="http://Example.org" elementFormDefault="qualified"
targetNamespace="http://Example.org" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<element name="FooInParam" DataValidationRoutine="MyArrayValidation">
<complexType>
<element name="MyLocalArrayCount" IsCountOf="MyArray"></element>
</complexType>
</element>
</xs:schema>
WsUtil.exe为结构生成以下原型:
typedef struct FooInParam
{
ULONG MyLocalArrayCount;
int * MyArray;
};