我们正在向 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 附件发送?