<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
	   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">

	<bean id="session" class="jakarta.mail.Session" factory-method="getInstance">
		<constructor-arg>
			<props/>
		</constructor-arg>
	</bean>

	<bean id="messageFactory"
		  class="org.springframework.ws.soap.saaj.SaajSoapMessageFactory"/>

	<bean id="greenmail" class="com.icegreen.greenmail.spring.GreenMailBean">
		<property name="autostart" value="true"/>
		<property name="smtpProtocol" value="true"/>
		<property name="imapProtocol" value="true"/>
		<property name="users">
			<list>
				<value>system:password@localhost</value>
			</list>
		</property>
	</bean>

	<bean id="messagingReceiver"
		  class="org.springframework.ws.transport.mail.MailMessageReceiver"
		  depends-on="greenmail">
		<property name="messageFactory" ref="messageFactory"/>
		<property name="from" value="Spring-WS SOAP Server &lt;server@localhost&gt;"/>
		<property name="storeUri" value="imap://system:password@localhost:3143/INBOX"/>
		<property name="transportUri" value="smtp://system:password@localhost:3025"/>
		<property name="messageReceiver" ref="messageDispatcher"/>
		<property name="session" ref="session"/>
		<property name="monitoringStrategy">
			<bean class="org.springframework.ws.transport.mail.monitor.Pop3PollingMonitoringStrategy">
				<property name="pollingInterval" value="500"/>
			</bean>
		</property>
	</bean>

	<bean id="messageDispatcher"
		  class="org.springframework.ws.soap.server.SoapMessageDispatcher">
		<property name="endpointMappings">
			<bean class="org.springframework.ws.server.endpoint.mapping.PayloadRootQNameEndpointMapping">
				<property name="defaultEndpoint">
					<bean class="org.springframework.ws.transport.test.EchoPayloadEndpoint"/>
				</property>
			</bean>
		</property>
	</bean>

	<bean id="webServiceTemplate"
		  class="org.springframework.ws.client.core.WebServiceTemplate"
		  depends-on="greenmail">
		<constructor-arg ref="messageFactory"/>
		<property name="messageSender">
			<bean class="org.springframework.ws.transport.mail.MailMessageSender">
				<property name="from"
						  value="Spring-WS SOAP Client &lt;client@localhost&gt;"/>
				<property name="transportUri"
						  value="smtp://system:password@localhost:3025"/>
				<property name="storeUri"
						  value="imap://system:password@localhost:3143/INBOX"/>
				<property name="receiveSleepTime" value="1000"/>
				<property name="session" ref="session"/>
			</bean>
		</property>
		<property name="defaultUri" value="mailto:server@localhost?subject=SOAP%20Test"/>
	</bean>


</beans>
