Understanding Web References with Compact Framework

One of the core requirements of the client application for the client I am working with is it must communication with a web service. To do this, we created an interface that was implemented in two different ways: a local mocked data source and a remote data source which housed our web service calls.  The mock was little more then a way to mock out local scenarios locally as this application could not be properly debugged when it ran with the remote data source.

This application is built on the Windows Mobile 6 framework and its original concept was conceived by a consultant the client brought in. We decided to utilize WCF for the web service, this would come at a price, however, compact framework only supports basicHttpBinding; which is the slowest and least efficient of all the bindings available in WCF.

To create the proxy classes, we used a tool called NetCfSvcUtil which is proved by the Power Toys for .NET Compact Framework 3.5, this is also what our consultant, with many years of experience in mobile development said we had to use after doing his research.  Thus we did it; it was a very manual process requiring a command line tool to generate the classes and then a copy/paste into a file that at its peak was 14k+ lines of code.  The consultant was removed from the team after his performance proved less then satisfactory.

I took over the project and had to first had to create a solid architecture to prevent the application from crashing randomly and without warning.  Once this was complete we evolved and flushed the application out into what it is now.  A special thanks to Microsoft for their help and guidance in getting the concept into my head of why the problem was occurring.

A second problem cropped up with respect to performance.  Despite what we did we could not get calls to take less then 4s.  After some timing research we determine that our server side methods were running in under .5s in the extreme high case (yes our machines on the back are insane).  Thus we dove into why this might be.  Spent 5 days in and out of the proxy code and scouring the Internet; I will say that after developing this application it is not surprising why Microsoft is getting killed by RIM, Apple, and Google in the mobile device market, really hoping 7 proves to be better.  But there are so few solid examples online of using WinMo 6.

Anyway, thankfully, our client has Premier support with Microsoft, so we decided to throw this issue to them.  Instantly we were told that our previous consultant had made a gross error; I also fault myself for not also doing my own investigation.  Microsoft had us use Web References and instantly we saw a 50% speed improvement.  Apparently doing this, despite the fact that you are effectively doing ASMX over WCF, is that it allows the proxy code to take certain shortcuts that allow it to operate faster.  Still cant use anything besides basicHttpBinding, but Ill take whatever I can get.

So bottom line: do NOT use the Net CF power toys, they arent supported by Microsoft and does not generate efficient code.  When speed is an necessity, use Web References (though 7 does support Service References).

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s