Solved

Web Services Newbie

Posted on 2011-02-22
3
384 Views
Last Modified: 2012-05-11
I have a VS 2008 app with a SQL Server 2008 database that I want to communicate with a customer's legacy system.  To simplify my question, let's say it's an inventory application.
My system handles receipts, issues and inventories.  I update my inventory and transaction tables according to the type of transaction.  For example, if it's a receipt, I increment my inventory level (or create a new record if the item is not already in inventory) and I add a record to the transaction table.
My question is:  Would it be better to have specific web services for all transaction types (receipt, issue and inventory) where I only pass the data fields needed or would the web services simply handle inserts, deletions and updates and I would pass my entire dataset and let the web service determine how to handle each transaction.
0
Comment
Question by:PSCTECH
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 110

Accepted Solution

by:
Ray Paseur earned 500 total points
ID: 34960039
Either way would work.  If it were up to me I would create a RESTful web service and send it commands in the URL GET request (for data retrieval only) or via POST for those commands that modify the data model.  A REST service can be as simple or as complex as you want to make it.  Good examples include the Google V3 API that draws maps, of at the simple end of things, this little script that takes a first name as input and returns the last name as output.  To see it in action, visit
http://laprbass.com/RAY_REST_get_last_name.php?key=ABC&resp=XML&name=Ray

You can try experimenting with different arguments to see what it does.  If you want to learn more about REST, look up the Wikipedia article.
http://en.wikipedia.org/wiki/Representational_State_Transfer

If that seems like a daunting amount of information, here are the important points.  REST is the protocol that underlies client-server networks.  Clients initiate requests and servers respond.  Each request is atomic.  Each response is complete.  The client has no need to know what the server is doing or how the server is doing it.  This elegant and simple separation of responsibilities makes it amazingly easy to develop client-server web services.

The contrast is the awkward and complicated thing called SOAP, and I advise you to stay away from that.  The web is littered with failed SOAP projects.  I have never met anyone who could not get a REST service running correctly.

Best of luck with it, ~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 Closing Comment

by:PSCTECH
ID: 34961311
Great answer, quick response, very helpful.  Thank you
0
 
LVL 110

Expert Comment

by:Ray Paseur
ID: 34962331
Thanks for the points!  Best of luck with your project, ~Ray
0

Featured Post

Report: Liquid Web beats Amazon, Rackspace & More

A study by performance analyst firm Cloud Spectator finds that Liquid Web beats rivals Amazon, Rackspace and DigitalOcean when it comes to website and cloud application performance.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SQL Server Results to Excel File 18 89
MS SQL Conditional WHERE clause 3 49
Usage Scenarios for Extended Events - Tracking Recompilations 1 50
Need to replicate a Log table 4 41
How to leverage one TLS certificate to encrypt Microsoft SQL traffic and Remote Desktop Services, versus creating multiple tickets for the same server.
In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
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…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

738 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