合约
服务协定承载定义服务如何处理通道消息的元数据。
WS_SERVICE_CONTRACT承载服务的元数据来处理WS_MESSAGE。
它具有 WS_CONTRACT_DESCRIPTION 和函数表。 应用程序可以选择指定 WS_SERVICE_MESSAGE_RECEIVE_CALLBACK。
如果未提供 WS_CONTRACT_DESCRIPTION 和函数表,则应用程序需要指定 WS_SERVICE_MESSAGE_RECEIVE_CALLBACK。
static WS_SERVICE_CONTRACT calculatorContract =
{
&calculatorContractDescription,
NULL,
&calculatorFunctions,
};
有关详细信息,请参阅 计算器 示例。
合同说明
WS_CONTRACT_DESCRIPTION 是定义服务类型协定的元数据。 由 wsutil.exe生成。
在 WSDL 方面, WS_CONTRACT_DESCRIPTION 映射到 wsdl:portType。 对于 WSDL 文档中的每个 wsdl:portType,将生成单独的 WS_CONTRACT_DESCRIPTION 。
合同说明由或更多 服务操作组成。 这些操作以 WS_OPERATION_DESCRIPTION数组的形式提供。
<wsdl:definitions xmlns:soap="https://schemas.xmlsoap.org/wsdl/soap/"
xmlns:wsu="https://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"
xmlns:soapenc="https://schemas.xmlsoap.org/soap/encoding/" xmlns:tns="https://Example.org"
xmlns:wsa="https://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsp="https://schemas.xmlsoap.org/ws/2004/09/policy"
xmlns:wsap="https://schemas.xmlsoap.org/ws/2004/08/addressing/policy" xmlns:xsd="https://www.w3.org/2001/XMLSchema"
xmlns:msc="http://schemas.microsoft.com/ws/2005/12/wsdl/contract" xmlns:wsaw="https://www.w3.org/2006/05/addressing/wsdl"
xmlns:soap12="https://schemas.xmlsoap.org/wsdl/soap12/" xmlns:wsa10="https://www.w3.org/2005/08/addressing"
xmlns:wsx="https://schemas.xmlsoap.org/ws/2004/09/mex" targetNamespace="https://Example.org"
xmlns:wsdl="https://schemas.xmlsoap.org/wsdl/">
<wsdl:portType name="ICalculator">
<wsdl:operation name="Add">
<wsdl:input wsaw:Action="https://Example.org/ICalculator/Add"
message="tns:ICalculator_Add_InputMessage" />
<wsdl:output wsaw:Action="https://Example.org/ICalculator/AddResponse"
message="tns:ICalculator_Add_OutputMessage" />
</wsdl:operation>
</wsdl:portType>
</wsdl:definitions>
有关 wsdl:portType 到 WS_CONTRACT_DESCRIPTION 转换的详细信息,请参阅 WSDL 输出部分。
static WS_CONTRACT_DESCRIPTION contractDescriptionICalculator =
{
WsCountOf(serviceOperationsICalculator),
serviceOperationsICalculator
};
函数表
函数表是表示服务协定中每个 服务操作 的函数指针的结构。 函数表定义也由 wsutil.exe生成。
示例:函数表
// Function Table
struct CalculatorServiceFunctionTable
{
AddOperation Add;
SubtractOperation Subtract;
};
// Populate the Function Table
static const CalculatorServiceFunctionTable calculatorFunctions = {Add, Subtract};
使用 WS_SERVICE_MESSAGE_RECEIVE_CALLBACK
WS_SERVICE_MESSAGE_RECEIVE_CALLBACK 具有双重互斥角色。
如果在WS_SERVICE_CONTRACT上指定了WS_CONTRACT_DESCRIPTION,则会成为指定WS_CONTRACT_DESCRIPTION不支持的所有操作的默认消息处理程序。 否则,如果未在WS_SERVICE_CONTRACT上指定WS_CONTRACT_DESCRIPTION,并且将在WS_SERVICE_CONTRACT上指定WS_SERVICE_MESSAGE_RECEIVE_CALLBACK,则传入的所有消息都传递给此回调。
有关更多示例,请参阅
以下回调是协定的一部分:
以下结构是合同的一部分: