Showing posts with label Web Services. Show all posts
Showing posts with label Web Services. Show all posts

Saturday, July 4, 2015

Improving performance by keeping payload simple and small

XML Schema Definition (XSD) is a means to represent the input and output parameters for web service operation. This is more popular choice compared to the other models like DTD because it doesn’t need additional parsers.

The size and complexity of the payload have immense impact on the performance. If the payload is huge and complex it would affect the performance as it takes long time to parse the content.

It is often observed that the payload usually has many fields with only a few being populated. Reducing the payload to include only the fields with values would help to reduce the network traffic and increase the processing speed. This can be achieved by explicitly setting the minOccurs value to 0.By default this is set to 1 in XSD.

The following example shows the definition of Meal type schema.

 <xs:element name="mealType">
   <xs:complexType>
     <xs:sequence>
      <xs:element name="category" type="xs:string"/>
       <xs:element name="starter"  minOccurs="0" maxOccurs="1"  type="xs:int"/>
       <xs:element name="mainCourse" minOccurs="1" maxOccurs="3"   type="xs:string"/>
       <xs:element name="dessert" minOccurs="0" maxOccurs="2"   type="xs:string"/>   
 </xs:sequence>
  </xs:complexType>
 </xs:element>

The starter and dessert field are optional and may not be populated for all meal types, hence the minoccurs is set to 0 for these fields.

(i) A sample payload with all fields populated would be as follows:

<mealType>
     <category>Executive Lunch </category>
     <starter>samosa </starter>
    <mainCourse>Rice <mainCourse>
    <mainCourse>Naan <mainCourse>
    <dessert>Ice cream </dessert>
 </mealType>

(ii )A sample payload with only few fields populated would be as follows:

 <mealType>
       <category>Budget Lunch </category>
       <mainCourse>Rice <mainCourse>
 </mealType>


Friday, July 2, 2010

Spring Web Services

Web services is the technology that integrates Web-based applications using the XML, SOAP, WSDL and UDDI open standards over the Internet . XML is used to define the data structure, SOAP is used to transfer the data, WSDL is used for describing the services available and UDDI is used for listing what services are available. Web services allow organizations to communicate data without the knowledge of each other's IT systems behind the firewall.

Web services do not provide the user with a GUI instead the services are shared through a programmatic interface across a network.

Web services allow different applications from different platforms to communicate with each other since all communication is in XML.

A detailed tutorial about implementing Spring Web Service which I found very useful is at
http://webcache.googleusercontent.com/search?q=cache:K3fszlCL9JQJ:www.lulu.com/content/content_download_redirect.php%3FmetaId%3D1090073+maven+dependecies+for+Spring+web+service&cd=2&hl=en&ct=clnk&gl=sg