-
Notifications
You must be signed in to change notification settings - Fork 38.5k
Add support for MediaType for EDIFACT and EDI-X12 [SPR-14707] #19272
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Brian Clozel commented There are many media types out there, and our Note that some of those aren't even listed in the In your case, you can create your own instance like this: MediaType EDIFACT = new MediaType("application", "edifact"); Are there Java open source libraries already supporting that format? |
Dawud Tan (陳大衛) commented well, AFAIK, this MIME type is in very common use on the B2B environment such as retailers and its suppliers like between WalMart, Amazon and SlimFast as their supplier, following are their corresponding guide Walmart Getting Started with EDI Implementation Guide, Amazon EDI Self Service Setup guide, but they transfer this file format using EDIINT AS2 (RFC 4130), but I hardly to find a solution that already integrate this AS2 protocol into spring. So, I would like to exchange this file format with my trading partner using spring mvc instead, that offer a lot of flexibility. AFAIK there is one Java open source library already supporting this format that is dependencies {
compile 'org.milyn:milyn-smooks-edi:1.4'
compile 'org.milyn.edi.unedifact:d01b-binding:1.4'
} since the time I post this jira ##19272 I've tried to implement this EDIFACTHttpMessageConverter, following is my naive implementation: package org.springframework.http.converter.edifact;
import org.milyn.edi.unedifact.d01b.D01BInterchangeFactory;
import org.milyn.smooks.edi.unedifact.model.UNEdifactInterchange;
import org.springframework.http.HttpInputMessage;
import org.springframework.http.HttpOutputMessage;
import org.springframework.http.MediaType;
import org.springframework.http.converter.AbstractHttpMessageConverter;
import org.springframework.http.converter.HttpMessageNotReadableException;
import org.springframework.http.converter.HttpMessageNotWritableException;
import org.xml.sax.SAXException;
import java.io.IOException;
import java.io.OutputStreamWriter;
public class EDIFACTHttpMessageConverter extends AbstractHttpMessageConverter<UNEdifactInterchange> {
private D01BInterchangeFactory factory;
public EDIFACTHttpMessageConverter() {
//https://tools.ietf.org/html/rfc1767
super(new MediaType("application", "EDIFACT"));
try {
this.factory = D01BInterchangeFactory.getInstance();
} catch (IOException | SAXException ex) {
ex.printStackTrace();
}
}
@Override
protected UNEdifactInterchange readInternal(Class<? extends UNEdifactInterchange> clazz,
HttpInputMessage inputMessage) throws IOException, HttpMessageNotReadableException {
return factory.fromUNEdifact(inputMessage.getBody());
}
@Override
protected boolean supports(Class<?> clazz) {
return true;
}
@Override
protected void writeInternal(UNEdifactInterchange interchange,
HttpOutputMessage outputMessage) throws IOException, HttpMessageNotWritableException {
factory.toUNEdifact(interchange, new OutputStreamWriter(outputMessage.getBody(), "UTF-8"));
}
} lastly I've push my sample Spring Boot Project into following Github repository, please if you don't mind could you take a look at it Mr. Brian Clozel
|
Brian Clozel commented I'm not saying this is not a valid use case - in fact, creating your own message converter implementation is a good place to start - you could even open source it as a library. There are probably a few things to improve in your message converter implementation (adding some test coverage, implementing the For now, we really have to find the right balance in Spring. We can't just implement message converters for all formats out there, we have to focus our efforts on things that are hard/tedious to implement and very useful to the community. Judging from your initial implementation and the lack of community feedback on that format in the last years, I'd say this is not a good candidate for now. We will reconsider this (and reopen this issue) when those conditions are met. Thanks! |
Dawud Tan (陳大衛) commented I'm Sorry if my words sounds rude, but, honestly I'm really rarely interact with foreign people in my country :( , so I have no idea when certain words have negative emotions. Well thanks a lot for your feedback Brian Clozel, and thanks for reminds me of something that hard/tedious to implement and very useful to the community. I just wonder why AS2 (RFC 4130) protocol that widely used by large companies like WalMart and Amazon got very little attention from community, but apperently Josh Long had ever made an issue for AS2 support in spring in this issue #SESIA-17, and I also did a search for JSR that ever mention this protocol then I found JSR 67: JavaTM APIs for XML Messaging 1.0, but I'm just not sure what the big picture is, however. thanks again for your time Brian Clozel. |
Dawud Tan (陳大衛) opened SPR-14707 and commented
Currently, there are no support for the MIME type application/EDIFACT and application/EDI-X12, these MIME types are the most used in B2B environments, after that we could add support for EDIFACTHttpMessageConverter same as ProtobufHttpMessageConverter ##10477.
thanks.
Affects: 4.3.3
Reference URL: https://tools.ietf.org/html/rfc1767
The text was updated successfully, but these errors were encountered: