如何将MTOM附件发送到.NET中的IRS的BulkRequestTransmitter服务

时间:2016-03-16 12:56:51

标签: c# soap mtom irs

我们正在向IRS网站发送数据,以便提交1094 / 1095C表格。要发送此消息,我们已经创建了一个HTTP请求

   HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://la.www4.irs.gov/airp/aca/a2a/1095BC_Transmission_AATS2016");

            request.Headers.Add(HttpRequestHeader.AcceptEncoding, "gzip, deflate");
            request.Headers.Add(HttpRequestHeader.ContentEncoding, "gzip");
            request.Headers.Add("Content-Transfer-Encoding", "8bit");
            request.Headers.Add("SOAPAction", "BulkRequestTransmitter");

            request.Method = "POST";

            request.Headers.Add("MIME-Version", "1.0");
            request.ContentType = "multipart/related; type=\"application/xop+xml;\" boundary=\"" + saperator+ "\";start=\"<root.message@cxf.apache.org>\"; start-info=\"text/xml\"\r\n";
            request.Headers.Add("Content-ID", "<root.message@cxf.apache.org>");
            request.Headers.Add("Payload", "--"+saperator);

并形成了最终请求

--uuid:bb8b365a-f8d6-49f0-9426-192c5408bf0f
        <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:us:gov:treasury:irs:ext:aca:air:7.0" xmlns:urn1="urn:us:gov:treasury:irs:common" xmlns:urn2="urn:us:gov:treasury:irs:msg:acabusinessheader">
          <soapenv:Header xmlns:wsa="http://www.w3.org/2005/08/addressing">
          <wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
          .... signature part
          </wsse:Security>
            <urn:ACATransmitterManifestReqDtl wsu:Id="id-E68EBBF1696C5DD4AA143353323390577" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
            .... Manifest data
            </urn:ACATransmitterManifestReqDtl>
            <urn2:ACABusinessHeader wsu:Id="id-E68EBBF1696C5DD4AA143353323390578" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
            .... Business header 
            </urn2:ACABusinessHeader>
            <wsa:Action>BulkRequestTransmitter</wsa:Action>
          </soapenv:Header>
          <soapenv:Body>
            <urn:ACABulkRequestTransmitter version="1.0">
              <urn1:BulkExchangeFile>
                cid:1094C_Request_[TCCID]_20160312T161033882Z.xml
              </urn1:BulkExchangeFile>
            </urn:ACABulkRequestTransmitter>
          </soapenv:Body>
        </soapenv:Envelope>

        --uuid:bb8b365a-f8d6-49f0-9426-192c5408bf0f
        Content-Type: application/xml
        Content-Transfer-Encoding:7bit
        Content-ID:1094C_Request_[TCCID]_20160315T132809462Z.xml
        Content-Disposition: attachment; name="1094C_Request_[TCCID]_20160315T132809462Z.xml"
        <?xml version="1.0" encoding="UTF-8"?>
        <n1:Form109495CTransmittalUpstream xmlns:n1="urn:us:gov:treasury:irs:msg:form1094-1095Ctransmitterupstreammessage" xmlns="urn:us:gov:treasury:irs:ext:aca:air:7.0" xmlns:irs="urn:us:gov:treasury:irs:common" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:us:gov:treasury:irs:msg:form1094-1095Ctransmitterupstreammessage IRS-Form1094-1095CTransmitterUpstreamMessage.xsd">
          .... Form109495CTransmittalUpstream data
        </n1:Form109495CTransmittalUpstream>
        --uuid:bb8b365a-f8d6-49f0-9426-192c5408bf0f--

但是当我们尝试使用上面的HTTPRequest时,将错误视为

 <?xml version="1.0" encoding="UTF-8"?>
        <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
            <soapenv:Body>
                <soapenv:Fault>
                    <faultcode>soapenv:Server</faultcode>
                    <faultstring>Error in assertion processing</faultstring>
                    <faultactor>ssg</faultactor>
                    <detail>
                        <l7:policyResult
                            status="Multipart stream ended before a terminating boundary was encountered" xmlns:l7="http://www.layer7tech.com/ws/policy/fault"/>
                    </detail>
                </soapenv:Fault>
            </soapenv:Body>
        </soapenv:Envelope>

你对此有什么参考,我们怎么能通过这个?或者如何在.NET中将文件作为MTOM附件发送?

2 个答案:

答案 0 :(得分:0)

我遇到了与我报告IRS ACA SOAP boundary error相同的错误。

尝试添加标题Content-Encoding gzip。我向IRS询问了这个错误。以下是我得到的回复,可能对您有用。

• utf-8 must be in all caps UTF-8 for both the manifest and form data file 

• make sure your Timestamps follow these examples:

EXAMPLE (allow 10 minutes between create and expire:

<wsu:Timestamp wsu:Id="TS-9850525DA06CE28ED91448475206407141"> 

<wsu:Created>2015-11-25T18:13:26.407Z</wsu:Created> 

<wsu:Expires>2015-11-25T18:23:26.407Z</wsu:Expires> 

</wsu:Timestamp>

EXAMPLE:

<urn1:Timestamp>2015-07-09T13:41:09Z</urn1:Timestamp>

答案 1 :(得分:0)

我认为其中一个问题(可能与您正在经历的事情直接相关,也可能没有直接关系),是您的价值

<urn1:BulkExchangeFile>

实际应该是

<xop:Include xmlns:xop="http://www.w3.org/2004/08/xop/include" 
             href="cid:1094C_Request_TCCID_20160312T161033882Z.xml" />