Linux - interior version



HAL - HW abstraction layer.Regardless of brand names it linux uses its own naming system for similar hardawre. HAL database is stored in /sys dir
 Ex: If you plug 3 diff Ethernet cards it will be eth0, eth1 and eth2. Thats it

dbus -  via dbus hw can communicate between applications and HAL

lsusb - lists all the usbs plugged in

lspci - lists all the pci cards plugged in

lsmod - lists all kernel modules

/proc - a virtual dir created in the RAM. But can be seen in the real dir structure. Only root can manipulate. Temporary configs can be made in here until reboot.

Booting up via run levels

Boot loader - Earlier linux used LILO. But now it is using GRUB
Boot loading menu entries 
UUID => partition where OS is
Kernel => where the kernel is 
quiet splash - dont verbose and show a logo
initrd =>initial ram disk. load essesntial modules from kernel into RAM when booting


init - first process when kernel is booted up. The master process of all processes.

pstree - shows all the processes available

/boot - kernel is stored in here. GRUB also stays here


Run levels 

0 - halt
1 - single user mode/ recovery mode
2 - default level for Debian OSs - GUI mode
3 - default level for Redhat OSs - text mode
4 - Available. But not used normally
5 - Redhat GUI mode
6 - Reboot. go to run level 0

/ect/inittab - run level details are here. can configure run levels and default level here.

 /etc/rcX.d - [X can be 0 to 5] shows sun level process starts and kills

Share:

OData based web services (Open Data)

Odata is a combination of  SOAP and REST. Therefore request messages are in a format of URIs and parameters. Response messages can be either ATOM or JSON.

OData was initially created by Microsoft and later it was delivered to the open source community.

Current version of OData specification is v4.0. Specification can be obtained from here.
http://www.odata.org/documentation/





OData communication components

  • Data model - message format standard (data types)
  • Request format and transport protocol - Specific URI specification
  • Client & Server libraries -   Data transformation between native data and xml/json data
Request messaging

Same as REST but slightly different.


http://services.odata.org/OData/OData.svc/Category(1)/Products?$top=2&$orderby=name
Service root                                                          Resource path                 Query options

Query options has $ prefix and each option has a specific function (like orderBy)





Share:

RESTful web services


REST (Representational State Transfer) is a web services architecture. If we take SOAP , it is specification for messages used in WS. But REST is a complete architecture of web services which has all the details how it is done in web service invocation.

W3 rest wiki is a one good place for REST specification.

REST can be used with any protocol (HTTP, FTP, SMTP)

Request messages

Requests are made using URIs and parameters. (In SOAP request are made using XML envelops)
So the request data is less in size compared to SOAP. (Comparing with all the meta data)

protocol :// [HOST] / [Resource root] / [Parameters - optional]
https://www.youtube.com/results?search_query=gangamstyle

Requests can be made with HTTP verbs
  • GET (Read data from WS)
  • HEAD (Return just the meta data of WS)
  • POST (Insert data to WS)
  • PUT (Update data in WS)
  • DELETE (Delete data in WS)
To what verbs to respond is implemented in the WS. (ex: Some WS can be read only)

Although this is the request mechanism how you create the request depends on the progrmming language you use.
Ex: To create requests we can use Apache HTTPClient library, Volley library for Android, OKHttp library for Android, XMLHTTPRequest object for JavaScript etc...

Response messages


Return messages can be in any format. REST can return non text/binary data as well.
  • POX (plain old xml)
  • ATOM
  • RSS
  • JSON (especially in mobile applications)
















Share:

Web Service Description Language (WSDL)


WSDL which is xml based contains the information about the web service. Typically WSDL is generated by the server in which the service is held at. After generation of WSDL it can read by SOAP library at client side.

Official WSDL specification can be found in here.
http://www.w3.org/TR/wsdl

Sample WSDL document

