views:

1885

answers:

13
+11  Q: 

Example Web Service

When I wanted to learn SOAP I looked around for tutorials. There are plenty out there, and they all say that they've created an example web service that you can use to test your "My First SOAP Client" app. Unfortunately, all of the sample web services I found have long since gone offline, making the test programs useless.

Can anyone recommend a good SOAP tutorial that uses with a still-working example web service?

EDIT: So far the sports web service mentioned below is the only one that seems to work as advertised and that doesn't come with a tutorial. So while I appreciate the great suggestions, I still consider this question to be unanswered.

A: 

what technology are you planning to build this web service in? C#, Java, other?

lomaxx
+2  A: 

I would suggest instead of trying to digest a "test" webservice that may or may not exist in the future, use a real one!

National Digital Forecast Database (NDFD) Simple Object Access Protocol (SOAP) Web Service

Mark Glorie
A: 

WizzFizz: NDFD looks great for a reliable, will-definitely-stay-up web service, but it doesn't look like it lends itself well to a simple Hello World program for beginners.

Lomaxx: Our company was recently asked to build a client program that would fetch data from a web service. Neither we nor our customer care what language is used. My coworker on this project started learning SOAP and encountered the same problem I did; the lack of good SOAP tutorials with a working, example web service. I'd be grateful for any tutorial with a working, simple web service that's still online.

Eli Courtwright
+1  A: 

I've used the dataaccess football web service for testing and learning how to access SOAP. SOAP tutorials are quite thin on the ground & it really does matter what development environment / language you use. i.e. Any tutorial will be heavily skewed towards a specific library or language.

seanyboy
+2  A: 

A simple "hello world" one would be the dictionary services set up by Aonaware - http://services.aonaware.com/. They allow you to look up a dictionary definition of any english word.

brendan
A: 

@brendan: The aonaware web service looks really nice, but I don't think it works as advertised. It works when you submit something to them through their web form, but not when you try to send SOAP requests. For example, try connecting to their server over telnet or netcat and sending one of the SOAP requests listed at http://services.aonaware.com/DictService/DictService.asmx/Define?word=string

@WizzFizz: I took a closer look at the NDFD pages and they have their own problems. For example, the page you linked to has a nice link that says "You can see an example of this process in action by visiting the following URL" and when you click on the link it takes you to a page with a form (http://www.weather.gov/forecasts/xml/sample_products/meteogram/DWML_graph.htm) and submitting that form spits out an error.

So far the dataaccess sports web service is the only one that seems to work as advertised and that doesn't come with a tutorial.

Eli Courtwright
+2  A: 

@Eli The aonaware web service works fine - it's just very picky about headers. Unless you set everything right, including Content-Length it just returns an error. Because of the Content-Length stuff it's hard to test this service with telnet

Below is a sample web service request with curl, a command line HTTP client.

cristi:~ diciu$ cat request.txt

<?xml version="1.0" encoding="UTF-8"?>
  <SOAP-ENV:Envelope
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
    SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
    xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"&gt;
      <SOAP-ENV:Body>
        <ServerInfo xmlns="http://services.aonaware.com/webservices/"&gt;
        </ServerInfo>
      </SOAP-ENV:Body>
    </SOAP-ENV:Envelope>

The actual request:


cristi:~ diciu$ curl --header "Content-Type: text/xml" --header "Soapaction: http://services.aonaware.com/webservices/ServerInfo" -d @request.txt http://services.aonaware.com/DictService/DictService.asmx | head
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  5633  100  5633    0     0   1160      0  0:00:04  0:00:04 --:--:--  1526
DictService web service version 2.1.3094.35914

Remote Server information:
dictd 1.9.15/rf on Linux 2.6.18-6-k7
On aspen.miranda.org: up 197+06:05:23, 32485487 forks (6862.0/hour)

Database      Headwords         Index          Data  Uncompressed
gcide          203645       3859 kB         12 MB         38 MB
wn             154563       3089 kB       8744 kB         26 MB
moby-thes       30263        528 kB         10 MB         28 MB

diciu
+2  A: 

@Eli - the thing is you don't need / want to learn SOAP. Web services are described via WSDL and the process is similar to how IDL (Corba) works.

Someone defines an interface within a WSDL file. Once the interface is agreed upon, software tools (generically called WSDL To Java) are used to generate code stubs for the service. This means that all the SOAP and HTTP stuff are abstracted away and already implemented for you by the web service implementation.

All you need to do is implement a client, using the client stubs, or a server, using the server stubs. The client and the server need not share implementation language, platforms or what not since the interface is standardized via the WSDL.

See Apache Axis if you're into Java - they have tutorials on web services and if you can run a tomcat server of your own where you can run your own service (AXIS is implemented as a tomcat web application).

This is a workable tested client for a web service:

import localhost.axis.EchoHeaders_jws.*; //note the import for the client stubs

public class Client {
    public static void main( String[] arguments) throws Exception 
    {
        EchoHeadersServiceLocator finderi = new EchoHeadersServiceLocator(); 
        EchoHeaders e = finderi.getEchoHeaders( 
            new java.net.URL("http://localhost:8080/axis/EchoHeaders.jws"));
        System.out.println( e.echo("All work and no play..." ));  // print the result of the echo call from the server side
    }
}
diciu
+4  A: 

Also, the National Weather Service provides weather forecast data and other data via a web service. They also have a bit more elaborate tutorials on how to get started using the service. This might be more what you're looking for.

http://www.weather.gov/forecasts/xml/

brendan
A: 

@diciu: Thanks for the nice example. The problem with using SOAP without learning it is that you'll eventually run into problems when something goes wrong. For example, if we try connecting to a C# SOAP server with a Java client and find that Microsoft is somehow breaking the standard, we want to figure out how our messages need to be formatted for successful queries (this actually happened). So I want a service where I can start by seeing how the HTTP requests and responses look and do them manually, then work my way up to using a programming language. This is probably the opposite of what most people want, but I feel it's the best way to approach HTTP services.

Eli Courtwright
+1  A: 

I learned creating and consuming webservices with nuSOAP, a PHP webservices framework and later I used wsdl.exe in the .Net framework to generate proxy classes to consume my own webservices.

Scott Nichol, the maintaner of nuSOAP, provides some good samples on using it. wsdl.exe is quite self-describing.

It is quite tough to write your WSDL and SOAP calls by hand. There are many tools for nearly every language to help you there. If a service provides a WSDL file, you can skip most of the programming. I already ran in some problems with Microsoft's SOAP toolkit for VBA, but I could get over it because I am writing the services myself.

As seanyboy already said, it is hard to suggest you a tutorial if you don't provide some languages which you know, because nearly all of them rely on one framework or another.

wieczo
+1  A: 

As for looking at the actual SOAP messages being transferred for learning or debugging purpose, many IDEs come with web-services plugin.

For example, Eclipse Web Services Explorer, let you start from a URL of a wsdl file. It then lets you create a request using a dynamically generated form. After filling in the form you can view and manually edit the generated SOAP request. You can then send out the request and see the raw http request and response.

Combine this facility with examples bundled with AXIS 2 and you have a very powerful method of learning SOAP write on your machine. As many people pointed out earlier you can run an instance of tomcat on your own machine with AXIS 2 examples. Feed the localhost URL into the Eclipse Web Services Explorer and enjoy.

I also noticed nice web-service support in Net Beans (6.1). It even comes with several public web-services pre-configured. Netbeans also have an http monitor utility for viewing raw http request and responses as they happen.

Tahir Akhtar
+2  A: 

A public registry listing Web Service can be found at http://www.service-repository.com/

baranco