Skip to content

Commit 180caaa

Browse files
committed
SWS-178
1 parent 3565597 commit 180caaa

File tree

1 file changed

+26
-5
lines changed

1 file changed

+26
-5
lines changed

src/docbkx/common.xml

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -223,9 +223,8 @@
223223
<section id="message-context">
224224
<title><interfacename>MessageContext</interfacename></title>
225225
<para>
226-
Typically, messages come in pairs: a request and a response. A request
227-
is created on the client-side, which is sent over some transport to the
228-
server-side, where a response is generated. This response gets
226+
Typically, messages come in pairs: a request and a response. A request is created on the client-side,
227+
which is sent over some transport to the server-side, where a response is generated. This response gets
229228
sent back to the client, where it is read.
230229
</para>
231230
<para>
@@ -235,11 +234,33 @@
235234
On the client-side, the message context is created by the <link linkend="client-web-service-template">
236235
<classname>WebServiceTemplate</classname></link>.
237236
On the server-side, the message context is read from the transport-specific input stream.
238-
For example, in HTTP, it is read from the <interfacename>HttpServletRequest</interfacename> and the response is written back
239-
to the <interfacename>HttpServletResponse</interfacename>.
237+
For example, in HTTP, it is read from the <interfacename>HttpServletRequest</interfacename> and the
238+
response is written back to the <interfacename>HttpServletResponse</interfacename>.
240239
</para>
241240
</section>
242241
</section>
242+
<section id="transport-context">
243+
<title><interfacename>TransportContext</interfacename></title>
244+
<para>
245+
One of the key properties of the SOAP protocol is that it tries to be transport-agnostic. This is why, for
246+
instance, Spring-WS does not support mapping messages to endpoints by HTTP request URL, but
247+
rather by mesage content.
248+
</para>
249+
<para>
250+
However, sometimes it is necessary to get access to the underlying transport, either on the client or server
251+
side. For this, Spring Web Services has the <interfacename>TransportContext</interfacename>. The transport
252+
context allows access to the underlying <interfacename>WebServiceConnection</interfacename>, which typically
253+
is a <classname>HttpServletConnection</classname> on the server side; or a
254+
<classname>HttpUrlConnection</classname> or <classname>CommonsHttpConnection</classname> on the client side.
255+
For example, you can obtain the IP address of the current request in a server-side endpoint or
256+
interceptor like so:
257+
</para>
258+
<programlisting><![CDATA[
259+
TransportContext context = TransportContextHolder.getTransportContext();
260+
HttpServletConnection connection = (HttpServletConnection )context.getConnection();
261+
HttpServletRequest request = connection.getHttpServletRequest();
262+
String ipAddress = request.getRemoteAddr();]]></programlisting>
263+
</section>
243264
<section id="xpath">
244265
<title>Handling XML With XPath</title>
245266
<para>

0 commit comments

Comments
 (0)