I finished up my sample implementation of an SMTP transport for Wse2. Thanks to the power of WSE, you can now easily call Web Services via email :)
The code is attached to this message. Instead of writing up a full article on the implementation, I peppered the code extremely liberally with comments. As a result, the explanation of the code is interleaved with the code itself. I’ll probably write more in depth about specific parts of the implementation, but hopefully the comments in the code should suffice for now.
Thanks to Pawel Lesnikowski for the excellent POP3 library. You can find that implementation on the web here.
A couple of notes:
- The design is heavily inspired by the SoapTcpTransport. I tried to stick to their pattern as much as possible. That said, any bugs are mine -- not theirs.
- The transport requires some basic configuration. I’ve included a sample App.config in the project which can be used in client applications.
- By default, the SMTP server used for sending outgoing messages is localhost. As long as you’re running IIS, this should work fine. If you want to use an external SMTP server, you can specify it by setting the “SmtpServer” key in AppSettings.
- Soap.smtp endpoints are addressed like so:
EndpointReference toEpr = new EndpointReference( new Uri( "urn:stockservice" ) );
toEpr.Via = new Via( new Uri( @"soap.smtp://soap@hyperthink.net" ) );
I have a sample implementation of the TcpAsyncStockService running using soap.smtp://, but I’m not exactly sure if I can post that code. However, thanks to the awesome transport architecture of WSE, changing from soap.tcp:// to soap.smtp:// is a really simple process. All you have to do is change an endpoint reference and you’re off to the races.
Happy hacking…
Download: Net.Hyperthink.Samples.SoapSmtp.zip
