开发者

WCF - Main "Router"

开发者 https://www.devze.com 2023-03-29 16:29 出处:网络
My assignment is to create an App for a Mobile Device (Like iphone/android/BB/etc..), the purpose of this app is to tell the users there is something new on the website and then show an list (inside t

My assignment is to create an App for a Mobile Device (Like iphone/android/BB/etc..), the purpose of this app is to tell the users there is something new on the website and then show an list (inside the App) showing the latest updates.

The Company insisted I use ASP.NET/C#/Visual Studio and use the SOAP protocol.

I've started working with C# and then using the so called WCF.

I've already got some stuff working. (Like "consuming" the WCF from an Android App and getting data sent back).

My Question is what will be the best "Architecture" to work with for the Mobile App Development. I was thinking about have only 1 WCF and then call a general function like Do() (Or some other name :)) and then adding a soap header where u can define what u want the service todo. Like getting a record from the database, or ping , er something else, whatever the company may need in the future :)

How this would work:

The Client (Mobile App) would make a call to the WCF, and in the soap header is states, lets say, it wants to register the Phone with the Device ID. The WCF will receive the Soap Requests, extract the header and use some sort of switch to decide what it needs todo. Once it knows that to do the WCF will then, for example, access some local Classes to insert/retrieve Database data or do something else and when its done it will simply return what is needed. (Like an OK sign or data or something else.. :)).

Is this a right approach, cause how I am looking at this, it makes it very easy for changes on the back end without updating the App.

Sorry if this a retarded question, but I am new to WCF and Mobile App Development, and i'am trying to deliver a great product at the end of my internship. I was just wondering what sort of "Architecture" you guys suggest I would use for this sort of assignment.


EDIT

I already told them SOAP is too heavy for mobile development and shown them some graphs. But they insisted to use techniques they already know.

After doing some research I indeed think the contract based approach is the better way to go. But can you maybe answer a few questions regarding it?

-Can I have like one WCF file that gets "consumed" which holds all the different operations?

-Can I authenticate the client (With using Soap headers Required) at the beginning of the WCF and after that call t开发者_运维问答he desired operation?


SOAP is generally regarded as a little too heavy for mobile development. Since users may incur data charges and generally have lower bandwidth, it would be preferable to take a REST/JSON approach. You can still use WCF to do this at the server.

You can use a generic operation (MessageAction="*") but you will then need to handle the serialisation/deserialistion of messages yourself. However, unless you have a pressing reason to do this I would suggest properly structured operations are the better way to go. They are much more maintainable. You can still make implementation changes at the server without affecting the client, as long as the message contract does not alter. The reality is that if you want to change the message or operation contracts you will have to make changes to the clients anyway. After considering this, the 'contract' based approach only has upsides and no real downsides.

0

精彩评论

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

关注公众号