Announcement Announcement Module
Collapse
No announcement yet.
Email Configuration Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Email Configuration

    Hello,

    I have a SpringWS which when invoked via Spring Integration will send response to a set of subscribed consumers.Currently the responses are logged in the console but now I want this response to be wrapped as an email message and send them to the subscribed consumers. How will the email configuration be?? and what would be the namespace support?? Is it just enough if I have the <mail-target> Please help with some example code snippet.
    gid xml

    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <beans:beans xmlns="http://www.springframework.org/schema/integration"
    	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    	xmlns:beans="http://www.springframework.org/schema/beans"
    	xmlns:tool="http://www.springframework.org/schema/tool"
       xmlns:integration="http://www.springframework.org/schema/integration"
     xsi:schemaLocation="http://www.springframework.org/schema/beans
    			http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
    			http://www.springframework.org/schema/tool
    			http://www.springframework.org/schema/tool/spring-tool-2.5.xsd
    			http://www.springframework.org/schema/integration
    	http://www.springframework.org/schema/integration/spring-integration-ws-1.0.xsd
    			">
    <message-bus/>
        <publish-subscribe-channel id="sendChannel"/>
        <!-- The service activator receives from the 'sendChannel',
    	     invokes the handler, and sends the reply Message to the 'replyChannel'. -->
    <service-activator input-channel="sendChannel"
    	                   ref="msgConverter1"
    	                   output-channel="replyChannel1"/>
    <service-activator input-channel="sendChannel"
    	                   ref="msgConverter1"
    	                   output-channel="replyChannel2"/>
    <!-- The handler invokes the WebService for the given URI and returns a reply Message. -->
    	<ws-handler id="msgConverter1" uri="http://localhost:8080/Trial1/companyservice"/>
    	
    	<!-- The response from the service is logged to the console. -->
    <channel-adapter id="replyChannel1" target="console" />
    <channel-adapter id="replyChannel2" target="console" />
    <console-target id="console"/>
    </beans:beans>
    GidWS.java

    Code:
    package org.springframework.integration.gidb.ws;
    
    import org.springframework.context.support.ClassPathXmlApplicationContext;
    import org.springframework.integration.channel.MessageChannel;
    import org.springframework.integration.message.Message;
    import org.springframework.integration.message.MessageBuilder;
    import org.springframework.integration.ws.handler.AbstractWebServiceHandler;
    import java.util.Properties;
    public class GidWS {
    
    	public static void main(String[] args) {
    		
    		ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("gid.xml", GidWS.class);
    		String requestXml =
    				"<hr:CompanyRequest xmlns:hr=\"http://mycompany.com/hr/schemas\">" +
    				"<hr:Company>"+
    		        "<hr:CompanyName>GetAllCompanies</hr:CompanyName>"+
    	            "</hr:Company>"+
                    "</hr:CompanyRequest>";
    
    		Message<String> message = MessageBuilder.fromPayload(requestXml)
    				.setHeader(AbstractWebServiceHandler.SOAP_ACTION_PROPERTY_KEY, "http://mycompany.com/hr/schemas")
    				.build();
    
    		((MessageChannel)context.getBean("sendChannel")).send(message);
    	}
    }
    Last edited by ashleyvijay; Oct 24th, 2008, 03:11 AM.

  • #2
    Please help!!!

    Can anybody say how the email adapter works?? What would be the configuration??? Any example available???Please help!!!

    Comment


    • #3
      From trunk documentation :

      http://img388.imageshack.us/my.php?image=simailro2.gif

      It's a screenshot because the documentation build failed and I don't know how to convert DocBook files, this is what we see in XMLMind XML Editor

      Hope that can help

      Comment


      • #4
        Thanks alot for the information.Im still not getting hold of things. Could u provide a sample code snippet using <mail-target> cos I think u dnt hve to write verbose code when using <mail-target> right?? Thank u once again

        Comment


        • #5
          Using the current head version of the the mail schema mail send would be as below.
          Code:
          <si:channel id="requests"/>
          
          <mail:header-enricher to="jonas@somewhere" subject="test" input-channel="requests" output-channel="mailSender"/>
          
          <mail:outbound-channel-adapter id="mailSender" host="somemailserver" />

          You can use header enricher to add headers the message which will then determine the behaviour of the outbound channel adapter.

          You can see the other options in the schema here Spring Integration Mail Schema

          Comment

          Working...
          X