Jump to content

Web Services Tutorial


davej

Recommended Posts

I think someone should consider re-writing the web services tutorial example. What is needed is an example that accesses some data that is elsewhere on the web or on the server. The current example is just a simple calculation that javascript or even pencil and paper could provide. I am just getting into this topic and certainly am not looking for something that I could do in JS. I want to exchange data with the server. http://www.w3schools.com/webservices/default.asp

  • Like 1
Link to comment
Share on other sites

What is needed is an example that accesses some data that is elsewhere on the web or on the server.
That's not really the scope of that example, the code in those functions isn't what they are trying to illustrate. You can add whatever functions you want to a web service and make them do anything you need them to, but that isn't part of the web services example. The example only shows how to set up a web service in ASP.net, and then one way to use the web service and call the functions. If you want to learn how to access data from a database or from the internet then there are other tutorials that teach things like that.
Link to comment
Share on other sites

Well, to me a good example demonstrates the usefulness of something. Isn't there any easy way for it to provide at least a tidbit of data from the server?

Link to comment
Share on other sites

Of course there is, those examples are found in the sections on how to use databases, or the filesystem, etc. Instead of having a function return the result of a calculation it could return data from a database or file or whatever else. I don't know if there's a reason to add that information to the web services examples, they probably don't want to confuse people trying to learn about web services who don't know how to use a database or whatever else.

Link to comment
Share on other sites

It's probably also worth pointing out that since that tutorial uses ASP.net as the example...
Well, I am confused by web services... 1. The primary example is a bit of VBScript code. I thought VBScript only ran in IE, but it says; "VBScript is the default scripting language in ASP." That includes ASP.NET? The VBScript tutorial does not mention server-side usage. 2. Isn't the whole idea of a WSDL/UDDI registry a little half-baked? I mean I can imagine a particular company or government agency providing a set of web services, but the only thing needed is a webpage with a plain text description of exactly how to access and use each service. The example page here; http://www.w3schools.com/webservices/tempconvert.asmx seems to display some boilerplate code for users -- but shouldn't it be showing boilerplate code demonstrating how to access the web services? It looks like code to implement a web service. 3. Then there is the issue of web services being based on XML. Does that make sense? How would XML make sense for a typical database web service where inventory or employee records are accessed? I can easily imagine that a web service could be expected to handle MSWord, PDF, Excel, JPG, AVI and other document types, or POST data. Is a web service only a true "Web Service" if it is limited to XML? 4. What is the difference between a "Web Service" and a web page? I can send data to a web page and get data from a web page, and I can automate this operation. Does that make it a "fake" web service? Thanks! Edited by davej
Link to comment
Share on other sites

1. They do say that it can be used (as in "created" and "consumed") by different languages. From the intro page:

XML provides a language which can be used between different platforms and programming languages and still express complex messages and functions.
2. There are tools that can generate a reference documentation out of WSDL files. And providing exact code samples is not exactly possible, since different languages would use different approaches. A web service documentation needs to assume the user is familiar with some form of accessing the web service in their language, and go from there with the web service terminology (port types, operations) as opposed to a language specific terminology (classes, methods; objects, functions; namespaces, procedures).3. XML gives the flexibility you need from a generic protocol, combined with the ability to place constraints on it (using WSDL and XML Schema). That is why it is the proffered method.4. "Web Service" is an umbrella term for all languages and specifications involved in the process - HTTP, XML, SOAP, WSDL and XML Schema. A web page is simply one thing that can travel over HTTP. But since in both "web service" and just plain web pages, the under layer is HTTP, yes, one could say a web page is a kind of web service. That's what the so called REST web services really are - using plain HTTP calls that accept certain inputs in the HTTP request (documented separately in a human readable fashion), directly delivering a specifically formatted (documented separately in a human readable fashion) HTTP response.
Link to comment
Share on other sites

The primary example is a bit of VBScript code. I thought VBScript only ran in IE, but it says; "VBScript is the default scripting language in ASP." That includes ASP.NET? The VBScript tutorial does not mention server-side usage.
The code is actually ASP.net code, written using VBScript. ASP.net isn't a language itself, it's a framework that you use another language (in this case VBScript) to interact with. VBScript can also be used as a client-side scripting language in IE. ASP and ASP.net are both server-side technologies. The web services example is a piece of code running on the server that browsers can ask the server to run (in this case, to convert the temperature).
Isn't the whole idea of a WSDL/UDDI registry a little half-baked? I mean I can imagine a particular company or government agency providing a set of web services, but the only thing needed is a webpage with a plain text description of exactly how to access and use each service.
That's basically what it is, the important part of the page you linked to is the reference on top listing the 2 functions that the web services supports. The rest of the text on that page are notes about how to change the namespace since the current default namespace for the web service is an example namespace. On a live system you would use a namespace that uniquely identifies you so you wouldn't see those extra notes, just the function reference.
Then there is the issue of web services being based on XML. Does that make sense? How would XML make sense for a typical database web service where inventory or employee records are accessed?
The XML is just a description of what the web service does, like a manual. It will list all of the functions and all of the parameters that each function uses, and what kind of result the function returns. It's basically a specification that describes the technical capabilities of the web service, it's not the actual code for the functions.
What is the difference between a "Web Service" and a web page? I can send data to a web page and get data from a web page, and I can automate this operation. Does that make it a "fake" web service?
Mostly formalities, like the presence of the WSDL. Web services are expected to conform to certain requirements which make them all basically the same to use. You could build a web service client for example that would be able to download the WSDL and give you an interface to the web service's functions even though you didn't write the client specifically for that web service.
Link to comment
Share on other sites

Ok, on the topic of VBScript. I have written a little ASP.NET code and know that you can use VB or C# for the scriptlets. I am pretty sure that ASP.NET uses VB while ASP uses VBScript. There are some differences as mentioned here... http://msdn.microsoft.com/en-us/library/ms973813.aspx where it says... "Unfortunately, porting existing ASP pages to ASP.NET pages is almost never as easy ..because... there are significant differences between Microsoft Visual Basic Scripting Edition (VBScript) and Visual Basic .NET."

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...