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:






footer




 

 

 

 

 Home | About Us | Network | Services | Support | FAQ | Control Panel | Order Online | Sitemap | Contact

 

Our web partners: Inexpensive Web Hosting Java Web Hosting personal webspace webspace php  linux webhost

 html web templates DreamweaverQuality Web Templates PSD Web Templates

cheap webhost j2ee web Hosting buy webspace ftp webspace adult webspace

frontpage WebHosting webspace hosting cheap webhost

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

webhosting