我正在学习 WCF-WWSAPI 并尝试通过 TCP 开发 ICalculator 示例,并在服务上使用可视 C++ 客户端和 C# 进行双工调用...基本上我的客户端是程序正在尝试将 555 添加到服务号和服务将调用客户端通过回调在屏幕上打印结果...客户端-> 服务管理工作正常,我的客户端可以将值发送到调用 AddTo 函数的服务,它会工作。但是出于某种原因,我的客户没有收到要从服务中打印出来的值......
这就是我的客户所做的:
hr = WsCreateMessageForChannel(
threadInfo->channel,
NULL,
0,
&message,
error);
if (FAILED(hr))
{
PrintError(hr, error);
}
const WS_MESSAGE_DESCRIPTION* messageDescriptions[] = {
// Result callback message
&tempuri_org_wsdl.messages.ICalculatorDuplex_Equals_OutputCallbackMessage, //<-- CHECK ON TEMPURI.ORG.WSDL.H
// Equation callback message
&tempuri_org_wsdl.messages.ICalculatorDuplex_Equation_OutputCallbackMessage //<-- CHECK ON TEMPURI.ORG.WSDL.H
};
for (;;) // to receive all potential callback messages in an infinite loop
{
void* callbackBody = NULL;
ULONG index = 0;
hr = WsReceiveMessage(
threadInfo->channel,
message,
messageDescriptions,
WsCountOf(messageDescriptions),
WS_RECEIVE_OPTIONAL_MESSAGE,
WS_READ_REQUIRED_POINTER,
heap,
callbackBody, <===this VALUE is 0x000000 from the server and I send an int
sizeof(callbackBody),
&index, // The returned index is used to determine which callback is received
NULL,
error);
这是我用来接收回调的服务器构造函数:
public CalculatorService()
{
result = 0.0D;
equation = result.ToString();
callback = OperationContext.Current.GetCallbackChannel<ICalculatorDuplexCallback>();
}
这是我在合同上的回调函数:
public void AddTo(double n)
{
Console.WriteLine("Dentro de AddTo");
result += n;
equation += " + " + n.ToString();
callback.Equals(result);
}
任何帮助/建议将不胜感激
非常感谢你
曼努埃尔