0

我在通过 IRS A2A AIR 服务发送 1094/1095 文件时遇到问题,并且不断收到 TPE1101 错误。此错误指出“我们的系统在您的消息中检测到无效或过时的 XML 命名空间。请查看位于https://www.irs.gov/e- file-providers/air/affordable-care-act-information-return-air-program,更正任何问题,然后重试。” 我对此文件所做的每一次更改都会导致相同的错误。

该错误涉及命名空间问题,但根据他们的样本和与 IRS 本身的联系,我的命名空间是正确的。我根据出版物 5258 第 5.3.1.4 节中的示例手动创建了 XML 文件。我已经对照 IRS 提供的 .xsd 文件检查了它:IRS-ACABusinessHeaderMessage、IRS-ACASecurityHeaderMessage 和 IRS-CAC。我在这里似乎遇到的唯一问题是 BulkExchangeFile 中的 Include 元素。文档中的示例特别要求的元素。我什至尝试发送一个有明显错误的文件,但我仍然得到同样的错误。

此外,从我们已经通过 UI 通道成功发送的文件中提取 ACABusinessHeader 和 ACATransmitterManifestReqDtl 元素。我已经仔细检查过,它们应该是正确的,所以我认为问题不存在。我们已经为 UI 通道向 IRS 注册了一个证书,并且签名问题存在不同的 TPE 错误,所以我认为这也不是问题。

这是我根据出版物 5258 中的示例手动创建的文件,包括 MIME 边界。显然,所有值都是虚拟数据或占位符,但还有其他 TPE 错误应该指向这些问题。只是我尝试的一切都以 TPE1101 告终。我只是无法弄清楚我错过了什么。

