Solved

Web Service Examples

Posted on 2011-02-28
8
557 Views
Last Modified: 2012-05-11
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,
0
Comment
Question by:Tolgar
  • 5
  • 2
8 Comments
 

Author Comment

by:Tolgar
ID: 35001413
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,
0
 

Author Comment

by:Tolgar
ID: 35002764
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,
0
 

Author Comment

by:Tolgar
ID: 35009395
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,
0
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 
LVL 109

Expert Comment

by:Ray Paseur
ID: 35009436
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

0
 

Author Comment

by:Tolgar
ID: 35010348
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
0
 
LVL 109

Expert Comment

by:Ray Paseur
ID: 35011162
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
0
 

Author Comment

by:Tolgar
ID: 35011197
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,

0
 
LVL 5

Accepted Solution

by:
group0 earned 500 total points
ID: 35012349
Try http://guide.soaplite.com/ for some examples of getting started with SOAP under Perl
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

There are many situations when we need to display the data in sorted order. For example: Student details by name or by rank or by total marks etc. If you are working on data driven based projects then you will use sorting techniques very frequently.…
New Relic recently released its Synthetics product that allows for the creation of performance monitors that periodically test a site's performance. If you wish to test an interactive workflow New Relic employs Selenium WebDriverJS to run those test…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The purpose of this video is to demonstrate how to set up the WordPress backend so that each page automatically generates a Mailchimp signup form in the sidebar. This will be demonstrated using a Windows 8 PC. Tools Used are Photoshop, Awesome…

785 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question