Good Afternoon, I´m working with G120 Module and NETMF V4.3. I need to consume a WCF service and I hoped It was as simple as in .NET framework, I mean, something like this:
Service1Client client = new Service1Client();
// Use client methods.
But I discovered that .NETMF doesn´t have the “Add Reference → Service reference” option, so I tried to make a .NET framework dll and use it on .NETMF but it turns out that generic dll´s cannot be compiled. Therefore, I decided to see the samples (HelloWorldClient_WCF and HelloWorldServer_WCF) as well as the forums. I found two different approaches:
It is stated in the first option that the code will work with both V4.2 and V4.3 but I dont have:
So I´m working with the second option. Does anyone have experience dealing with consuming web services? can anyone give me some advices regarding how can I consume a regular web service in NETMF V4.3?
@ Miguel - As Jay Jay mentioned, the Codeshare you linked is setup so your Micro Framework device acts as the WCF server and your PC acts as the WCF client. If you want to reverse those roles, you will need to rewrite the WCF client code slightly because NETMF does not have the namespaces you mentioned nor does it support generics.
The samples you also mentioned should be useful in getting started with WCF.
Good afternoon, I already consume the “HelloWorldServer_MF” server in my application and works fine. The second step is to consume my client´s web service instead of the default example mentioned above. I have a simple question in order to know what is going wrong. The documetation says that if the server app uses “wsHttpBinding” you should use protocolVersion11. I saw my client´s web service and uses basicHttpBinding, and I guess this is why it isn´t working. FYI, my discover function is always returning false with basicHttpBinding service, while works perfectly with the “HelloWorldServer_MF” example.
Do you think this binding differences could cause this discover problems?
Thank you very much for your information and cooperation.
Hi guys, I`ve struggled a lot trying to consume an existing web service hosted in WCF on a Windows Service / IIS, and maybe that´s not possible. The example works because the HelloWorldServer_WCF is running on my PC, but I haven´t seen any examples of NETMF devices connecting to IIS hosted services. Is it possible to do this?
@ Miguel - It is definitely possible as I have had a Cerb 40 II talking to a Web API (vs WCF) based REST service hosted in a Azure instance of IIS. It was part of a garage door opener project I used to become familiar with NETMF development. It is no longer in use, but it worked at one time.
To call your WCF service “traditionally”, you need to use the C:\Program Files (x86)\Microsoft .NET Micro Framework\v4.3\Tools\MFSvcUtil.exe tool to generate the client code used to call your service from within a NETMF device.
So search the web for how to use MFSvcUtil.exe. It is fairly simple. Just open a console window and run the exe against your WCF service (C:\Program Files (x86)\Microsoft .NET Micro Framework\v4.3\Tools\MFSvcUtil.exe http://you-site.com/YourService.svc?wsdl /v)
Add the generated files to your NETMF project and call your service.
Also, be sure to include the ws2007HttpBinding service endpoint binding I describe a few posts ago. :dance:
Thanks for your replies. I decided to use a socket connection and send all the SOAP protocol. It´s working perfectly, and since I´m in a rush, I will stick with this solution until I have some more spare time to deal with this situation.