开发者

Calling a C# opeartion with 'Out' from a managed C++ code

Hi I have a WCF web serive which has an opeartion i need to call from a native C++ apllication. I have a bridge managed DLL which works, but I am having truoble with calling a WCF operation which has an OUT object.

The C# opearation:

void DoWork(string indxNum, out ErrorWarningsData objerrc)

Here ErrorWarningsData is a class in the C# Web Service.

This is how 开发者_JS百科my Managed C++ code looks like :

gcroot<Binding^> binding1 = gcnew WSHttpBinding();

gcroot<EndpointAddress^> address1 = gcnew EndpointAddress(gcnew String("http://usatondevlas1.na.praxair.com/Build15/ResourceCenterSVC/ResourceCenter.svc"));

gcroot<HelloServiceClient::ServiceReference2::ResourceCenterServiceContractClient^> client = gcnew HelloServiceClient::ServiceReference2::ResourceCenterServiceContractClient(binding1,address1);

gcroot<HelloServiceClient::ServiceReference2::ErrorWarningsData^> objEWData = gcnew HelloServiceClient::ServiceReference2::ErrorWarningsData;

But when I try to call the DoWork Method from the WCF Service I get an error .

This is what I tried :

client->DoWork("4278779",[Out] objEWData ); Also tried, client->DoWork("4278779",[Out] ^% objEWData ); And, client->DoWork("4278779",[Out] % objEWData );

Could some one please tell me how to access the oject with 'OUT'. I could find some examples to access [Out] for int and string but none for objects

PS: I followed the following to link to connect the WCF service to the native appliaction [link]http://stackoverflow.com/questions/686452/create-wcf-service-for-unmanaged-c-clients


I'm not sure why you are using gcroot in these cases. You can just do:

WSHttpBinding ^ binding1 = gcnew WSHttpBinding(); 
EndpointAddress ^ address1 = gcnew EndpointAddress(gcnew String ("http://usatondevlas1.na.praxair.com/Build15/ResourceCenterSVC/ResourceCenter.svc"));
HelloServiceClient::ServiceReference2::ResourceCenterServiceContractClient ^ client = gcnew HelloServiceClient::ServiceReference2::ResourceCenterServiceContractClient(binding1,address1);
HelloServiceClient::ServiceReference2::ErrorWarningData ^ objEWData = gcnew HelloServiceClient::ServiceReference2::ErrorWarningsData;
client->DoWork("4278779", objEWData); 


You shouldn't need any extra markup in order to pass something as an out parameter in C++/CLI. The semantics are similar to passing by reference in native C++.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