- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
I would like to see this implemented purely so I can run some XML through it 10 times and laugh.
Admin
Well, besides the obvious XML bloat the really WTF for me is that
it is returning 'void' and not specifying any exceptions it might throw either ...
is this method so advanced that it can't possibly fail? ;)
Admin
This sort of XML-in-XML has unfortunately already been invented, more or less, by Apple with their shiny new XML property-lists. -_-;
The forum software apparently doesn't want me to paste anything, so I'll just link to Apple's documentation with an example.
Admin
Why do people say stuff like this without backing it up?
Let me try:
Actually, yo mama is a WTF!
Admin
This is exactly why people shouldn't make jokes on here anymore.
Admin
I bet the webservice crashes if you send a "malformed XML" and of course, whoever created it, will blame it on the developers that don't know how to use it! is so simple!
Admin
Of all the people on this board, Alex, I thought you would be the last to compare code to data - VB to XML.
Code (like VB) describes how methods are implemented.
Data (like XML) describes how methods are to be used.
If they had implemented a "sendmail" method in XSL, that would be a WTF.
Admin
Jonathan Postel would be spinning in his grave.
Admin
I'll back it up for him. Here's a trivial XML-RPC method call (body only):
<methodCall>
<methodName>colorCode</methodName>
<params>
<param>
<array><data>
<value><double>1.0</double></value>
<value><double>0.8</double></value>
<value><double>0.0</double></value>
</data></array>
</param>
</params>
</methodCall>
and here's how a sane programmer would write it:
colorCode([1.0, 0.8, 0.0]);
Not only it's far shorter than the XML even after compressing the XML, but I can write a recursive-descent parser for that in... what... 60-100 LOC, depending on the language? Certainly less than the SAX code required for decoding the first version.
Though I should compare it to the complexity of a minimal and not fully compliant XML parser, in order to be completely fair...
Admin
I've used email as a carrier for a distributed service. Basically, piping email through a /etc/smrsh script to process XML/CSV data contained therein. Each such message had a subject containing the transaction ID of the email message, and the script sent an email in return to acknowledge receipt. If the sending server had a message unacknowledged after 4 hours, it would resend the message.
This gives (nearly) all the advantages of SOAP/web services, but with the added advantage that a temporary network outage, or a sudden heavy burst of traffic/updates gets handled smoothly, without beating up any servers, and without data loss. (sendmail is awfully good at what it does!)
Admin
One could easily write a wrapper or interface function for that stupid thing, one that actually takes the data as normal parameters, wraps it into xml and then passes it to the xml mailer. Who ever said the function must be used as-is...
Admin
A wrapper for a wrapper for sending an email.
When does it end?
Admin
I see. Port 25 is blocked, because we don't want just anybody to be able to send email with arbitrary From: addresses, but we'll provide a nifty new XML/HTTP service to allow just anybody to send email with arbitrary From: addresses. Brillant!
Admin
The stupid thing about XMTP is that SMTP is already ~=eXteNSiBLe=~.
Admin
How about XTCP? :)
<tcp> <header> <source-port>52123</source-port> <destination-port>80</destination-port> <sequence-number>123456</sequence-number> <ack-number>987654</ack-number> <control-flags> <urgent>0</urgent> <push>0</push> <reset>0</reset> <syn>0</syn> <finish>0</finish> </control-flags> <window-size>9216</window> <checksum>1234</checksum> <urgent-pointer>0</urgent-pointer> <options></options> </header> <data encoding="base64"> R0VUIC8gSFRUUC8xLjAKSG9zdDogd3d3LmV4YW1wbGUuY29tOjgwClVzZXItQWdlbnQ6IE1v emlsbGEvNC4wIChjb21wYXRpYmxlOyBNU0lFIDYuMDsgV2luTlQgNS4xKQpBY2NlcHQ6ICoK Cg== </data> </tcp>
Admin
Re XTCP: If you use Ethereal you can export a capture file as XML.
Admin
Looks like XSDL to me...
Admin
And... this makes the more and more common but very annoying mistake of confusing an "email" with an "email address" (the Email attribute). People don't ask for someone's house, why should they ask for their email?
Admin
Issue is that the boundaries here are damn blurry, code is data too, and data is also code.
In different situations, your code is data to your compiler, or your interpreter, or your VM.
But even in a single place, Lisp code is also Lisp data, and Lisp data is Lisp code as well.
Admin
I gotta say, I couldn't call the original code a WTF without knowing more about the framework they're using, and the environment in which it's running. It would be a WTF for a small app running on a Windows PC, but what about an enterprise app containing servers in zones that don't allow direct communication outside over SMTP?
Also, sending an email can be a blocking task that takes a significant amount of time. Maybe the framework makes the service available as an asynchronous task? I've used frameworks that did this. You don't want a couple of simultaneous email sends taking up a bunch of your valuable threads. Instead, you make it an asynchronous service, backed by a queue.
As for the XML part, what if there are clients written in many different languages, on PCs, mainframes, etc that wish to perform this task? It may be perfectly acceptable to make the service abailable through XML over HTTP. Pretty much every client can invoke that, rather than depending on the clients being able to use COM, RMI or something similar.
The code may be a WTF, but I think the biggest WTF is the way people are jumping all over what might very well be perfectly reasonable, and in fact could be perfect for the environment in which it works.
Admin
here's the output of a swf to xml converter:
<DefineBits objectID="2">
<data>
<data>/9j/4AAQSkZJRgABAQAAAQABAAD/wAARCAH0APoDAS... [ad infinitum]
You guessed it. a bitmap in xml!
(now will the "community server" mash up my post???)
Admin
See? easy....
Admin
I don't see the problem here. If you have an application that sends out a lot of different e-mails and you want this to be easily managed, it is not a bad idea to save the e-mail data externally (xml for example).
Lot better than having to change the logic and recompile just to change a body or to header in some specific email...
Admin
The point about Web Services is that they provide a standardised mechanism by which methods can be discovered and invoked on remote systems. Typically you'll use a toolkit to generate the required proxy code to communicate with the required methods - the toolkit should be able to find out everything it needs to know about the methods from the (normally system generated) WSDL. As WSDL makes use of the XSD namespaces, the object graphs required to transmit and recieve data from the remote methods can be defined in detail so that the programmer making use of the remote method knows exactly what data is required in which types.
The WTF here is not the 'sending-an-email-via-XML' idea (although it's fairly stupid); no, it's the fact that the method only has one input. Now, even though the author of the method is expecting an XML document (which in itself is insane), that's not what's been defined - the input is any old String.
What should have been done here is to define a class or a struct to model the data being passed to the method (email address, name, from address and so on), and have that as the parameter. The WSDL can the accurately model the requirements for the method, and the framework can handle the mapping of the input data. Remember that a Web Service does not imply XML communication - that's only if you're using SOAP as the transport mechanism; you could just as easily be using HttpPost or HttpGet as transports.
Admin
XML is like violence, if it doen't fix your problem you're not using enough of it.
Admin
I hope the framework has got a helper class generating the XML string for the WebService, that implements this interface:
public interface MailHelper
{
void From(String sender);
void To(String receiver);
void Cc(String copy);
void Bcc(String blindCopy);
void Subject(String subject);
void Body(String mailText);
String GenerateXml();
}
Now you can call the WebService like this:
MailHelper helper = ...;
helper.From(sender);
...
serviceWrapper.SendEmailMessage(helper.GenerateXml());
Admin
</number></plus>Is that what God said after inventing politicians?
</number></variable></greater-than></if>
Admin
So how is this different to, say, sending a binary attachment via SMTP - you do realise that attachments are converted to character strings (Base64 or UUEncode) whenever you send an email? Remeber that SMTP was only designed to handle ASCII characters (that's 7 bits not 8). Have a look at http://email.about.com/cs/standards/a/base64_encoding.htm for more information.
Admin
<font size="2">
</font><font size="2"></font>
<font size="2">Holy WTF! I work with email (a _lot_ of it), and stuff like this is part of what drives me insane.
</font>
<font size="2">Here is what you need to do if you need to send an email:
</font>
<font size="2">Method 1) Be a proper SMTP client. Connect to a designated mail submission agent (MSA on 587/tcp) and send mail via SMTP. This has the advantage that you do not need a mail client on the host itself, but it is slightly unreliable if your network connectivity fails (unless you implement queuing yourself).
</font>
<font size="2">Method 2) Run a MTA/MSA in submission only mode with a commandline interface (/usr/lib/sendmail or /usr/sbin/sendmail or equivalent). The MTA handles queueing and all the complexities of transferring mail over the network to the designated MTA.
</font>
<font size="2">Authentication is trivial to implement in SMTP (and for those people pointing out port 25 blocks, if you need to send mail, you can always get those lifted for mail going to a designated MSA).
</font>
<font size="2">The purpose of using different ports for different services is being broken by this whole HTTP for everything crap.
</font>
<font size="2">Why would you need to run SMTP over HTTP in the first place? Really, if you need to implement something like that, then you are solving the wrong problem in the first place.
</font>
<font size="2">(Hopefully this isn't mangled too much)
</font>
Admin
Coming from Paula. <FONT size=4>THAT</FONT> made me laugh!!!
Admin
This is what you all have been waiting for: a truly extensible markup language! :D
http://www.orfjackal.net/temp/xxml/
(I just couldn't resist the temptation.)
Here is what today's WTF looks like when it has been processed by this program:
<font size="2"><?xml version="1.0"?>
<element name="EmailMessage">
<characters>
</characters>
<element name="From">
<characters>
</characters>
<element name="Address">
<attribute name="Name">John Doe</attribute>
<attribute name="Email">[email protected]</attribute>
</element>
<characters>
</characters>
</element>
<characters>
</characters>
<element name="To">
<characters>
</characters>
<element name="Address">
<attribute name="Name">John Doe</attribute>
<attribute name="Email">[email protected]</attribute>
</element>
<characters>
</characters>
</element>
<characters>
</characters>
<element name="CC">
<characters>
</characters>
<element name="Address">
<attribute name="Name">John Doe</attribute>
<attribute name="Email">[email protected]</attribute>
</element>
<characters>
</characters>
</element>
<characters>
</characters>
<element name="BCC">
<characters>
</characters>
<element name="Address">
<attribute name="Name">John Doe</attribute>
<attribute name="Email">[email protected]</attribute>
</element>
<characters>
</characters>
</element>
<characters>
</characters>
<element name="Subject">
<characters>Test Email To John Doe</characters>
</element>
<characters>
</characters>
<element name="Body">
<characters>This contains the body of the Email to John Doe</characters>
</element>
<characters>
</characters>
</element>
</font>
Admin
They're not really that similar at all, I don't think.
Shouldn't it have this DTD:
<!DOCTYPE lisp-program list*>
<!ELEMENT list (list|atom, list|atom)> <!-- (car, cdr) -->
<!ELEMENT atom #CDATA>
?
<!-- (plus 2 2) -->
<lisp-program>
<list>
<atom>plus</atom>
<list>
<atom>2</atom>
<atom>2</atom>
</list>
</list>
</lisp-program>
That one reflects usage/theory not original syntax. Original LISP syntax is closer to this one:
<!DOCTYPE lisp-program list*>
<!ELEMENT list (list|atom*)>
<!ELEMENT atom #CDATA>
<!-- (plus 2 2) -->
<lisp-program>
<list>
<atom>plus</atom>
<atom>2</atom>
<atom>2</atom>
</list>
</lisp-program>
But here the parser would have to do more work. For example, in the first DTD, implementing car and cdr are trivial; they are litirally the first and second sub-elements of the <list> element. You could actually represent car and cdr with a trivial XPATH rule.
But in the second, it would have to create a new <list> element to contain the cdr list.
Reed
Admin
Which is a very valid reason in many (especially large) corporations, sadly...
I've so far come across directives passed down from board (read CEO) level in multinational multibillion dollar corporations twice that dictated every application to use XML (no questions asked, doesn't matter if it serves any purpose, but every application has to use XML).
Admin
What's the problem now you just have to make the SmtpMail.Send function use the Web Service to send and you have a simple way to send emails while following the SOA Vision of Initech.
Admin
So what happens if my email string looks like
"</EMAILMESSAGE><EMAILMESSAGE>"
Because people do things like that.
Admin
Hm.
Well, I had html in that email string. You know... close the body tag, start adding more html email tags.... You get the idea, right?
Admin
Its stupid++ !!!
(or Inc(stupid) or stupid=stupid+1 for our Pascal/VB-coding friends)
-dZ.
Admin
I don't see any problem upgrading all the company systems to support XML!!!1
With our marketing department, we created a 3-month project to upgrade everything here to encapsulate all our data into XML. They guaranteed us our sales would skyrocket!!!!1one!!
The first step was upgrading our network equipment to support RFC 3252 (Binary Lexical Octet Ad-hoc Transport). Please, take a look on http://www.faqs.org/rfcs/rfc3252.html.
Admin
There is a difference: you can not get put in jail yet for using it.
Too bad.
Sincerely,
Gene Wirchenko
Admin
Exceptions can be thrown server side and caught client side (in .Net anyway).
Admin
Service Oriented Architecture properly refers to a set of design principles for constructing extensible applications architected around self-contained business units of work called "services." I could elaborate on the characteristics of SOA but the Wikipedia entry does a decent job on the basics.
It is possible to employ SOA principles without using web services. In fact, it has been done so for many, many years in industries like telecommunications. The problem arises when a mechanism for enabling SOA (like web services) becomes conflated with the design principles.
Back to lurking.....
Admin
So, this guys are guilty of making an email sending function that takes XML formatted e-mails (not a bad concept), but not taking extra time to define an abstraction layer that would make the process more object-friendly?
Ooooooo... WTF.... I'm scared [8-)]
Admin
Ok, so let me get this right ...
And some people on here think this is ok!
Admin
Sadly, I know oh too well how this sort of thing happens:
Application Programmer (AP): "You know that prototype web service for sending e-mail that accepts arrays in its parameters? I can't use it."
SOA Architect (SOA): "Why not?"
AP: "The framework I'm forced to use for web services doesn't handle arrays according to spec, and corporate policy won't let me use a different framework that is actually compliant."
SOA: "*sigh* can you at least pass me a single frickin' STRING? I've gotta have this framework in production by the day after tomorrow."
Admin
He's comparing two different ways of doing the same thing. He should have shown us the code that generates and processes that XML abomination, but it's easier and more concise to show us the XML and let us use our imaginations.
Admin
I see so much overuse of XML where I work it makes me want to kill someone. It's always the uber nerds that have no understanding of the big picture who think adding XML to an application will make it better.
Admin
<tag att="1">some text</tag>
Is semantically equivilent to something like:
'('ELEMENT tag (('ATTRIBUTE att "1") ('TEXT "some text")))
(Confession: I dunno if this is valid LISP, because I really know Scheme better than LISP.)
So you can represent any XML document as a LISP list. You can't really do the reverse, though, without making stuff up. (Which is why you have the need for weird things like <atom/>)
But by essentially fudging with the syntax, you can get a VERY verbose XML-based representation of LISP lists. And from there, you're only an evaluator away from having a working XML-based computer language. :)
The real way that they're similar, though, is that they're based on lists of other lists. An XML element contains a list of other XML elements. (Redefine some of those elements as atoms, and you've got a working language.) In that respect, the two are similar.
Take four on the stupid captcha... does case count?
Admin
Grr... I'm really beginning to dislike this forum software. That's the second post of mine it's gobbled the formatting in. I think there's something screwy between my web browser and the forum software. WYSIWYG is nice and all, but it's really starting to get annoying...
Admin
well "MailMessage" resides under system.WEB namespace and uses the old COM components in CDO which are not available on every machine.
so if you publish your app through click once or any other x-copy'ish way , you wont be able to use those classes (unless you know that cdo is available on every machine).
so the only odd part is the xml instead of object args..
Admin
Usually in .NET it is done like this: