Malaysia organizations don't realize severity of cyberattacks http://t.co/PUCv68Rd
42 minutes ago by ALLsecuritySoft on twitter
ZDNet is available in the following editions:
Justin James shares his experience of putting together a Windows Communication Foundation service, which he says was much easier than expected.
technology, software engineering, computer technology, software development, software, science and technology, justin james, microsoft .net framework, levit , techrepublic.com
When I decided to create a Windows Communication Foundation (WCF) Data service, the goal was to take an existing class library and expose a portion of its functionality as an action. My biggest issue with this process was that .NET class libraries are focused around providing objects that happen to have some methods, but WCF services are focused on the methods.
This inversion of architecture can provide some challenges. Fortunately, I have a heavy background in non-object-oriented (OO) languages, and I often write my objects to be focused around one or two methods, which was the case here. This greatly smoothed the transition to WCF.
A summary of the work performed
In the original library, a primary object was used (with several supporting objects to be used as data structures for properties). Once enough of the properties (some optional) had values in them, an execution method could be called. This wasn't great or "correct" OO design, but the OO architecture is really poor for times when all you really want is a function with a lot of parameters (some optional).
When I went to WCF, I wanted to be able to expose this one method and pass in a data structure that essentially encapsulated all of the properties. In other words, I went from having a data structure with one method that used the properties of the object to a method that accepted all of those properties as a data structure. In both cases, I was getting back a data structure that represented a list of result objects.
The first step was to add a WCF service project to my solution. This created a stub service for me. The stub service contained an interface file, a service file (.svc), and a Web.config file. I renamed the interface and service files to match my service name, and then opened the files and did the same for the service and class defined. Like ASP.NET, the service file has a code behind file, which is what I was actually going to work with.
The code behind and interface have a basic implementation, but it was not useful to me (it does serve as a handy reference point if you are not familiar with this work, though). The place to start is in the interface. It is not mandatory to use an interface, but it is helpful in certain scenarios for architecture reasons, such as when consuming the WCF service directly from another .NET application.
In the interface (which should be decorated with ServiceContract), I created my data structures that I would need for parameters and output values as WCF Data Contracts. To do this, I created classes and decorated it with DataContract. Within the class, I implemented the properties. The properties, which should be exposed via WCF, should be decorated with DataMember.
Something to keep in mind is that, as you walk the property tree, all of the leaf nodes must be primitive types. I opted to not worry about data validation at the WCF level, primarily because I would be the only person using this service.Once the data structures were complete, I defined in the interface a method (decorated with OperationContract) that represented the functionality I wanted to expose. Then, I removed the default items that the add project wizard created.
Figure A
The default interface implementation. (Click the image to enlarge.)
Figure B
A better look at the code in the default interface. (Click the image to enlarge.)
Next, I went into the service code behind file to implement the interface. This is simply a matter of creating methods that implement the interface's methods and performing the actual work. I just had to create an object from my class library and set its properties to the values from the input parameter. Once I had those properties set, I called its execution method and captured the results. I created an object of the method's return type and populated its values from the captured results. Then, that object was returned to the client.
Figure C
The default service code behind. (Click the image to enlarge.)
Figure D
A better look at the code in the default service code behind. (Click the image to enlarge.)
When you run the project, it will start a local Web server in Visual Studio and bind it to a random port, like working with an ASP.NET project. To test the service, I used the WCF Test Client application, which should open automatically when you run the project; if it doesn't open automatically, look for WcfTestClient.exe in the IDE directory within the Visual Studio installation directory. The test client allows you to make calls against a WCF service and inspect the results. Combining this with the usual breakpoints, watches, etc. will allow you to perform your troubleshooting like any other application.
Figure E
The WCF Test Client. (Click the image to enlarge.)
I was deploying to IIS, so there was no need to write code to launch the service, open connections, etc. I could have defined additional endpoints in my Web.config, but the defaults worked fine for me. To make it easier, run the WCF Service Configuration Editor (it's in the Tools menu) once, and it will work as a context-menu item in Solution Explorer.
Figure F
The WCF Service Configuration Editor. (Click the image to enlarge.)
Deploying is a snap. I installed the Web Deployment components on my server, right-clicked the project in Solution Explorer, and chose Publish. Filling out the wizard is pretty obvious. There are additional settings in the project's properties to allow more control over the publishing.
Figure G
The service publishing wizard. (Click the image to enlarge.)
Conclusion
It was much easier to create my WCF service than I expected. Although I didn't go very deep into WCF's capabilities, such as security and authentication, I don't think most developers need those items (though, from what I have seen, the capabilities are not particularly hard to implement).
If you have been holding back on providing functionality as a Web service because it looked complicated or were confused about how to do it, it's time to roll up your sleeves and get started.
Justin James is an employee of Levit & James, Inc. in a multidisciplinary role that combines programming, network management and systems administration. He has been blogging at TechRepublic since 2005.
Malaysia organizations don't realize severity of cyberattacks http://t.co/PUCv68Rd
42 minutes ago by ALLsecuritySoft on twitterNews: Radio Costa Rica by EnjoyIT 1.0: Radio Costa Rica allows you to listen to a great var... http://t.co/BLzVT5As http://t.co/1Dhcy6ki
42 minutes ago by CostaRica_VIP on twitterThe key for mobile operators is identifying the applications that are popular with subscribers on their network. They can then work partn...
2 hours ago by camcullen on Experience trumps content in apps monetizationExperience trumps content in apps monetization | ZDNet http://t.co/gBXcjbGd
2 hours ago by DennisOosterman on twitterExperience trumps content in apps monetization - ZDNet Asia News: "What we are doing currently is not to monetiz... http://t.co/S2EZtd8m
3 hours ago by kennyfabre1 on twitterMalaysia organizations don't realize severity of cyberattacks: "Minister Maximus Johnity Ongkili said at the Sec... http://t.co/bgVlOBvx
4 hours ago by Bug2Hunt on twitter#security Malaysia organizations don't realize severity of cyberattacks: "Minister Maximus Johnity Ongkili said ... http://t.co/hkFb4zrI
4 hours ago by Wiredsec on twitterMalaysia organizations don't realize severity of cyberattacks http://t.co/EEEmRM3j via @zdnetasia
4 hours ago by RedDragon1949 on twitterMalaysia organizations don't realize severity of cyberattacks - ZDNet Asia News http://t.co/YpNMYgb5
4 hours ago by RedDragon1949 on twitterMalaysia organizations don't realize severity of cyberattacks http://t.co/FFems54Q
5 hours ago by mytech_pro on twitterChina solar cell makers seek Taiwan partnerships http://t.co/p5Hh7kJD
6 hours ago by Export2China on twitterBig data acquisitions pave way to fast, effective innovation http://t.co/hdiEfBsz via @zdnetasia
6 hours ago by jowoodley on twitterIntegration, focused investments to propel Windows Phone: By Kevin Kwang , ZDNet Asia on May 23, 2012 (2 hours a... http://t.co/E7tsZbHJ
7 hours ago by Easyforexdotcom on twitterIntegration, focused investments to propel Windows Phone http://t.co/u9TqjQ8C
7 hours ago by ashvin_9 on twitterAsiaClassifiedToday. Integration, focused investments to propel Windows Phone - ZDNet Asia: S... http://t.co/47tdjZyG #asia #google #biz
8 hours ago by ChemarieMonica on twitterSo much as we know , MTK6575 extremely integrated frequency1GHz ARM Cortex-A9 processor, the superiority of 3G / HSPA Modem, and help the...
1 day ago by y15822137359 on 5 SaaS adoption speed bumps to avoidI reckon your view: "CRM is strategy, not software", if a company replicating the approach uses in ERP implementation into CRM, what they...
2 days ago by wykoong on Gartner: Mobile CRM gives better ROI than socialThis video will teach you about the Excel fill handle but also provide you with a workook to download... http://www.youtube.com/watch?v=...
3 days ago by TradeBrother on A quick fill handle trick for Microsoft Excelwaiting...
5 days ago by eapete on What should count in a company's market value?Boy, you've opened a can of worms now.
Wait for the rants & raves.
I was puzzling before this whether to replicate the success formula we executed for a financial institute, and come out with a standard s...
5 days ago by wykoong on Drop the egos, copy ideas, then innovateThreats and malware know no boundaries. Neither should your web security. See how far Blue Coat Unified Web Security goes to protect your network.
Echelon 2012 - The Awesomer Tech Event in Asia
Echelon 2012 – SEA’s longest running tech startup event goes Awesomer. Catch 50 of Asia’s most promising startups & over 40 international speakers on June 11-12.
Startup Asia Jakarta showcases new product-ready tech startups. Plus: hackathon, exhibition, and speakers. Use promo code CBSi50 for 50% discount.
ZDNet Asia Intelligent Singapore video series
Featuring inteviews with CXOs who define "intelligence" in their markets and reveal how their companies drive business efficiencies through ICT.