Title: Dave Elliman
1A Web Service Client
2Web services
- Describe themselves using WSDL
- XML Web Service Description Language
- This means there are tools available to produce
proxies/skeletons/stubs - For .net we have the command wsdl
- For Java (in JEE) there is wsdl2java
3For example
- http//www.xmlme.com/WSShakespeare.asmx
- Add ?wsdl to see the xml definition
- Add ?wsdl to see the xml definition
- We can build a client to access this
- wsdl http//www.xmlme.com/WSShakespeare.asmx?wsdl
- This produced a C file Shakespeare.cs which
contains everything needed to access the web
service - I then created a C console application in VS2005
4Hello World
using System using System.Collections.Generic us
ing System.Text namespace speare class
Program static void Main(string
args) Console.Out.WriteLine(
"Hello World")
5To include the proxy
- I added Shakespeare.cs to the project
- I needed to add a reference System.Web.Services
6I called the proxy methods
using System using System.Collections.Generic us
ing System.Text class Program static
void Main(string args) String
phrase, speech Shakespeare
shakespeare new Shakespeare() for
( ) phrase
Console.ReadLine() if
(phrase.Equals("quit")) break
String result shakespeare.GetSpeech(phrase)
Console.Out.WriteLine(result)
7Reflections on that
- It was very easy!
- It was a synchronous method call (RPC)
- In fact it used xml/SOAP
- It was not especially fast in execution
- The client was arbitrary
- Could have been in a web page (ASP.NET)
- Could have been Windows Forms
- Could have been WPF
- Could have been Silverlight
8Important Lessons
- A Web Service leaves the choice of client open
- Code to connect is easily generated by tools
- Could have used Java tools and JavaFX / Swing as
easily as .Net clients