diff --git a/core/src/main/java/org/springframework/ws/client/WebServiceClientException.java b/core/src/main/java/org/springframework/ws/client/WebServiceClientException.java index 0ff193ef..7dcfc7c3 100644 --- a/core/src/main/java/org/springframework/ws/client/WebServiceClientException.java +++ b/core/src/main/java/org/springframework/ws/client/WebServiceClientException.java @@ -19,9 +19,11 @@ package org.springframework.ws.client; import org.springframework.ws.WebServiceException; /** + * Exception thrown whenever an error occurs on the client-side. + * * @author Arjen Poutsma */ -public class WebServiceClientException extends WebServiceException { +public abstract class WebServiceClientException extends WebServiceException { public WebServiceClientException(String msg) { super(msg); diff --git a/core/src/main/java/org/springframework/ws/client/core/WebServiceFaultException.java b/core/src/main/java/org/springframework/ws/client/WebServiceFaultException.java similarity index 90% rename from core/src/main/java/org/springframework/ws/client/core/WebServiceFaultException.java rename to core/src/main/java/org/springframework/ws/client/WebServiceFaultException.java index d2396446..57e25e18 100644 --- a/core/src/main/java/org/springframework/ws/client/core/WebServiceFaultException.java +++ b/core/src/main/java/org/springframework/ws/client/WebServiceFaultException.java @@ -14,9 +14,7 @@ * limitations under the License. */ -package org.springframework.ws.client.core; - -import org.springframework.ws.client.WebServiceClientException; +package org.springframework.ws.client; /** * Thrown by SimpleFaultResolver when the response message has a fault. diff --git a/core/src/main/java/org/springframework/ws/client/WebServiceIOException.java b/core/src/main/java/org/springframework/ws/client/WebServiceIOException.java new file mode 100644 index 00000000..30d534c3 --- /dev/null +++ b/core/src/main/java/org/springframework/ws/client/WebServiceIOException.java @@ -0,0 +1,35 @@ +/* + * Copyright 2007 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.ws.client; + +import java.io.IOException; + +/** + * Exception thrown whenever an I/O error occurs on the client-side. + * + * @author Arjen Poutsma + */ +public class WebServiceIOException extends WebServiceClientException { + + public WebServiceIOException(String msg) { + super(msg); + } + + public WebServiceIOException(String msg, IOException ex) { + super(msg, ex); + } +} diff --git a/core/src/main/java/org/springframework/ws/client/WebServiceTransformerException.java b/core/src/main/java/org/springframework/ws/client/WebServiceTransformerException.java new file mode 100644 index 00000000..0834a314 --- /dev/null +++ b/core/src/main/java/org/springframework/ws/client/WebServiceTransformerException.java @@ -0,0 +1,35 @@ +/* + * Copyright 2007 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.ws.client; + +import javax.xml.transform.TransformerException; + +/** + * Exception thrown whenever an transformation error occurs on the client-side. + * + * @author Arjen Poutsma + */ +public class WebServiceTransformerException extends WebServiceClientException { + + public WebServiceTransformerException(String msg) { + super(msg); + } + + public WebServiceTransformerException(String msg, TransformerException ex) { + super(msg, ex); + } +} diff --git a/core/src/main/java/org/springframework/ws/client/WebServiceTransportException.java b/core/src/main/java/org/springframework/ws/client/WebServiceTransportException.java new file mode 100644 index 00000000..51ab3879 --- /dev/null +++ b/core/src/main/java/org/springframework/ws/client/WebServiceTransportException.java @@ -0,0 +1,35 @@ +/* + * Copyright 2007 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.ws.client; + +import org.springframework.ws.transport.TransportException; + +/** + * Exception thrown whenever an transport error occurs on the client-side. + * + * @author Arjen Poutsma + */ +public class WebServiceTransportException extends WebServiceIOException { + + public WebServiceTransportException(String msg) { + super(msg); + } + + public WebServiceTransportException(String msg, TransportException ex) { + super(msg, ex); + } +} diff --git a/core/src/main/java/org/springframework/ws/client/core/SimpleFaultResolver.java b/core/src/main/java/org/springframework/ws/client/core/SimpleFaultResolver.java index 7d868c58..40cd8dcf 100644 --- a/core/src/main/java/org/springframework/ws/client/core/SimpleFaultResolver.java +++ b/core/src/main/java/org/springframework/ws/client/core/SimpleFaultResolver.java @@ -17,18 +17,18 @@ package org.springframework.ws.client.core; import org.springframework.ws.WebServiceMessage; +import org.springframework.ws.client.WebServiceFaultException; /** - * Simple fault resolver that simply throws a {@link WebServiceFaultException} when a fault occurs. + * Simple fault resolver that simply throws a {@link org.springframework.ws.client.WebServiceFaultException} when a + * fault occurs. * * @author Arjen Poutsma - * @see WebServiceFaultException + * @see org.springframework.ws.client.WebServiceFaultException */ public class SimpleFaultResolver implements FaultResolver { - /** - * Throws a new WebServiceFaultException. - */ + /** Throws a new WebServiceFaultException. */ public void resolveFault(WebServiceMessage message) { throw new WebServiceFaultException(message.getFaultReason()); } diff --git a/core/src/main/java/org/springframework/ws/client/core/WebServiceOperations.java b/core/src/main/java/org/springframework/ws/client/core/WebServiceOperations.java index c95fe83c..17ec68cd 100644 --- a/core/src/main/java/org/springframework/ws/client/core/WebServiceOperations.java +++ b/core/src/main/java/org/springframework/ws/client/core/WebServiceOperations.java @@ -16,10 +16,12 @@ package org.springframework.ws.client.core; -import java.io.IOException; import javax.xml.transform.Result; import javax.xml.transform.Source; +import org.springframework.oxm.GenericMarshallingFailureException; +import org.springframework.ws.client.WebServiceClientException; + /** * Specifies a basic set of Web service operations. Implemented by {@link WebServiceTemplate}. Not often used directly, * but a useful option to enhance testability, as it can easily be mocked or stubbed. @@ -35,11 +37,14 @@ public interface WebServiceOperations { * * @param requestPayload the object to marshal into the request message payload * @return the unmarshalled payload of the response message, or null if no response is given - * @throws IOException in case of I/O errors + * @throws GenericMarshallingFailureException + * if there is a problem marshalling or unmarshalling + * @throws WebServiceClientException if there is a problem sending or receiving the message * @see WebServiceTemplate#setMarshaller(org.springframework.oxm.Marshaller) * @see WebServiceTemplate#setUnmarshaller(org.springframework.oxm.Unmarshaller) */ - Object marshalSendAndReceive(Object requestPayload) throws IOException; + Object marshalSendAndReceive(Object requestPayload) + throws GenericMarshallingFailureException, WebServiceClientException; /** * Sends a web service message that contains the given payload, marshalled by the configured @@ -49,11 +54,14 @@ public interface WebServiceOperations { * @param requestPayload the object to marshal into the request message payload * @param requestCallback callback to change message, can be null * @return the unmarshalled payload of the response message, or null if no response is given - * @throws IOException in case of I/O errors + * @throws GenericMarshallingFailureException + * if there is a problem marshalling or unmarshalling + * @throws WebServiceClientException if there is a problem sending or receiving the message * @see WebServiceTemplate#setMarshaller(org.springframework.oxm.Marshaller) * @see WebServiceTemplate#setUnmarshaller(org.springframework.oxm.Unmarshaller) */ - Object marshalSendAndReceive(Object requestPayload, WebServiceMessageCallback requestCallback) throws IOException; + Object marshalSendAndReceive(Object requestPayload, WebServiceMessageCallback requestCallback) + throws GenericMarshallingFailureException, WebServiceClientException; /** * Sends a web service message that contains the given payload, reading the result with a @@ -62,8 +70,9 @@ public interface WebServiceOperations { * @param requestPayload the payload of the request message * @param responseExtractor object that will extract results * @return an arbitrary result object, as returned by the SourceExtractor + * @throws WebServiceClientException if there is a problem sending or receiving the message */ - Object sendAndReceive(Source requestPayload, SourceExtractor responseExtractor) throws IOException; + Object sendAndReceive(Source requestPayload, SourceExtractor responseExtractor) throws WebServiceClientException; /** * Sends a web service message that contains the given payload, reading the result with a @@ -75,10 +84,11 @@ public interface WebServiceOperations { * @param requestCallback callback to change message, can be null * @param responseExtractor object that will extract results * @return an arbitrary result object, as returned by the SourceExtractor + * @throws WebServiceClientException if there is a problem sending or receiving the message */ Object sendAndReceive(Source requestPayload, WebServiceMessageCallback requestCallback, - SourceExtractor responseExtractor) throws IOException; + SourceExtractor responseExtractor) throws WebServiceClientException; /** * Sends a web service message that contains the given payload. Writes the response, if any, to the given @@ -86,9 +96,9 @@ public interface WebServiceOperations { * * @param requestPayload the payload of the request message * @param responseResult the result to write the response payload to - * @throws IOException in case of I/O errors + * @throws WebServiceClientException if there is a problem sending or receiving the message */ - void sendAndReceive(Source requestPayload, Result responseResult) throws IOException; + void sendAndReceive(Source requestPayload, Result responseResult) throws WebServiceClientException; /** * Sends a web service message that contains the given payload. Writes the response, if any, to the given @@ -99,10 +109,10 @@ public interface WebServiceOperations { * @param requestPayload the payload of the request message * @param requestCallback callback to change message, can be null * @param responseResult the result to write the response payload to - * @throws IOException in case of I/O errors + * @throws WebServiceClientException if there is a problem sending or receiving the message */ void sendAndReceive(Source requestPayload, WebServiceMessageCallback requestCallback, Result responseResult) - throws IOException; + throws WebServiceClientException; /** * Sends a web service message that can be manipulated with the given callback, reading the result with a @@ -111,10 +121,10 @@ public interface WebServiceOperations { * @param requestCallback the requestCallback to be used for manipulating the request message * @param responseExtractor object that will extract results * @return an arbitrary result object, as returned by the WebServiceMessageExtractor - * @throws IOException in case of I/O errors + * @throws WebServiceClientException if there is a problem sending or receiving the message */ Object sendAndReceive(WebServiceMessageCallback requestCallback, WebServiceMessageExtractor responseExtractor) - throws IOException; + throws WebServiceClientException; /** * Sends a web service message that can be manipulated with the given callback, reading the result with a @@ -122,8 +132,8 @@ public interface WebServiceOperations { * * @param requestCallback the callback to be used for manipulating the request message * @param responseCallback the callback to be used for manipulating the response message - * @throws IOException in case of I/O errors + * @throws WebServiceClientException if there is a problem sending or receiving the message */ void sendAndReceive(WebServiceMessageCallback requestCallback, WebServiceMessageCallback responseCallback) - throws IOException; + throws WebServiceClientException; } diff --git a/core/src/main/java/org/springframework/ws/client/core/WebServiceTemplate.java b/core/src/main/java/org/springframework/ws/client/core/WebServiceTemplate.java index 1ee54529..cf38ef11 100644 --- a/core/src/main/java/org/springframework/ws/client/core/WebServiceTemplate.java +++ b/core/src/main/java/org/springframework/ws/client/core/WebServiceTemplate.java @@ -36,10 +36,13 @@ import org.springframework.util.Assert; import org.springframework.util.ClassUtils; import org.springframework.ws.WebServiceMessage; import org.springframework.ws.WebServiceMessageFactory; -import org.springframework.ws.client.WebServiceClientException; +import org.springframework.ws.client.WebServiceIOException; +import org.springframework.ws.client.WebServiceTransformerException; +import org.springframework.ws.client.WebServiceTransportException; import org.springframework.ws.client.support.WebServiceAccessor; import org.springframework.ws.context.MessageContext; import org.springframework.ws.transport.FaultAwareWebServiceConnection; +import org.springframework.ws.transport.TransportException; import org.springframework.ws.transport.TransportInputStream; import org.springframework.ws.transport.TransportOutputStream; import org.springframework.ws.transport.WebServiceConnection; @@ -144,12 +147,11 @@ public class WebServiceTemplate extends WebServiceAccessor implements WebService * Marshalling methods */ - public Object marshalSendAndReceive(final Object requestPayload) throws IOException { + public Object marshalSendAndReceive(final Object requestPayload) { return marshalSendAndReceive(requestPayload, null); } - public Object marshalSendAndReceive(final Object requestPayload, final WebServiceMessageCallback requestCallback) - throws IOException { + public Object marshalSendAndReceive(final Object requestPayload, final WebServiceMessageCallback requestCallback) { if (getMarshaller() == null) { throw new IllegalStateException("No marshaller registered. Check configuration of WebServiceTemplate."); } @@ -176,13 +178,13 @@ public class WebServiceTemplate extends WebServiceAccessor implements WebService * Result-handling methods */ - public void sendAndReceive(Source requestPayload, Result responseResult) throws IOException { + public void sendAndReceive(Source requestPayload, Result responseResult) { sendAndReceive(requestPayload, null, responseResult); } public void sendAndReceive(Source requestPayload, WebServiceMessageCallback requestCallback, - final Result responseResult) throws IOException { + final Result responseResult) { try { final Transformer transformer = createTransformer(); doSendAndReceive(transformer, requestPayload, requestCallback, new SourceExtractor() { @@ -192,14 +194,14 @@ public class WebServiceTemplate extends WebServiceAccessor implements WebService transformer.transform(source, responseResult); } catch (TransformerException ex) { - throw new WebServiceClientException("Could not transform payload", ex); + throw new WebServiceTransformerException("Could not transform payload", ex); } return null; } }); } - catch (TransformerException ex) { - throw new WebServiceClientException("Could not create transformer", ex); + catch (TransformerConfigurationException ex) { + throw new WebServiceTransformerException("Could not create transformer", ex); } } @@ -207,27 +209,26 @@ public class WebServiceTemplate extends WebServiceAccessor implements WebService * Source-handling methods */ - public Object sendAndReceive(final Source requestPayload, final SourceExtractor responseExtractor) - throws IOException { + public Object sendAndReceive(final Source requestPayload, final SourceExtractor responseExtractor) { return sendAndReceive(requestPayload, null, responseExtractor); } public Object sendAndReceive(final Source requestPayload, final WebServiceMessageCallback requestCallback, - final SourceExtractor responseExtractor) throws IOException { + final SourceExtractor responseExtractor) { try { return doSendAndReceive(createTransformer(), requestPayload, requestCallback, responseExtractor); } catch (TransformerConfigurationException ex) { - throw new WebServiceClientException("Could not create transformer", ex); + throw new WebServiceTransformerException("Could not create transformer", ex); } } private Object doSendAndReceive(final Transformer transformer, final Source requestPayload, final WebServiceMessageCallback requestCallback, - final SourceExtractor responseExtractor) throws IOException { + final SourceExtractor responseExtractor) { Assert.notNull(responseExtractor, "responseExtractor must not be null"); return sendAndReceive(new WebServiceMessageCallback() { public void doInMessage(WebServiceMessage message) throws IOException { @@ -238,7 +239,7 @@ public class WebServiceTemplate extends WebServiceAccessor implements WebService } } catch (TransformerException ex) { - throw new WebServiceClientException("Could not transform payload to request message", ex); + throw new WebServiceTransformerException("Could not transform payload to request message", ex); } } }, new SourceExtractorMessageExtractor(responseExtractor)); @@ -248,18 +249,18 @@ public class WebServiceTemplate extends WebServiceAccessor implements WebService * WebServiceMessage-handling methods */ - public void sendAndReceive(WebServiceMessageCallback requestCallback, WebServiceMessageCallback responseCallback) - throws IOException { + public void sendAndReceive(WebServiceMessageCallback requestCallback, WebServiceMessageCallback responseCallback) { Assert.notNull(responseCallback, "responseCallback must not be null"); sendAndReceive(requestCallback, new WebServiceMessageCallbackMessageExtractor(responseCallback)); } public Object sendAndReceive(WebServiceMessageCallback requestCallback, - WebServiceMessageExtractor responseExtractor) throws IOException { + WebServiceMessageExtractor responseExtractor) { Assert.notNull(responseExtractor, "response extractor must not be null"); MessageContext messageContext = createMessageContext(); - WebServiceConnection connection = getMessageSender().createConnection(); + WebServiceConnection connection = null; try { + connection = getMessageSender().createConnection(); WebServiceMessage request = messageContext.getRequest(); if (requestCallback != null) { requestCallback.doInMessage(request); @@ -287,8 +288,21 @@ public class WebServiceTemplate extends WebServiceAccessor implements WebService } return null; } + catch (TransportException ex) { + throw new WebServiceTransportException("Could not use transport: " + ex.getMessage(), ex); + } + catch (IOException ex) { + throw new WebServiceIOException("I/O error: " + ex.getMessage(), ex); + } finally { - connection.close(); + if (connection != null) { + try { + connection.close(); + } + catch (IOException ex) { + logger.debug("Could not close WebServiceConnection", ex); + } + } } } diff --git a/core/src/test/java/org/springframework/ws/client/core/SimpleFaultResolverTest.java b/core/src/test/java/org/springframework/ws/client/core/SimpleFaultResolverTest.java index 0013835d..72fb4c31 100644 --- a/core/src/test/java/org/springframework/ws/client/core/SimpleFaultResolverTest.java +++ b/core/src/test/java/org/springframework/ws/client/core/SimpleFaultResolverTest.java @@ -19,6 +19,7 @@ package org.springframework.ws.client.core; import junit.framework.TestCase; import org.easymock.MockControl; import org.springframework.ws.WebServiceMessage; +import org.springframework.ws.client.WebServiceFaultException; public class SimpleFaultResolverTest extends TestCase { diff --git a/src/changes/changes.xml b/src/changes/changes.xml index d7723e3b..e9c21107 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -6,6 +6,9 @@ + Remove IOExceptions from WebServiceTemplate. A runtime + exception hierarchy has been created in org.springframework.ws.client. + Support JAXB's MTOM/XOP/MIME support. As a result, all Mime-related code in SoapMessage has been moved to the org.springframework.ws.mime package diff --git a/src/docbkx/client.xml b/src/docbkx/client.xml index 218686ac..02ee6b2b 100644 --- a/src/docbkx/client.xml +++ b/src/docbkx/client.xml @@ -1,73 +1,117 @@ + "http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd"> - Using Spring Web Services on the Client -
- Introduction - - Spring-WS provides a client-side Web service API that allows for consistent, XML-driven access to Web - services. It also allows for use of marshallers and unmarshallers. - - - The package org.springframework.ws.client.core provides the core functionality for using - the client-side access API. It contains template classes that simplifies the use of Web services, much like - the JdbcTemplate does for JDBC. The design principle common to Spring template - classes is to provide helper methods to perform common operations and for more sophisticated usage, delegate - the essence of the processing task to user implemented callback interfaces. The Web service template - follows the same design. The classes offer various - convenience methods for the sending and receiving of XML messages, marshalling objects to XML before sending, - and allows for multiple transports, - -
-
- Using the client-side API -
- <classname>WebServiceTemplate</classname> - - The WebServiceTemplate is the core class for client-side Web service access in - Spring-WS. It contains methods for sending Source objects, and receiving response - messages as either Source or Result. Additionally, it can - marshal objects to XML before sending them across a transport, and unmarshal the response XML into an - object again. - -
- Transports - - The WebServiceTemplate requires a reference to a - MessageSender. The message sender is responsible for sending the XML message - across a transport layer. - - - There are two implementations of the MessageSender interface for sending messages - via HTTP. The simplest implementation is the HttpUrlConnectionMessageSender, - which uses the facilities provided by Java SE itself. The alternative is the - CommonsHttpMessageSender, which uses the Jakarta Commons HttpClient. Use the - latter if you need more advanced and easy-to-use functionality. Both HTTP message senders require an - URL to be set using the url property. - -
-
- Message factories - - In addition to a message sender, the WebServiceTemplate requires a Web service - message factory. As explained in , there are two message factories - for SOAP: SaajSoapMessageFactory and - AxiomSoapMessageFactory. If no message factory is specified, Spring-WS will - use the SaajSoapMessageFactory by default. - -
-
-
- Sending and receiving a <interfacename>WebServiceMessage</interfacename> - - The WebServiceTemplate contains many convenience methods to send and receive - web service messages. There are methods that take and return Source - and those that return a Result. Additionally, there are methods which - marshal and unmarshal objects to XML. Here is an example that sends a simple XML message to a Web - service. + Using Spring Web Services on the Client +
+ Introduction + + Spring-WS provides a client-side Web service API that allows for consistent, XML-driven access to Web + services. It also allows for use of + marshallers and unmarshallers + . + + + The package + org.springframework.ws.client.core + provides the core functionality for using + the client-side access API. It contains template classes that simplifies the use of Web services, much like + the + JdbcTemplate + does for JDBC. The design principle common to Spring template + classes is to provide helper methods to perform common operations and for more sophisticated usage, delegate + the essence of the processing task to user implemented callback interfaces. The Web service template + follows the same design. The classes offer various + convenience methods for the sending and receiving of XML messages, marshalling objects to XML before + sending, + and allows for multiple transports, + +
+
+ Using the client-side API +
+ + <classname>WebServiceTemplate</classname> + + + The + WebServiceTemplate + is the core class for client-side Web service access in + Spring-WS. It contains methods for sending + Source + objects, and receiving response + messages as either + Source + or + Result + . Additionally, it can + marshal objects to XML before sending them across a transport, and unmarshal the response XML into an + object again. + +
+ Transports + + The + WebServiceTemplate + requires a reference to a + MessageSender + . The message sender is responsible for sending the XML message + across a transport layer. + + + There are two implementations of the + MessageSender + interface for sending messages + via HTTP. The simplest implementation is the + HttpUrlConnectionMessageSender + , + which uses the facilities provided by Java SE itself. The alternative is the + CommonsHttpMessageSender + , which uses the Jakarta Commons HttpClient. Use the + latter if you need more advanced and easy-to-use functionality. Both HTTP message senders require an + URL to be set using the + url + property. + +
+
+ Message factories + + In addition to a message sender, the + WebServiceTemplate + requires a Web service + message factory. As explained in + + , there are two message factories + for SOAP: + SaajSoapMessageFactory + and + AxiomSoapMessageFactory + . If no message factory is specified, Spring-WS will + use the + SaajSoapMessageFactory + by default. + +
+
+
+ Sending and receiving a + <interfacename>WebServiceMessage</interfacename> + + + The + WebServiceTemplate + contains many convenience methods to send and receive + web service messages. There are methods that take and return + Source + and those that return a + Result + . Additionally, there are methods which + marshal and unmarshal objects to XML. Here is an example that sends a simple XML message to a Web + service. + - - - Here is the corresponding configuration: - - + Here is the corresponding configuration: + + @@ -111,48 +155,73 @@ public class WebServiceClient { ]]> - - This example uses the template to send a hello world message to the web service located at - http://localhost:8080/WebService, and writes the result to the console. - The WebServiceTemplate is injected with the message sender. - A zero argument constructor and messageFactory / - messageSender bean properties are provided and can be used for constructing - the instance (using a BeanFactory or plain Java code). Alternatively, consider deriving from - Spring-WS's WebServiceGatewaySupport convenience base class, which provides - pre-built bean properties for configuration. - -
-
- Marshalling, sending, receiving, and unmarshalling - - In order to facilitate the sending of plain Java objects, the WebServiceTemplate - has a send methods that take an object as an argument for a message's data content. - The method marshalSendAndReceive in WebServiceTemplate - delegates the conversion of the request object to XML to a Marshaller, and - the conversion of the response XML to an object to an Unmarshaller. - For more information about marshalling and unmarshaller, refer to . - By using the marshallers, you and your application code can focus on the business object that is being - sent or received and not be concerned with the details of how it is represented as XML. - In order to use the marshalling functionality, you have to set a marshaller and unmarshaller with the - marshaller/unmarshaller properties of the - WebServiceTemplate. - -
-
- <interface>WebServiceMessageCallback</interface> - - To accommodate the setting of a SOAP headers, and other settings on the message, the - WebServiceMessageCallback interface gives you access to the message - after it has been created, but before it is sent. The example below demonstrates how to set the SOAP - Action header on a message that is created by marshalling an object. - - + This example uses the template to send a hello world message to the web service located at + http://localhost:8080/WebService + , and writes the result to the console. + The + WebServiceTemplate + is injected with the message sender. + A zero argument constructor and + messageFactory + / + messageSender + bean properties are provided and can be used for constructing + the instance (using a BeanFactory or plain Java code). Alternatively, consider deriving from + Spring-WS's + WebServiceGatewaySupport + convenience base class, which provides + pre-built bean properties for configuration. + +
+
+ Marshalling, sending, receiving, and unmarshalling + + In order to facilitate the sending of plain Java objects, the + WebServiceTemplate + has a send methods that take an object as an argument for a message's data content. + The method + marshalSendAndReceive + in + WebServiceTemplate + delegates the conversion of the request object to XML to a + Marshaller + , and + the conversion of the response XML to an object to an + Unmarshaller + . + For more information about marshalling and unmarshaller, refer to + + . + By using the marshallers, you and your application code can focus on the business object that is being + sent or received and not be concerned with the details of how it is represented as XML. + In order to use the marshalling functionality, you have to set a marshaller and unmarshaller with the + marshaller + / + unmarshaller + properties of the + WebServiceTemplate + . + +
+
+ + <interface>WebServiceMessageCallback</interface> + + + To accommodate the setting of a SOAP headers, and other settings on the message, the + WebServiceMessageCallback + interface gives you access to the message + after it has been created, but before it is sent. The example below demonstrates how to set the SOAP + Action header on a message that is created by marshalling an object. + + -
-
+
+
\ No newline at end of file diff --git a/src/site/apt/upgrading.apt b/src/site/apt/upgrading.apt index b764d1d8..0e14cad1 100644 --- a/src/site/apt/upgrading.apt +++ b/src/site/apt/upgrading.apt @@ -15,6 +15,11 @@ Upgrading from version 1.0-M3 to 1.0-RC1 * Methods for getting and adding attachments were taken from <<> and extraced into a new interface: <<>>. Adding a method requires a content id now. +* WebServiceTemplate + + The <<> no longer declares an IOException for each method. Rather, an runtime exception + hierarchy has been created in <<>>. + Upgrading from version 1.0-M2 to 1.0-M3 Several changes were made between version 1.0 Milestone 2 and Milestone 3 of the project. These changes increased