82
Designing a Service's Interaction Layer
}
}
Code Example 3.10
Implementation of a Service Specific Exception
Code Example 3.11 shows the service implementation for the same weather
service interface. This example illustrates how the service might throw
CityNotFoundException
.
public class WeatherServiceImpl implements WeatherService {
public String getWeather(String city)
throws CityNotFoundException {
if(!validCity(city))
throw new CityNotFoundException(city + " not found");
// Get weather info and return it back
}
}
Code Example 3.11
Example of a Service Throwing a Service Specific Exception
Chapter 5 describes the details of handling exceptions on the client side. (In
particular, refer to  Handling Exceptions  on page 230.) On the service side, keep
in mind how to include exceptions in the service interface and how to throw them.
Generally, you want to do the following:
E
Convert application specific errors and other Java exceptions into meaningful 
service specific exceptions and throw these service specific exceptions to the 
clients.
Although they promote interoperability among heterogeneous platforms, Web
service standards cannot address every type of exception thrown by different plat 
forms. For example, the standards do not specify how Java exceptions such as
java.io.IOException
 and 
javax.ejb.EJBException
 should be returned to the
client. As a consequence, it is important for a Web service from the service's
interoperability point of view to not expose Java specific exceptions (such as
those just mentioned) in the Web service interface. Instead, throw a service spe 
cific exception. In addition, keep the following points in mind:
<





New Page 1








Home : About Us : Network : Services : Support : FAQ : Control Panel : Order Online : Sitemap : Contact : Terms Of Service

 

Our web partners:  Jsp Web Hosting  Unlimited Web Hosting  Cheapest Web Hosting  Java Web Hosting  Web Templates  Best Web Templates  Web Design Templates  Interland Web Hosting  Cheap Web Hosting  Filemaker Web Hosting  Tomcat Web Hosting  Quality Web Hosting  Best Web Hosting  Mac Web Hosting

 
 

Virtualwebstudio. Business web hosting division of Vision Web Hosting Inc. All rights reserved

Web Hosting Apache