Link to home
Start Free TrialLog in
Avatar of Tolgar
Tolgar

asked on

Web Service Examples

Can you please point me to some thorough examples where I can see how web services work?

I just started to work on this area. So basic but very descriptive examples are really appreciated.

If you can give me step by step instructions for a basic example which I can reproduce on my machine , that would be great.

Thanks,
Avatar of Tolgar
Tolgar

ASKER

By the way, I forgot to tell...I am going to use Perl for my implementation due to some internal restrictions.

If the example can be in Perl that would be really good.

Thanks,
Avatar of Tolgar

ASKER

A simple example would be fine.

The wsdl is ready in the format given below:

http://sbcd-00-hg.mywork.com/main/services/Example?wsdl

It uses soap.

Thanks,
Avatar of Tolgar

ASKER

In this wsdl, I need to get the ABCD field from the following part:

<?xml version="1.0" encoding="UTF-8" ?>
<wsdl:definitions targetNamespace= ' ......................................'
SOME CODE
...................
...........
................

- <wsdl:message name="getGeckRequest">
  <wsdl:part name="id" type="xsd:int" /> 
  <wsdl:part name="login" type="soapenc:string" /> 
  </wsdl:message>

SOME CODE
...................
...........
................

 </wsdl:definitions>

Open in new window



I checked it in SOAP UI, and getGeckRequest is the right one to use as I showed above. When I used SOAP UI and run the Request 1 under getGeck, the result has the solution field like that:

<solution>tolgar - SOME NUMBER

SOME TEXT </solution>

Open in new window


What I want to do is; I want to write something into this field using web services in PERL.


How can I make it?

Thanks,
I have only PHP examples.  Here is one.  It is a very simple web service using a RESTful interface.   You give the service a first name, and it returns the last name.  Of course you can extend this kind of design to do much more interesting things than just this, but it illustrates the principles of REST nicely.  You can experiment with it on my server here:
http://www.laprbass.com/RAY_REST_get_last_name.php?key=ABC&name=Ray&resp=XML

In the RESTful design pattern each request is atomic and each response is complete (this is the way the WWW works).  The calling program is not required to maintain stateful information or otherwise be concerned about how the service is preparing its response.  Security, if needed, is as simple as putting the service behind HTTPS.  If it looks amazingly simple, that is because it is amazingly simple.

More information than you will ever need is available here:
http://en.wikipedia.org/wiki/Representational_State_Transfer

Best of luck with your project, ~Ray

<?php // RAY_REST_get_last_name.php
error_reporting(E_ALL);



// DEMONSTRATE HOW A RESTFUL WEB SERVICE WORKS
// INPUT FIRST NAME, OUTPUT LAST NAME
// CALLING EXAMPLE:
// file_get_contents('http://laprbass.com/RAY_REST_get_last_name.php?key=ABC&resp=XML&name=Ray');



// OUR DATA MODEL CONTAINS ALL THE ANSWERS - THIS COULD BE A DATA BASE - AS SIMPLE OR COMPLEX AS NEEDED
$dataModel
= array
( 'Brian'   => 'Portlock'
, 'Ray'     => 'Paseur'
, 'Richard' => 'Quadling'
, 'Dave'    => 'Baldwin'
)
;


// SHOULD RESPONSE BE PLAIN TEXT OR XML FORMAT
$alpha = '';
$omega = '';
if ( (isset($_GET["resp"])) && ($_GET["resp"] == 'XML') )
{
    $alpha = '<response>';
    $omega = '</response>';
}



// TEST THE API KEY
$key = FALSE;
if (isset($_GET["key"])) $key = $_GET["key"];
if ($key !== 'ABC') die($alpha . 'BOGUS API KEY' . $omega);



// LOOK UP THE LAST NAME
$name="?";
if (isset($_GET["name"])) $name = $_GET["name"];

// IF THE URL NAME IS FOUND IN THE DATA MODEL
if (array_key_exists($name, $dataModel))
{
    // RETURNS THE LAST NAME FROM THE DATA MODEL
    die($alpha . "$dataModel[$name]" . $omega);
}

// RETURNS THE UNKNOWN NAME INDICATOR
else die($alpha . 'UNKNOWN' . $omega);

Open in new window

Avatar of Tolgar

ASKER

Thanks for your reply. But I specifically need SOAP application with Perl.

I would really appreciate if you could give me an example with SOAP Web services with Perl.


Thanks,

Artug
SOAP, eh.  Sorry to hear that.  Some of my colleagues believe that SOAP is the devil.  I don't go quite that far, but I can tell you for sure that the internet is littered with failed SOAP applications.  I have never found anyone who could not understand the REST examples.

Suggest you leave this Q open a while longer - perhaps one of the other experts can weigh in with some useful information.  Best of luck with it, ~Ray
Avatar of Tolgar

ASKER

Actually, it is not the matter of understanding REST. But on the server which I am working on, it only support SOAP web services. That's why there is this requirement. On the other hand, it has to be with Perl due to similar system requirements.

Thanks,

ASKER CERTIFIED SOLUTION
Avatar of group0
group0

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial