【发布时间】:2012-12-20 07:57:16
【问题描述】:
我正在学习 WCF-WWSAPI 并尝试在服务上使用可视 C++ 客户端和 C# 开发 ICalculator example over TCP and duplex calls... 基本上我的客户端是程序正在尝试将 555 添加到服务号,服务将调用客户端通过回调在屏幕上打印结果... client -> service dommunications 工作正常,我的客户端可以将值发送到调用 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);
}
任何帮助/建议将不胜感激
非常感谢
曼努埃尔
【问题讨论】:
标签: c++ wcf web-services wcf-binding wwsapi