2023 Exercise 1 A rather more complex server as shown below would connect to a database See | Assignment Collections

Computer Science 2023 a mySQL database

2023 Exercise 1 A rather more complex server as shown below would connect to a database See | Assignment Collections

Exercise 1

A rather more complex server as shown below would connect to a database. See for instance the form priceClient.html, which connects to priceClient.php and in turn to priceServer.php, which then reads from a mySQL database.

These files simulate a stockbroker’s site and by selecting one of the short codes, listed in the file priceClient.html you can get a static price quote.

The structure of the form is:

 

 

Web Services Demo

 

<body text=”#000000″ bgcolor=”#FFFFF0″ link=”#0000EE” vlink=”#551A8B” alink=”#FF0000″>

Share Price Query     

 

 

 

NAME=”queryForm”

ACTION=”stockClientlocal.php”

METHOD=”POST”

onSubmit=”return true”>

 

First Name

 

 

The web service has a selection of nominal share prices of a few companies in the London FTSE 100. These are identified by their shareCode; TSCO, BP, VOD, XTA, PSON.

If you type one of these codes into the query form, it will return the stored share price.

 

 

This simply asks the user to enter a shareCode, which it then sends by ‘POST’ to the client:

 

require_once(‘nusoap.php’); //loads the nusoap library

$client = new nusoap_client(‘http://localhost/priceServer.php’); //creates a new client connected to the server

$shareCode = $_POST[‘shareCode’]; //reads and stores the data send by the form

$sharePrice = $client->call(‘getSharePrice’,

array(‘param’ => ‘$shareCode ‘));

// the above lines call the getSharePrice function in the server using the data passed from the form

// they set a variable to the value of the call

 

echo $sharePrice; //Displays the sharePrice on the screen

echo “Request”;

echo “” . htmlspecialchars($client->request, ENT_QUOTES) . “”;

echo “Response”;

echo “” . htmlspecialchars($client->response, ENT_QUOTES) . “”;

// These last 4 lines display debug data and co-incidentally show the soap envelope

The structure of the server is:

 

function getSharePrice($param) {

mysql_connect(‘localhost’,’laureate_prof2′,’Password – TBA’); //connects to the database system,

//with user name and password

mysql_select_db(‘laureate_prof2’); //selects the specific database to use

$query = “SELECT sharePrice FROM sharePrices WHERE shareCode = ‘$param'”;

//passes SQL query to the database

$result = mysql_query($query); //executes the query and sets a variable to the result

$row = mysql_fetch_assoc($result); // selects the row as an array

return $row[‘sharePrice’]; // returns the value of the asked for parameter

}

require(‘nusoap.php’); //includes the nusoap library

$server = new soap_server(); //instantiates the nusoap server

//The following lines set up the WSDL, which we will discuss next week.

$server->configureWSDL(‘stockserver’, ‘urn:sharePrice’);

$server->register(“getSharePrice”,

array(‘param’ => ‘xsd:string’),

array(‘return’ => ‘xsd:decimal’),

‘urn:sharePrice’,

‘urn:sharePrice#getSharePrice’);

$HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA)

? $HTTP_RAW_POST_DATA : ”;

$server->service($HTTP_RAW_POST_DATA);

?>

Summary

The client form accepts the user data and passes it on to the SOAP client, which creates a SOAP envelope, transmits the data to the server and receives the response.

It is the server which carries the functionality, connects to the database, runs the query and returns the data to the client.

However, this Web service returns a bare price without a company name and not even the short code originally entered.

The task

To improve this service to make the resultant display more user-friendly.

(Maybe add a title or comments to the bare number that is the current output, or perhaps display more information.)

 

Exercise 2

 

The task here is to improve the service still further and add more to the functionality so that the user can alter the price in the database or perhaps add extra company data. The database table was created by:

CREATE TABLE sharePrices (

stock_id int primary key,

shareCode CHAR( 5 ) ,

shareName CHAR( 10 ) ,

sharePrice DECIMAL(10,2) );

The data entered is:

INSERT INTO sharePrices VALUES (1,’TSCO’ , ‘Tesco’, 375.00);

INSERT INTO sharePrices VALUES (2,’BP’,’BP’, 460.00);

INSERT INTO sharePrices VALUES (3, ‘VOD’, ‘Vodafone’, 162.00);

INSERT INTO sharePrices VALUES (4, ‘XTA’, ‘Xstrata’, 1034.00);

INSERT INTO sharePrices VALUES (5, ‘PSON’, ‘Pearson’, 1134.00);

If you try to enter a duplicate stock_id, it will refuse.

Files needed for these exercises are included in attachment.

sharePricesClient.html

stockclientlocal.php

stockserverlocal.php

 

We give our students 100% satisfaction with their assignments, which is one of the most important reasons students prefer us to other helpers. Our professional group and planners have more than ten years of rich experience. The only reason is that we have successfully helped more than 100000 students with their assignments on our inception days. Our expert group has more than 2200 professionals in different topics, and that is not all; we get more than 300 jobs every day more than 90% of the assignment get the conversion for payment.

Place Order Now

#write essay #research paper #blog writing #article writing #academic writer #reflective paper #essay pro #types of essays #write my essay #reflective essay #paper writer #essay writing service #essay writer free #essay helper #write my paper #assignment writer #write my essay for me #write an essay for me #uk essay #thesis writer #dissertation writing services #writing a research paper #academic essay #dissertation help #easy essay #do my essay #paper writing service #buy essay #essay writing help #essay service #dissertation writing #online essay writer #write my paper for me #types of essay writing #essay writing website #write my essay for free #reflective report #type my essay #thesis writing services #write paper for me #research paper writing service #essay paper #professional essay writers #write my essay online #essay help online #write my research paper #dissertation writing help #websites that write papers for you for free #write my essay for me cheap #pay someone to write my paper #pay someone to write my research paper #Essaywriting #Academicwriting #Assignmenthelp #Nursingassignment #Nursinghomework #Psychologyassignment #Physicsassignment #Philosophyassignment #Religionassignment #History #Writing #writingtips #Students #universityassignment #onlinewriting #savvyessaywriters #onlineprowriters #assignmentcollection #excelsiorwriters #writinghub #study #exclusivewritings #myassignmentgeek #expertwriters #art #transcription #grammer #college #highschool #StudentsHelpingStudents #studentshirt #StudentShoe #StudentShoes #studentshoponline #studentshopping #studentshouse #StudentShoutout #studentshowcase2017 #StudentsHub #studentsieuczy #StudentsIn #studentsinberlin #studentsinbusiness #StudentsInDubai #studentsininternational