• Increase font size
  • Default font size
  • Decrease font size

short introduction into webservices

If you want to study webservices, you should have a basic understanding of the following:

- HTML
- XML

According to http://www.w3schools.com web services are:

- Web services are application components
- Web services communicate using open protocols
- Web services are self-contained and self-describing
- Web services can be discovered using UDDI
- Web services can be used by other applications
- XML is the basis for Web services

However, this fact may be confusing when read by newbie. Let's look closer on this topic:

Imagine this situations, you have a functionality based on PHP eg. eshop. Then you got an offer to extend your eshop by products from a regular shop using oracle database and c++ application. How could you include items stored in Oracle DB into your eshop. Certainly there are several possibilities, and one of them is a web service. There could be created a oracle procedure or set of procedures that would serve like access point into oracle database for searching. Once we have such procedure web services technology takes place. Web services take care of communication between eshop created in PHP and oracle procedure. Oracle procedure is a basic element of our new web service. We have to describe all possibilities it has otherwise eshop (lets call it client) doesnt now how to communicate. Description of webservice is made as WSDL file and is made in WSDL language.

WSDL language is based on XML. It describes:

- which actions service offers - imagine we have web services 'database access' and services are insert, update, delete, ...
- what are arguments action accepts and returns. Arguments may also be complex types (structured).
- where exactly is the service placed (URL)
- protocol used for communication - mostly SOAP

Generaly, when you have WSDL file, you know everything to be able to build a client and communicate with the service.

When you theretically know how to communicate (based on WSDL file) you may continute to practical part - building and sending messages.

SOAP is the most used alternative - a simple XML-based protocol to let applications exchange information over HTTP.

It is an envolepe carrying data.

Generaly we may say:

HTTP + XML = SOAP

Example of a SOAP request [http://www.w3schools.com/soap/soap_example.asp]:

POST /InStock HTTP/1.1
Host: www.example.org
Content-Type: application/soap+xml; charset=utf-8
Content-Length: nnn
<?xml version="1.0"?>
<soap:Envelope
xmlns:soap="http://www.w3.org/2001/12/soap-envelope"
soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding">
<soap:Body xmlns:m="http://www.example.org/stock">
<m:GetStockPrice>
<m:StockName>IBM</m:StockName>
</m:GetStockPrice>
</soap:Body>
</soap:Envelope>

And that's it.

Know we can

- create a request in appropriate XML format based on rules in WSDL file

- send request enveloped by SOAP protocol to webservice located at URL defined in WSDL file by HTTP POST/GET

- then read a reasponse from web service again in XML format

Here is an example of PHP web service client that is created based on WSDL:

 

<!--?php<br--> 
 $client = new SoapClient('http://ws.cdyne.com/emailverify/Emailvernotestemail.asmx?wsdl',array( 
 "trace"      => 1, 
 "exceptions" => 0));
 var_dump($client->__getFunctions());        //show functions/actions the service offers
 
 //create array of params that will be send to a webservice
 $params   = array(
 'email' => 'rasto.hornak[at]gmail.com',
 'LicenseKey' => '1',
 );
 
 //view params
 print_r($params);
 
 try { 
 $client->VerifyEmail($params);        //calling procedur on web service
 print "

Request :\n".htmlspecialchars($client->__getLastRequest()); 
 print "

Response:\n".htmlspecialchars($client->__getLastResponse()); 
 } 
 catch (SoapFault $exception) { 
 echo $exception;       
 } 
 ?>

 

 

Comments  

 
0 #1 George Michael 2016-12-27 21:29
baru raffi 38 gigi: http://tinyurl.com/htw9ht2
berita terkini Nadya Hutagalung: http://tinyurl.com/hunqcj8
http://tinyurl.com/jr27lz9 dumais
http://tinyurl.com/zak7bpc Behind The Scene Bollywood hari ini
Bangtan Boys hari ini: http://tinyurl.com/zjum455
http://tinyurl.com/glpa9ly bocor di internet benarkah
Quote
 

Add comment

No bad words.


Security code
Refresh


New articles

Differential Equations - Simple spring model Machine Learning and Robotics
Read More 1696 Hits
Kalman Filter implementation Machine Learning and Robotics
Read More 2476 Hits
Inverse kinematics Machine Learning and Robotics
Read More 3026 Hits
gpsim tutorial Machine Learning and Robotics
Read More 6092 Hits

New articles

Differential Equations - Simple spring model Machine Learning and Robotics
Read More 1696 Hits
Kalman Filter implementation Machine Learning and Robotics
Read More 2476 Hits
Inverse kinematics Machine Learning and Robotics
Read More 3026 Hits
gpsim tutorial Machine Learning and Robotics
Read More 6092 Hits
Design by i-cons.ch / etosha-namibia.ch