Results 1 to 5 of 5

Thread: Email Configuration

  1. #1
    Join Date
    Sep 2008
    Location
    Mannheim,Germany
    Posts
    125

    Question Email Configuration-Help Needed!

    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 at 03:11 AM.

  2. #2
    Join Date
    Sep 2008
    Location
    Mannheim,Germany
    Posts
    125

    Unhappy Please help!!!

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

  3. #3
    Join Date
    Oct 2008
    Location
    Auxerre, France
    Posts
    16

    Default

    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

  4. #4
    Join Date
    Sep 2008
    Location
    Mannheim,Germany
    Posts
    125

    Question

    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

  5. #5
    Join Date
    Oct 2007
    Location
    London, England
    Posts
    108

    Default

    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
    Jonas Partner
    OpenCredo

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •