Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

use of a web service

Posted on 2011-09-09
2
Medium Priority
?
337 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 2000 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 111

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

I made this because I wanted to get e-mail with a attached csv file so I'd would be able to import user input into a MS Excel template, but I also wanted to register/save all inputs from each day in a file on the server. 1st - It creates a temp C…
In order to have all security and back ups taken care of, WordPress users can sign up for services with WP Engine.
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…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …

886 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