--MIME_boundary
Content-Type: application/xop+xml; charset=UTF-8; type="text/xml"
Content-Transfer-Encoding: 8bit
Content-ID: <rootpart>
    <soapenv:Envelope xmlns:oas1="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"
                      xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
                      xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
                      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                      xmlns:xsd="http://www.w3.org/2001/XMLSchema"
                      xmlns:urn="urn:us:gov:treasury:irs:ext:aca:air:ty20"
                      xmlns:urn1="urn:us:gov:treasury:irs:common"
                      xmlns:urn2="urn:us:gov:treasury:irs:msg:acabusinessheader"
                      xmlns:urn3="urn:us:gov:treasury:irs:msg:acasecurityheader"
                      xmlns:urn4="urn:us:gov:treasury:irs:msg:irsacabulkrequesttransmitter">
        <soapenv:Header xmlns:wsa="http://www.w3.org/2005/08/addressing">
            <urn3:ACASecurityHeader>
                <urn1:UserId>1XXXXX123</urn1:UserId>
            </urn3:ACASecurityHeader>
            <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">
                <ds:Signature Id="SIG-B38D3ED1AED822149F1501078080746278"
                              xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
                    <ds:SignedInfo>
                        <ds:CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-10315#WithComments"/>
                        <ds:SignatureMethod Algorithm="http://www.w3.org/2001/04/xmldsig-e#rsa-sha256"/>
                        <ds:Reference URI="#TS-Eb4799bee41bb4df0a72f52832d283ef7">
                            <ds:Transforms>
                                <ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#WithComments">
                                    <ds:InclusiveNamespaces PrefixList="wsse wsa oas1 soapenv urn urn1 urn2 urn3 urn4"
                                                         xmlns="http://www.w3.org/2001/10/xml-exc-c14n#WithComments"/>
                                </ds:Transform>
                            </ds:Transforms>
                            <ds:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"/>
                            <ds:DigestValue>[TimestampDigestValue]</ds:DigestValue>
                        </ds:Reference>
                        <ds:Reference URI="#id-E5f1ed32aab8f4578adeee5debd851a62">
                            <ds:Transforms>
                                <ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#WithComments">
                                    <ds:InclusiveNamespaces PrefixList="wsa oas1 soapenv urn1 urn2 urn3 urn4"
                                                         xmlns="http://www.w3.org/2001/10/xml-exc-c14n#"/>
                                </ds:Transform>
                            </ds:Transforms>
                            <ds:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"/>
                            <ds:DigestValue>[ACABusinessHeaderDigestValue]</ds:DigestValue>
                        </ds:Reference>
                        <ds:Reference URI="#id-E4a71164001994d7f865fc7ddb8055350">
                            <ds:Transforms>
                                <ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#WithComments">
                                    <ds:InclusiveNamespaces PrefixList="wsa oas1 soapenv  urn1 urn2 urn3 urn4"
                                                         xmlns="http://www.w3.org/2001/10/xml-exc-c14n#"/>
                                </ds:Transform>
                            </ds:Transforms>
                            <ds:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"/>
                            <ds:DigestValue>[ManifestDigestValue]</ds:DigestValue>
                        </ds:Reference>
                    </ds:SignedInfo>
                    <ds:SignatureValue>[SignatureValue]
                    </ds:SignatureValue>
                    <ds:KeyInfo Id="KI-B38D3ED1AED822149F1501078080740274">
                        <wsse:SecurityTokenReference wsu:Id="STR-B38D3ED1AED822149F1501078080740275">
                            <wsse:KeyIdentifier EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security1.0#Base64Binary"
                                                ValueType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3">
                                [KeyIdentifier]
                            </wsse:KeyIdentifier>
                        </wsse:SecurityTokenReference>
                    </ds:KeyInfo>
                </ds:Signature>
                <wsu:Timestamp wsu:Id="TS-Eb4799bee41bb4df0a72f52832d283ef7">
                    <wsu:Created>2021-09-23T14:08:00.732Z</wsu:Created>
                    <wsu:Expires>2021-09-23T14:18:00.732Z</wsu:Expires>
                </wsu:Timestamp>
            </wsse:Security>
            <urn2:ACABusinessHeader wsu:Id="id-E5f1ed32aab8f4578adeee5debd851a62"
                                    xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
                <urn:UniqueTransmissionId>7d432d4a-3acb-44ba-910f-4983527ee7c4:SYS12:XXX0X::T
                </urn:UniqueTransmissionId>
                <urn1:Timestamp>2021-08-23T19:32:20:05:00</urn1:Timestamp>
            </urn2:ACABusinessHeader>
            <urn:ACATransmitterManifestReqDtl wsu:Id="id-E4a71164001994d7f865fc7ddb8055350"
                                              xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
                <urn:PaymentYr>2020</urn:PaymentYr>
                <urn:PriorYearDataInd>0</urn:PriorYearDataInd>
                <urn1:EIN>000000000</urn1:EIN>
                <urn:TransmissionTypeCd>O</urn:TransmissionTypeCd>
                <urn:TestFileCd>T</urn:TestFileCd>
                <urn:TransmitterNameGrp>
                    <urn:BusinessNameLine1Txt>TestBusinessName</urn:BusinessNameLine1Txt>
                </urn:TransmitterNameGrp>
                <urn:CompanyInformationGrp>
                    <urn:CompanyNm>TestBusinessName</urn:CompanyNm>
                    <urn:MailingAddressGrp>
                        <urn:USAddressGrp>
                            <urn:AddressLine1Txt>1700 E Test ROAD</urn:AddressLine1Txt>
                            <urn1:CityNm>New Teston</urn1:CityNm>
                            <urn:USStateCd>IL</urn:USStateCd>
                            <urn1:USZIPCd>60111</urn1:USZIPCd>
                            <urn1:USZIPExtensionCd>0000</urn1:USZIPExtensionCd>
                        </urn:USAddressGrp>
                    </urn:MailingAddressGrp>
                    <urn:ContactNameGrp>
                        <urn:PersonFirstNm>Test</urn:PersonFirstNm>
                        <urn:PersonLastNm>McSmoothie</urn:PersonLastNm>
                    </urn:ContactNameGrp>
                    <urn:ContactPhoneNum>5555556666</urn:ContactPhoneNum>
                </urn:CompanyInformationGrp>
                <urn:VendorInformationGrp>
                    <urn:VendorCd>I</urn:VendorCd>
                    <urn:ContactNameGrp>
                        <urn:PersonFirstNm>Test</urn:PersonFirstNm>
                        <urn:PersonLastNm>McSmoothie</urn:PersonLastNm>
                    </urn:ContactNameGrp>
                    <urn:ContactPhoneNum>5555556666</urn:ContactPhoneNum>
                </urn:VendorInformationGrp>
                <urn:TotalPayeeRecordCnt>23</urn:TotalPayeeRecordCnt>
                <urn:TotalPayerRecordCnt>1</urn:TotalPayerRecordCnt>
                <urn:SoftwareId>00X0000000</urn:SoftwareId>
                <urn:FormTypeCd>1094/1095C</urn:FormTypeCd>
                <urn1:BinaryFormatCd>application/xml</urn1:BinaryFormatCd>
                <urn1:ChecksumAugmentationNum>A56148301135815266BF66792CDEB607F45C7430D81C9B3568C8044DCBE3C86A</urn1:ChecksumAugmentationNum>
                <urn:AttachmentByteSizeNum>71770</urn:AttachmentByteSizeNum>
                <urn:DocumentSystemFileNm>1094C_Request_XXX0X_20210824T053220854Z.xml</urn:DocumentSystemFileNm>
            </urn:ACATransmitterManifestReqDtl>
            <wsa:Action>BulkRequestTransmitter</wsa:Action>
        </soapenv:Header>
        <soapenv:Body Id="BodyRefID">
            <urn4:ACABulkRequestTransmitter version="1.0">
                <urn1:BulkExchangeFile>
                    <inc:Include href="cid:Test.xml"
                                 xmlns:inc="http://www.w3.org/2004/08/xop/include"/>
                </urn1:BulkExchangeFile>
            </urn4:ACABulkRequestTransmitter>
        </soapenv:Body>
    </soapenv:Envelope>
    --MIME_boundary
    Content-Type: text/xml; charset=UTF-8
    Content-Transfer-Encoding: 7bit
    Content-ID: <Test.xml>
        Content-Disposition: attachment; name="BaseAttachment.xml"
        <?xml version="1.0" encoding="utf-8"?>
        <Form109495CTransmittalUpstream xmlns:xsd="http://www.w3.org/2001/XMLSchema"
                                        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                                        xmlns="urn:us:gov:treasury:irs:msg:form1094-1095Ctransmitterupstreammessage">
            Form1094CUpstreamDetails...
        </Form109495CTransmittalUpstream>