<definitions name="HelloService"
   targetNamespace="http://www.examples.com/wsdl/HelloService.wsdl"
   xmlns="http://schemas.xmlsoap.org/wsdl/"
   xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
   xmlns:tns="http://www.examples.com/wsdl/HelloService.wsdl"
   xmlns:xsd="http://www.w3.org/2001/XMLSchema">
 
   <message name="SayHelloRequest">
      <part name="firstName" type="xsd:string"/>
   </message>
 
   <message name="SayHelloResponse">
      <part name="greeting" type="xsd:string"/>
   </message>

   <portType name="Hello_PortType">
      <operation name="sayHello">
         <input message="tns:SayHelloRequest"/>
         <output message="tns:SayHelloResponse"/>
      </operation>
   </portType>

   <binding name="Hello_Binding" type="tns:Hello_PortType">
      <soap:binding style="rpc"
         transport="http://schemas.xmlsoap.org/soap/http"/>
      <operation name="sayHello">
         <soap:operation soapAction="sayHello"/>
         <input>
            <soap:body
               encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
               namespace="urn:examples:helloservice"
               use="encoded"/>
         </input>
  
         <output>
            <soap:body
               encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
               namespace="urn:examples:helloservice"
               use="encoded"/>
         </output>
      </operation>
   </binding>

   <service name="Hello_Service">
      <documentation>WSDL File for HelloService</documentation>
      <port binding="tns:Hello_Binding" name="Hello_Port">
         <soap:address
            location="http://www.examples.com/SayHello/" />
      </port>
   </service>
</definitions>
Code obtained from : http://www.tutorialspoint.com/wsdl/wsdl_example.htm


Understanding the elements of  WSDL

targetNamespace="http://www.examples.com/wsdl/HelloService.wsdl"
==> target name space means the name space associated with this WSDL document


<documentation>WSDL File for HelloService</documentation>
===> Documentation for this web service (optional)


<message name="SayHelloRequest">
      <part name="firstName" type="xsd:string"/>
   </message>
 
   <message name="SayHelloResponse">
      <part name="greeting" type="xsd:string"/>
   </message>
===> input and output parts of the service (input msg= SayHelloRequest , output msg=SayHelloRespnse)


<portType name="Hello_PortType">
      <operation name="sayHello">
         <input message="tns:SayHelloRequest"/>
         <output message="tns:SayHelloResponse"/>
      </operation>
   </portType>
===> all the operations are defined here. Currently there is one operation, sayHello and it has one input msg and one output msg described earlier.


<soap:address
            location="http://www.examples.com/SayHello/" />
==> specifies where the service is located at. We can call the web service from this location.

Share:

SOAP message format

Schema for the SOAP 1.1 message can be found in here.
This says all about the SOAP message format.

Example SOAP message


<?xml version="1.0"?>
<soap:Envelopexmlns: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>

Code obtained from W3Schools.com


Identification of the elements in SOAP message


xmlns:soap="http://www.w3.org/2001/12/soap-envelope"
===> XML name space, soap is referenced at a schema whihc is at the given URI

soap:Envelope
===> Envelop is the root element at any SOAP xml message

soap:Body 
===>  Body is where the content of the message is held

xmlns:m="http://www.example.org/stock
===> Another xml namespce , m is declared. The scheme is at the given URI

<m:GetStockPrice>
    <m:StockName>IBM</m:StockName>
  </m:GetStockPrice>

===> This is the actual message. (ex: stock name is IBM)


















https://upload.wikimedia.org/wikipedia/commons/thumb/5/59/SOAP.svg/220px-SOAP.svg.png


SOAP message elements

  • Envelope - Must be there
  • Header - optional (Meta data. Documentation, time stamps etc)
  • Body - Must be there 
  • Fault - optional (child element of Body. can contains error messages and error codes, error details)

SOAP data types

All the specifications for SOAP data types can be found in here in details.
http://www.w3.org/TR/xmlschema-2/#built-in-primitive-datatypes
http://www.w3.org/TR/2000/NOTE-SOAP-20000508/#_Toc478383514

primitive data types used in SOAP

  • string
  • boolean
  • decimal
  • float
  • double
  • duration
  • dateTime
  • time
  • date
  • gYearMonth
  • gYear
  • gMonthDay
  • gDay
  • gMonth
  • hexBinary
  • base64Binary
  • anyURI
  • QName
  • NOTATION
When we use a SOAP library (at client side or server side) it can match with the data used in applications and SOAP primitive data types. These  data types should be defined in WSDL when used with a service.

SOAP supports complex data types too. Complex datatypes structure should be defined in WSDL.
Share:

SOAP based web services


One major category of web services is SOAP based web services. (Simple Object Access Protocol)

SOAP is a message format specification. (Which is also XML based)

SOAP WS can process over HTTP, FTP,SMTP etc.. (But HTTP is being the popular protocol)

SOAP has 2 major versions. See specs at http://www.w3.org/TR/soap/
  1. SOAP 1.1
  2. SOAP 1.2 (released in 2007 and W3 recommended)


