Skip to content

Commit 642281d

Browse files
committed
SWS-139: mail support
1 parent 55b8cae commit 642281d

File tree

1 file changed

+95
-3
lines changed

1 file changed

+95
-3
lines changed

src/docbkx/client.xml

Lines changed: 95 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,37 @@
6161
<uri>http://example.com/services</uri>, or supply the <parameter>uri</parameter> parameter
6262
for one of the methods.
6363
</para>
64+
<para>
65+
The following example shows how the default configuration can be used for HTTP transports:
66+
<programlisting><![CDATA[<beans>
67+
68+
<bean id="messageFactory" class="org.springframework.ws.soap.saaj.SaajSoapMessageFactory"/>
69+
70+
<bean id="webServiceTemplate" class="org.springframework.ws.client.core.WebServiceTemplate">
71+
<constructor-arg ref="messageFactory"/>
72+
<property name="defaultUri" value="http://example.com/WebService"/>
73+
</bean>
74+
75+
</beans>]]></programlisting>
76+
</para>
77+
<para>
78+
The folowing example shows how override the default configuration, and to use Commons Http to
79+
authenticate using HTTP authentication:
80+
<programlisting><![CDATA[<bean id="webServiceTemplate" class="org.springframework.ws.client.core.WebServiceTemplate">
81+
<constructor-arg ref="messageFactory"/>
82+
<property name="messageSender">
83+
<bean class="org.springframework.ws.transport.http.CommonsHttpMessageSender">
84+
<property name="credentials">
85+
<bean class="org.apache.commons.httpclient.UsernamePasswordCredentials">
86+
<constructor-arg value="john"/>
87+
<constructor-arg value="secret"/>
88+
</bean>
89+
</property>
90+
</bean>
91+
</property>
92+
<property name="defaultUri" value="http://example.com/WebService"/>
93+
</bean>]]></programlisting>
94+
</para>
6495
</section>
6596
<section>
6697
<title>JMS transport</title>
@@ -74,14 +105,75 @@
74105
</para>
75106
<para>
76107
To use the <classname>JmsMessageSender</classname>, you need to set the
77-
<property>defaultUri</property> or <parameter>uri</parameter> to a JMS URI, which - at a
108+
<property>defaultUri</property> or <parameter>uri</parameter> parameter to a JMS URI, which - at a
78109
minimum - consists of the <literal>jms:</literal> prefix and a destination name. Some examples of
79110
JMS URIs are: <uri>jms:SomeQueue</uri>,
80111
<uri>jms:SomeTopic?priority=3&amp;deliveryMode=NON_PERSISTENT</uri>, and
81112
<uri>jms:RequestQueue?replyToName=ResponseName</uri>.
82113
For more information on this URI syntax, refer to the class level Javadocs of the
83114
<classname>JmsMessageSender</classname>.
84115
</para>
116+
<para>
117+
The following example shows how to use the JMS transport in combination with an ActiceMQ
118+
connection factory:<programlisting><![CDATA[<beans>
119+
120+
<bean id="messageFactory" class="org.springframework.ws.soap.saaj.SaajSoapMessageFactory"/>
121+
122+
<bean id="connectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory">
123+
<property name="brokerURL" value="vm://localhost?broker.persistent=false"/>
124+
</bean>
125+
126+
<bean id="webServiceTemplate" class="org.springframework.ws.client.core.WebServiceTemplate">
127+
<constructor-arg ref="messageFactory"/>
128+
<property name="messageSender">
129+
<bean class="org.springframework.ws.transport.jms.JmsMessageSender">
130+
<property name="connectionFactory" ref="connectionFactory"/>
131+
</bean>
132+
</property>
133+
<property name="defaultUri" value="jms:RequestQueue?deliveryMode=NON_PERSISTENT"/>
134+
</bean>
135+
136+
</beans>]]></programlisting>
137+
</para>
138+
</section>
139+
<section>
140+
<title>Email transport</title>
141+
<para>
142+
Spring Web Services also provides an email transport, which can be used to send web service
143+
messages via SMTP, and retrieve them via either POP3 or IMAP. The client-side email
144+
functionality is contained in the <classname>MailMessageSender</classname> class.
145+
This class creates an email message from the request
146+
<interfacename>WebServiceMessage</interfacename>, and sends it via SMTP. It then waits for a
147+
response message to arrive in the incoming POP3 or IMAP server.
148+
</para>
149+
<para>
150+
To use the <classname>MailMessageSender</classname>, set the <property>defaultUri</property> or
151+
<parameter>uri</parameter> parameter to a <literal>mailto</literal> URI. Here are some URI
152+
examples: <uri>mailto:[email protected]</uri>, and
153+
<uri>mailto:server@localhost?subject=SOAP%20Test</uri>. Make sure that the message sender is
154+
properly configured with a <property>transportUri</property>, which indicates the server to
155+
send requests (typically a SMTP server), and a <property>storeUri</property>, which indicates
156+
the server to poll for responses (typically a POP3 or IMAP server).
157+
</para>
158+
<para>
159+
The following example shows how to use the email transport:<programlisting><![CDATA[<beans>
160+
161+
<bean id="messageFactory" class="org.springframework.ws.soap.saaj.SaajSoapMessageFactory"/>
162+
163+
<bean id="webServiceTemplate" class="org.springframework.ws.client.core.WebServiceTemplate">
164+
<constructor-arg ref="messageFactory"/>
165+
<property name="messageSender">
166+
<bean class="org.springframework.ws.transport.mail.MailMessageSender">
167+
<property name="from" value="Spring-WS SOAP Client &lt;[email protected]&gt;"/>
168+
<property name="transportUri" value="smtp://client:[email protected]"/>
169+
<property name="storeUri" value="imap://client:[email protected]/INBOX"/>
170+
</bean>
171+
</property>
172+
<property name="defaultUri" value="mailto:[email protected]?subject=SOAP%20Test"/>
173+
</bean>
174+
175+
</beans>]]></programlisting>
176+
</para>
85177
</section>
86178
</section>
87179
<section>
@@ -90,7 +182,7 @@
90182
In addition to a message sender, the <classname>WebServiceTemplate</classname> requires a Web
91183
service message factory. There are two message factories for SOAP:
92184
<classname>SaajSoapMessageFactory</classname> and <classname>AxiomSoapMessageFactory</classname>.
93-
If no message factory is specified (via the '<literal>messageFactory</literal>' property),
185+
If no message factory is specified (via the <property>messageFactory</property> property),
94186
Spring-WS will use the <classname>SaajSoapMessageFactory</classname> by default.
95187
</para>
96188
</section>
@@ -237,7 +329,7 @@ public void marshalWithSoapActionHeader(final Source s) {
237329
238330
public Object extractData(WebServiceMessage message) throws IOException
239331
]]><lineannotation>// do your own transforms with message.getPayloadResult()</lineannotation><![CDATA[
240-
]]><lineannotation>// or message.getPayloadSource()</lineannotation><![CDATA[
332+
]]><lineannotation>// or message.getPayloadSource()</lineannotation><![CDATA[
241333
}
242334
});
243335
}]]></programlisting>

0 commit comments

Comments
 (0)