问题描述
我正在尝试通过WCF将SOAP消息发送给IRS,但由于我的MTOM附件格式错误,它一直被拒绝.
I am trying to send a SOAP message via WCF to the IRS, and it keeps getting rejected because my MTOM attachment is formatted incorrectly.
我已将问题缩小到我的Content-Transfer-Encoding
值.它设置为Binary
(8-bit
的简写).
I've narrowed down the issue to my Content-Transfer-Encoding
value. It is set to Binary
(shorthand for 8-bit
).
IRS服务希望我使用带有8位编码附件的7-bit
(换句话说,请使用UTF-8进行编码,然后确保我没有使用任何非ASCII字符).
The IRS service wants me to use 7-bit
, with an 8-bit-encoded attachment (in other words, encode with UTF-8 and then guarantee that I'm not using any non-ASCII characters).
我已经在使用自定义消息编码器来gzip我的请求(响应以纯文本形式返回,back).这就是我的WriteMessage
现在的样子.
I'm already using a custom message encoder in order to gzip my requests (responses come back plain-text, ugh). This is what my WriteMessage
looks like right now.
public override ArraySegment<byte> WriteMessage(Message message, int maxMessageSize, BufferManager bufferManager, int messageOffset) {
// get an instance of the underlying encoder
var encoder = new MtomMessageEncodingBindingElement() {
MessageVersion = MessageVersion.Soap11WSAddressing10,
WriteEncoding = System.Text.Encoding.UTF8
}.CreateMessageEncoderFactory().Encoder;
// write the message contents
var uncompressed = encoder.WriteMessage(message, maxMessageSize, bufferManager, messageOffset);
// compresses the resulting byte array
return CompressBuffer(uncompressed, bufferManager, messageOffset);
}
有什么想法吗?当我将WriteEncoding
属性更改为ASCII或UTF7时,.NET抛出ArgumentException并告诉我该格式不受支持.
Any ideas? When I change the WriteEncoding
property to ASCII or UTF7 .NET throws an ArgumentException and tells me the format is not supported.
推荐答案
我将Java Apache CXF和WSS4J用于IRS解决方案,但是如果收到此错误,则消息的格式不正确和/或无法解释请查阅位于 https://www.irs.gov/for-Tax-Pros/Software-Developers/Information-Returns/Affordable-Care-Act-Information -返回Air-Program ,更正所有问题,然后重试."这是因为IRS期望这样做:
I am using Java Apache CXF and WSS4J for the IRS solution, but if you are getting this error "The message was not formatted properly and/or cannot be interpreted. Please review the XML standards outlined in Section 3 of the AIR Submission Composition and Reference Guide located at https://www.irs.gov/for-Tax-Pros/Software-Developers/Information-Returns/Affordable-Care-Act-Information-Return-AIR-Program, correct any issues, and try again." it is because the IRS is expecting this:
Content-Type: application/xml
Content-Transfer-Encoding: 7bit
Content-ID: <6920edd2-a3c7-463b-b336-323a422041d4-1@blahurn:us:gov:treasury:irs:common>
Content-Disposition: attachment;name="1094B_Request_BBBBB_20151019T121002000Z.xml"
这篇关于通过具有MTOM和Content-Transfer-Encoding的WCF发送SOAP消息:7位的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!