|
61 | 61 | <uri>http://example.com/services</uri>, or supply the <parameter>uri</parameter> parameter
|
62 | 62 | for one of the methods.
|
63 | 63 | </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> |
64 | 95 | </section>
|
65 | 96 | <section>
|
66 | 97 | <title>JMS transport</title>
|
|
74 | 105 | </para>
|
75 | 106 | <para>
|
76 | 107 | 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 |
78 | 109 | minimum - consists of the <literal>jms:</literal> prefix and a destination name. Some examples of
|
79 | 110 | JMS URIs are: <uri>jms:SomeQueue</uri>,
|
80 | 111 | <uri>jms:SomeTopic?priority=3&deliveryMode=NON_PERSISTENT</uri>, and
|
81 | 112 | <uri>jms:RequestQueue?replyToName=ResponseName</uri>.
|
82 | 113 | For more information on this URI syntax, refer to the class level Javadocs of the
|
83 | 114 | <classname>JmsMessageSender</classname>.
|
84 | 115 | </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 <[email protected]>"/> |
| 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> |
85 | 177 | </section>
|
86 | 178 | </section>
|
87 | 179 | <section>
|
|
90 | 182 | In addition to a message sender, the <classname>WebServiceTemplate</classname> requires a Web
|
91 | 183 | service message factory. There are two message factories for SOAP:
|
92 | 184 | <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), |
94 | 186 | Spring-WS will use the <classname>SaajSoapMessageFactory</classname> by default.
|
95 | 187 | </para>
|
96 | 188 | </section>
|
@@ -237,7 +329,7 @@ public void marshalWithSoapActionHeader(final Source s) {
|
237 | 329 |
|
238 | 330 | public Object extractData(WebServiceMessage message) throws IOException
|
239 | 331 | ]]><lineannotation>// do your own transforms with message.getPayloadResult()</lineannotation><![CDATA[
|
240 |
| - ]]><lineannotation>// or message.getPayloadSource()</lineannotation><![CDATA[ |
| 332 | + ]]><lineannotation>// or message.getPayloadSource()</lineannotation><![CDATA[ |
241 | 333 | }
|
242 | 334 | });
|
243 | 335 | }]]></programlisting>
|
|
0 commit comments