Solved

use of a web service

Posted on 2011-09-09
2
328 Views
Last Modified: 2012-05-12
Hello.
This is the first time I use web service.
I created a simple web service (the project is java web application) on my computer.
now, another application need to use it. this application is on another computer (B) on the network.
I want to place the web service I created in a computer (A) on the network as well.  (both computer ar in the same network)
What files do I need to copy to computer A ?
How the app from computer B communicate with the web service on computer A? What info do I need to supply?
Is there any security issues I need to worry about ? How can I set a username+password to the web service ?

Thank you
0
Comment
Question by:egrolpe
2 Comments
 
LVL 23

Accepted Solution

by:
Siva Prasanna Kumar earned 500 total points
ID: 36515875
The webservice you developed how did you test it?

You might have got a WSDL URL like http://localhost:8080/xyzservice?wsdl

change the localhost to the actual IP and give you to you consumer on computer B if he can access the WSDL url from a normal web browser he can access service to the most part.

If the data is not very confidential & sharing is just b/w the same network then no need of any additional security as it will be a overhead in achieving that.

0
 
LVL 108

Expert Comment

by:Ray Paseur
ID: 36516307
I can show you how this is done with a very simple teaching example, written in PHP.  This uses RESTful design, which in my opinion is much easier to get right than SOAP.  The world-wide-web is a RESTful design.  More on REST here.
http://en.wikipedia.org/wiki/Representational_state_transfer
http://www.ibm.com/developerworks/webservices/library/ws-restful/

The script below is located at on my server at this URL.  Try a couple of these to see how it works.
http://www.laprbass.com/RAY_REST_get_last_name.php?key=ABC&name=Ray
http://www.laprbass.com/RAY_REST_get_last_name.php?key=ABC&name=egrolpe
http://www.laprbass.com/RAY_REST_get_last_name.php?key=FOO&name=Ray

So to sum up, in the REST design, each request is atomic and complete, providing the parameters as GET arguments in the URL.  And each response is complete and usually instantaneous, written in clear text to the browser output stream.  It is a stateless protocol.  Neither party needs to know how the other makes the request or response.  The requesting client needs only to know what format the server will use for the response.  That is usually documented in the API documentation.  An example of the API documentation for one of my web services is here.
http://www.carpool2camp.org/v2api/apidocs.php

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 FAMILY 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'
)
;


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



// TEST THE 'API KEY' - THIS COULD BE A DATA BASE VALIDATION LOOKUP - AS SIMPLE OR COMPLEX AS NEEDED
$key = (!empty($_GET["key"])) ? $_GET["key"] : FALSE;
if ($key !== 'ABC')
{
    echo $alpha . 'BOGUS API KEY' . $omega;
    die();
}



// LOOK UP THE FAMILY NAME
$name = (!empty($_GET["name"])) ? $_GET["name"] : FALSE;

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

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

Open in new window

0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

To properly understand GitHub, let’s divide it into two words ‘Git’ and ‘Hub’. Git is basically a ‘Distribution Version Control’ (DVC) and ‘Source Code Management’ (SCM) system widely used by software programmers while Hub means the efficient centre…
In this article you will learn how to create a free basic website on Bitbucket, a git service provider. Polymer creates dynamic HTML components, which allow more flexibility than static HTML. This tutorial uses Ubuntu Linux but can also be done on W…
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…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

757 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now