我正在学习WCF-WWSAPI并尝试使用可视化C ++客户端和服务上的C#开发ICalculator example over TCP and duplex calls ... 基本上我的客户端程序正在尝试将555添加到服务号码,服务将调用客户端通过回调在屏幕上打印结果... 客户 - > 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);
}
任何帮助/建议都将受到高度赞赏
非常感谢
曼努埃尔
答案 0 :(得分:0)
for (;;) // to receive all potential callback messages in an infinite loop
{
void* callbackBody;
ULONG index = 0;
hr = WsReceiveMessage(
threadInfo->channel,
threadInfo->message,
//&messageDescriptions[0],
messageDescriptions,
WsCountOf(messageDescriptions),
WS_RECEIVE_OPTIONAL_MESSAGE,
WS_READ_REQUIRED_POINTER,
heap,
&callbackBody,
sizeof(callbackBody),
&index, // The returned index is used to determine which callback is received
NULL,
error);
现在我可以使用WWSAPI和netTcpBinding获取数据作为回调!!!!
对我有好处!!!