Image obtained at: https://www.simple-talk.com/iwritefor/articlefiles/166-proxies.gif

For serialization/ deserialization of messages we need to have 2 SOAP libraries.

  • One at client side (SOAP client library)
  • One at server side (SOAP server library) 
These SOAP library implementations are available for popular programming languages and OSs. But the SOAP library you are using should comply with your OS and programming language. So the serialization process is handled by the libraries not by the programmer.

In SOAP based WS, messages are XML based (They are called SOAP envelopes)

All the details about the WS are contained in XML message called WSDL (Web Service Description Language). If you have the WSDL you know how to call the web service.

SOAP advantages 

  • Many platform and programming languages support SOAP
  • Developers dont have create/read WS messages directly (SOAP libraries can do that)
  • When used with HTTP can work with existing internet resources   

SOAP disadvantages 

  • Serialization process takes some time(depends on SOAP library quality)
native data => xml data and xml data => native data conversion

  • SOAP messages (envelope) sizes are big
Share:

Message formats used in web services

In web services what happens in client request a service from a server over the web. So various data (messages ) can be exchanged in requester and responder. They can be in various formats in WS.

Open Formats

  • RSS (XML based format used in web feeds)
  • ATOM (XML based format used in web feeds)
  • POX (Plain Old XML - raw xml format)
  • JSON (Java Script Object Notation - light weigh - especially used in mobile applications)
  • HTML

Proprietary Formats

There can be various proprietary messaging formats for vendor specific applications.
  • AMF (Action Message Format by Adobe)



Share:

Web services and Transport layer protocols


















Image obtained from : http://www.highteck.net/images/45-Transport-layer.jpg

Because web services operate over internet the role of TCP/IP stack is aslo essential. In TCP/IP layers Transport layer protocols can play a huge role because it helps to move data between machines over internet.   

WS over Non-HTTP Protocols 

These include protocols like FTP, SMTP, POP like protocols.
WS can operate over these as well.
These are asynchronous (meaning request response doesn't happen immediately ) 

WS over HTTP 

This is the most WS protocol.
HTTP is text based.
HTTP is synchronous (meaning request reply can happen immediately)

HTTP request happens via verbs (GET, POST, PUT, DELETE, HEAD .........)

But not all the web services respond to HTTP verbs.

HTTP syntax
protocol :// [HOST] / [Resource root] / [Parameters - optional]
https://www.youtube.com/results?search_query=gangamstyle 

Response data over HTTP can be any format we request.

Ex if we request to send repnose data in XML data format, we can add request header 
ACCEPT : application/xml

Share:

Brief understanding of web services

Normally when you want to communicate with another computer from our computer we can use a computer network.

Web services are just like that.
We have a client who request a service x.
A server who has the service x implemented in its server.
We can request for the service x over internet.
Image obtained from : http://pdn.pelco.com/sites/default/files/original/4274web_service_diag.jpg














According to Web Service Architecture Working Group (WSAWG) web service is defined technically as follows.

Web service has an interface described in a machine-processable format (specifically WSDL). Other systems interact with the Web service in a manner prescribed by its description using SOAP (Simple Object Access Protocol) messages, typically conveyed using HTTP with an XML serialization in conjunction with other Web-related standards.
http://dev.w3.org/2002/ws/arch/wsa/wd-wsa-arch-review2.html#whatis


Typically we can just call a remote web service. We have to go through its API(Application Programming Interface) to access it.
(ex: If we build a mobile device and we want to get some data to our app from Facebook server we have to go through Facebook API first)


API components

  • Request message format (can be SOAP, XML or JSON or any other format)
  • Response message format (can be SOAP, XML or JSON or any other format)
  • Service request syntax (call as a named method / Call as URIs and Parameters)
  • Requested action (What is being requested from the server)
  • Authentication ( Authenticity of the connection between client and server, login exchange or token exchange)

Machine- Machine communication mechanism (from history to now)

  • Electroic Data Exchange (EDI , machine-machine communication method)
  • Remote Procedure Calls (RPC)
  • Microsodt RPC (based on RPC and COM - Common Object Model)
  • Common Object Request Broker Architecture (CORBA)
  • Java Remote Method Invocation (Java RMI)
  • XML-RPC (XML based RPC)
  • ATOM based WS (Atom is based on XML)
  • RSS based WS (RSS is also based XML)
  • Simple Object Access Protocol (SOAP. Also known as WS*-Web services everything. One of the popular one)
  • JSON based WS




Share: