05 - Best Practices and Common Issues in JAX WS

5.1  Best Practices in the Design of Web Service:

While designing new web services the following features can be considered for better performance.

1. Contract Definition:
Identify related information needed across multiple requirements and group them as individual web services. Aggregate the individual services to deliver the whole requirement

2. Loose coupling:
Loose coupling means to avoid dependency between the systems. The web service itself is considered to have loose coupling between service provider and consumer. To implement a loosely coupled system we should avoid hardcoding the URL of the service provider

3. Development Approach:
 Top down and meet in the middle are better approaches than bottom up approach. Bottom up approach is used when converting the existing Java code as a web service and defining few data types have issues like weakly typed or cannot be reused with this approach. We need to ensure that the data types used as parameter and return type should be strongly typed.

4. Polling and Callback:
Calling web service messages asynchronously will avoid waiting for the response due to slow network traffic or complex operations. This asynchronous behavior can be achieved by Polling and Callback model in JAX WS

5. Reusability:
 Implementing caching mechanism for repeatedly needed information and reusing the data will avoid unnecessary network round-trip.

6. Message Encoding:
Avoid using encoded format of the parameters if the environment is not expecting the same. By using literal values instead of encoded format will increase the performance

7. Fault Handling:
 When the web service gets any exception, those exception details will be returned through SOAP messages in Fault element. Proper fault message should be defined in such a way that the end user of the web service can understand the problem.

8. Efficient Use of Header:
Sometimes we may need to send nonfunctional information to the web service processing. Send that information through header instead of payload

9. For better quality of web service, the required features are

  • Availability
  • Accessibility
  • Reliability
  • Throughput
  • Latency
  • Regulatory
  • Security

5.2  Best Practices in Design of Web Service Clients:

1. Synchronize the use of client instances

2. Capture all web service client details

3. Set the value for Client ID: The default client id is not user friendly. So set the client

4. Close the client instances after consumption is complete

5.3  Common Issues:

1.  Improper Namespace declaration
Providing wrong namespaces and using them in the wsdl document will create problem in     resolving the elements using the namespaces
2.  Data type issues
Complex data types will cause to serialize from XML to Java value conversion and it will impact the performance. In order to avoid this performance hit usage of simpler data types like string, int, Bigdecimal are recommended
3.   Frequent and repeated client calls to the service create network traffic and create performance issues.
4.   Unnecessary or complex SOAP message element will increase the processing time to parse the SOAP messages
5.  Marshalling and unmarshalling also cause a huge impact on the processing time. More nested XML elements results in longer marshalling and unmarshalling time

Like us on Facebook