The HTTP header *may* provide information about the client used to post the message, but using this information -- or any other -- to provide a different response maculates the own spirit of a web service, which is all about interoperability. If the message was forwarded, this may be totally misleading.
A more stable (read: more maintainable) solution would be to provide two different endpoints or URLS, one for DIME and another for MIME. Of course, you can share the actual code, but the attachment format would be chosen by the caller, not imposed by the server. Guessing is never a good practice, because Murphy's Law says you *will* make the wrong guess... This guess-what-the-client-wants is typical of M$ products, but the result is always bad -- for example, my M$-Word "auto" features are all turned off, because its guesses are almost always wrong... Don't do that with your WS. Be nice and let the client choose what he wants. He will be happier. (Well, at least, the client programmers will... ). Specifying that SOAP header is also an option, and I don't see why that would be ugly, since that's exactly the type of orthogonal information headers are supposed to carry. And it automatically provides a way to support other future formats for the attachments. It is the most extensible and maintainable solution, because the interface is not disrupted for new formats. It gives a little extra work, but it may pay off in the future. I have a similar situation, but since my service is restricted to my intranet, I chose to provide only DIME responses. Both Java/Axis and .NET clients understand that, so there was no point in providing MIME attachments. ============================================= Marcelo Jaccoud Amaral mailto:jaccoud [at] petrobras.com.br voice: +55 21 2534-3485 fax: +55 21 2534-1809 ============================================= There are only 10 kinds of people in the world: those who understand binary and those who don't. "Eric Jain" <[EMAIL PROTECTED] Para: <[EMAIL PROTECTED]> b.ch> cc: (cco: Marcelo Jaccoud Amaral/RJ/Petrobras) Assunto: Re: MIME and DIME 2003-07-04 08:01 Favor responder a axis-user RE: MIME and DIME> MessageContext msgContext = MessageContext.getCurrentContext(); > Message response = msgContext.getResponseMessage(); > response.getAttachmentsImpl().setSendType( > > org.apache.axis.attachments.Attachments.SEND_TYPE_DIME); > > response.addAttachmentPart(response.createAttachmentPart( > new DataHandler(new > FileDataSource(tempFile)))); Thanks, this solves one half of the problem :-) > However, I'm not sure that it is possible to determine which type a > client supports, and thus change the attachment format based on that. This would be important. Does anyone know how to detect .NET clients? Maybe through an HTTP header value? If not, we will have to require a custom SOAP header to be set that specifies the expected attachment type. Ugly... -- Eric Jain
