Java Reference
In-Depth Information
Note To invoke a web service using Spring-WS, you have to include spring-ws-1.5.8.jar (located
in the dist directory of the Spring-WS installation), stax-api-1.0.2.jar (located in lib/stax ),
activation-1.1.1.jar and saaj-api-1.3.jar (located in lib/java-ee ), and saaj-impl-1.3.jar (located in
lib/saaj ) in your classpath. To use dom4j, you also have to include dom4j-1.6.1.jar (located in lib/dom4j ).
import org.dom4j.Document;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;
public class WeatherServiceProxy implements WeatherService {
private static final String namespaceUri =
"" ;
private DateFormat dateFormat;
private WebServiceTemplate webServiceTemplate;
public WeatherServiceProxy() throws Exception {
dateFormat = new SimpleDateFormat("yyyy-MM-dd");
public void setWebServiceTemplate(WebServiceTemplate webServiceTemplate) {
this.webServiceTemplate = webServiceTemplate;
public List<TemperatureInfo> getTemperatures(String city, List<Date> dates) {
// Build the request document from the method arguments
Document requestDocument = DocumentHelper.createDocument();
Element requestElement = requestDocument.addElement(
"GetTemperaturesRequest", namespaceUri);
for (Date date : dates) {
// Invoke the remote web service
DocumentSource source = new DocumentSource(requestDocument);
DocumentResult result = new DocumentResult();
webServiceTemplate.sendSourceAndReceiveToResult(source, result);
Search WWH ::

Custom Search