42 bands from 15 countries to feature at Music Matters Live 2012 which will beam live via YouTube for 1st time this year. #mm12
14 minutes ago by EileenZDNetAsia on twitter
ZDNet is available in the following editions:
Consuming a Web service in a .NET application is a straightforward process. Tony Patton discusses a Web services project with both Java and .NET.
I once worked on a project that utilized a backend built with Java and a user interface constructed with .NET. Communication between the Java and .NET components was necessary for a successful project, so a Web service was installed on the Java side with it being utilized by the .NET front-end.
The Web service eased the process of integrating the two disparate environments, so it was a win-win for both sides. Also, I was quite impressed with how easy it was to utilize the external Web service on the .NET side.
What you need
Using a Web service in a .NET project involves
creating and compiling a proxy class, which is generated from a
reference to the Web service. This reference may be in several
formats:
If you use Visual Studio .NET, it's easy to add a Web service to your project by adding a Web Reference. This allows you to enter the Web service's location (using one of the methods from the list). In addition, you may use the WSDL.exe tool included with the .NET Framework installation.
Here's the process of using a Web service:
For demonstration purposes, I'll use a sample Web service from the xMethods' Web site. This service allows a temperature to be retrieved given a proper U.S. zip code. At this point, step one is completed so the WSDL file is used to create the proxy class:
WSDL.exe /out:TemperatureService.cs /n:BuilderWS
/l:CS
http://www.xmethods.net/sd/2001/TemperatureService.wsdl
The VB.NET equivalent requires one change: The language option should be /l:VB. The result of this step is a source code file.
Click here to see the C# equivalent.
Now you can compile the source code with your IDE or via the command line. The following line shows how the code may compile with the command-line C# compiler:
csc /t:library /out:TemperatureService.dll
TemperatureService.cs
/reference:System.Web.Services.dll /optimize
A few points on the compilation:
In this example, we include the System.Web.Services namespace via its .dll.
If your language of choice is VB.NET, you can easily use the VB.NET compiler. Click here.
The result of these steps is a .dll that may be used in a project to call the Web service.
Using the Web service
At this point, you can use the Web service in a
project. You can place the new .dll in the same directory as your
project or install it in the Global Assembly Cache (GAC). In the
next example, the service is utilized in a simple ASP.NET page via
C#:
<%@ Page language="c#" %>
<%@ Import Namespace="BuilderWS" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
>
<script language="C#" runat="server">
private void Page_Load(object sender, System.EventArgs e) {
TemperatureService testService = new TemperatureService();
float temp = testService.getTemp("40243");
this.txtTemp.Text = temp.ToString();
}
</script>
<html><head>
<title>Builder.com Web Service utilization
example</title>
</head>
<body>
<form id="frmWSExample" method="post" runat="server">
<asp:TextBox id="txtTemp" style="Z-INDEX: 101; LEFT: 224px;
POSITION: absolute;
TOP: 64px" runat="server" />
<asp:Label id="lblOutput" style="Z-INDEX: 102; LEFT: 32px;
POSITION: absolute;
TOP: 64px" runat="server" Width="176px">The current temperature
is:</asp:Label>
</form></body></html>
The Web service accepts the zip code parameter
as a string value, while returning a float value representing the
temperature. The zip code passed is hard coded, but it could easily
be dynamic, allowing the user to specify the zip. The VB.NET
equivalent follows:
<%@ Page language="vb" %>
<%@ Import Namespace="BuilderWS" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
>
<script language="vb" runat="server">
Sub Page_Load
Dim testService As New TemperatureService()
Dim temp As double
temp = testService.getTemp("40243")
me.txtTemp.Text = temp.ToString()
End Sub
</script>
<html><head>
<title>Builder.com Web Service utilization
example</title>
</head><body>
<form id="frmWSExample" method="post" runat="server">
<asp:TextBox id="txtTemp" style="Z-INDEX: 101; LEFT: 224px;
POSITION: absolute;
 TOP: 64px" runat="server" />
<asp:Label id="lblOutput" style="Z-INDEX: 102; LEFT: 32px;
POSITION: absolute;
 TOP: 64px" runat="server" Width="176px">The current
temperature
is:</asp:Label>
</form></body></html>
Although this listing uses VB.NET, the Web service it calls could easily be in C# or any other .NET-supported language, since you're utilizing the .dll file.
A straightforward process
Consuming a Web service in a .NET application
is a straightforward process. As Web services continue to evolve
and develop, you may find a need for them in your next project.
While I hate to use a technology simply for the sake of using it, this project with Java on one side and .NET on the other provided a situation in which a Web service was the perfect fit.
42 bands from 15 countries to feature at Music Matters Live 2012 which will beam live via YouTube for 1st time this year. #mm12
14 minutes ago by EileenZDNetAsia on twitterMusic Matters to be launched in Bali via partnership w/Telkom Indonesia. #mm12
14 minutes ago by EileenZDNetAsia on twitterHP to shed 27K workers by 2014 http://t.co/OevueOGh http://t.co/erFSwAUB #arcavir
15 minutes ago by V_RaV on twitterhttp://t.co/VNaUVSe1 HP to shed 27K workers by 2014: IT vendor plans exit of 8 percent of gl... http://t.co/5LKpdBSZ http://t.co/wiqTBKkj
15 minutes ago by RavtachSolution on twitterChina solar cell makers seek Taiwan partnershipshttp://bit.ly/JErUGz via @zdnetasia #solar #energy #china
30 minutes ago by newellpr on twitterMalaysia organizations don't realize severity of cyberattacks http://t.co/PUCv68Rd
1 hour 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
1 hour 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...
3 hours ago by camcullen on Experience trumps content in apps monetizationExperience trumps content in apps monetization | ZDNet http://t.co/gBXcjbGd
3 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
4 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
5 hours ago by Bug2Hunt on twitter#security Malaysia organizations don't realize severity of cyberattacks: "Minister Maximus Johnity Ongkili said ... http://t.co/hkFb4zrI
5 hours ago by Wiredsec on twitterMalaysia organizations don't realize severity of cyberattacks http://t.co/EEEmRM3j via @zdnetasia
5 hours ago by RedDragon1949 on twitterMalaysia organizations don't realize severity of cyberattacks - ZDNet Asia News http://t.co/YpNMYgb5
5 hours ago by RedDragon1949 on twitterMalaysia organizations don't realize severity of cyberattacks http://t.co/FFems54Q
6 hours ago by mytech_pro on twitterChina solar cell makers seek Taiwan partnerships http://t.co/p5Hh7kJD
6 hours ago by Export2China 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...
3 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...
6 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.