----MIME_boundary

这是我实际发送文件的 C# 代码。

public void SendFiletoIRS()
        {
            var sendingFile = $"C:\\IRSACAA2AFile.xml";
            byte[] byteFile = File.ReadAllBytes(sendingFile);

            byte[] zippedFile = null;
            
            //GZip the file
            using (System.IO.MemoryStream outputStream = new System.IO.MemoryStream())
            {
                using (System.IO.Compression.GZipStream gzip = new System.IO.Compression.GZipStream(outputStream, System.IO.Compression.CompressionMode.Compress))
                {
                    gzip.Write(byteFile, 0, byteFile.Length);
                    gzip.Flush();
                    gzip.Close();
                    zippedFile = outputStream.ToArray();
                }
            }

            //Transmit file
            string serviceAddress = "https://la.www4.irs.gov/airp/aca/a2a/1095BC_Transmission_AATS";

            try
            {
                HttpWebRequest request = (HttpWebRequest)WebRequest.Create(serviceAddress);
                
                //Add additional headers
                request.ContentType = "multipart/related; type=\"application/xop+xml\"; start=\"<rootpart>\"; start-info=\"text/xml\"; boundary=\"--MIME_boundary\"";
                request.ContentLength = zippedFile.Length;
                request.Method = "POST";
                request.KeepAlive = true;
                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.Headers.Add("MIME-Version", "1.0");
                request.Host = "la.www4.irs.gov";

                //Get IRS response
                using (Stream requestStream = request.GetRequestStream())
                {
                    requestStream.Write(zippedFile, 0, zippedFile.Length);
                    requestStream.Flush();
                    requestStream.Close();
                }

                HttpWebResponse response = (HttpWebResponse)request.GetResponse();
                if (response.StatusCode == HttpStatusCode.OK)
                {
                    Stream responseStream = response.GetResponseStream();
                    var responseString = new StreamReader(responseStream).ReadToEnd();
                    responseStream.Close();
                }                
            }
            catch(WebException ex)
            {
                using (StreamReader reader = new StreamReader(ex.Response.GetResponseStream()))
                {
                    var temp = reader.ReadToEnd();
                }
            }
        }

最后,这是我从 IRS 得到的完整错误响应。

<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
    <soapenv:Body>
        <soapenv:Fault>
            <faultcode>soapenv:Client</faultcode>
            <faultstring>Our system detected invalid or outdated XML namespaces in your message. Please review the XML standards outlined in Section 3 of Publication 5258, AIR Submission Composition and Reference Guide, located at https://www.irs.gov/e-file-providers/air/affordable-care-act-information-return-air-program, correct any issues, and try again.</faultstring>
            <detail>
               <errorcode>TPE1101</errorcode>
               <uniqueTransmissionID/>
            </detail>
    </soapenv:Body>
        </soapenv:Fault>
</soapenv:Envelope>
4

0 回答 0