【问题标题】:POST to Ariba via cXML with attachment通过带有附件的 cXML POST 到 Ariba
【发布时间】:2019-07-31 23:54:02
【问题描述】:

我一直通过 cXML 将 NetSuite 中生成的发票发布到 Ariba Supplier Network。最近,我们的一位客户更改为要求所有发票提交都附有 pdf 附件。

我可以从 NetSuite 保存的搜索中获取发票 PDF 的 URL。我可以在附件元素中传递这个 URL 吗?我是否还需要使用 MIME 信封在 Ariba 中创建附件?

这就是我试图通过 POSTMAN 传递的内容。我正在恢复以下状态。

无法解析文档:prolog 中不允许内容。 (第 1 行,第 1 列)[ANCLS-125007011]

Content-Type: multipart/mixed; boundary=RJM4809370DO2978413
--RJM4809370DO2978413
Content-type: text/xml; charset="UTF-8"

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE cXML SYSTEM "http://xml.cxml.org/schemas/cXML/1.2.035/InvoiceDetail.dtd">
<cXML payloadID="IN.DO2978413.20190309110306" 
            <InvoiceDetailRequestHeader invoiceDate="2019-03-09T11:32:55-05:00" 
                <Extrinsic name="invoicePDF">
                    <Attachment>
                        <URL>cid:system.na2.netsuite.com/core/media/media.nl?id=4417380&c=XXXXXX&h=7528d4b175c15c719e89&_xt=.pdf</URL>
                    </Attachment>
                </Extrinsic>
            </InvoiceDetailRequestHeader>
............
</cXML>
--RJM4809370DO2978413
Content-Type: application/pdf
Content-ID:<system.na2.netsuite.com/core/media/media.nl?id=XXXXXX&c=4086366&h=7528d4b175c15c719e89&_xt=.pdf>
Content-Disposition: attachment; filename=11315307.PDF

--RJM4809370DO2978413--

这是原始请求。

POST
https://service.ariba.com/service/transaction/cxml.asp
12:46:10.923

Request Headers:
Content-Type:"Multipart/mixed; boundary="RJM4809370DO2978413";type="text/xml""
cache-control:"no-cache"
Postman-Token:"973410c7-0db8-4140-822c-4ac4dffe3dcd"
User-Agent:"PostmanRuntime/7.6.1"
Accept:"*/*"
Host:"service.ariba.com"
accept-encoding:"gzip, deflate"
content-length:7844
Request Body:"--RJM4809370DO2978413
 Content-Type: text/xml; charset=UTF-8
 Content-Disposition: attachment
 Content-ID: 

 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE cXML SYSTEM "http://xml.cxml.org/schemas/cXML/1.2.035/InvoiceDetail.dtd">
 <cXML payloadID="IN.DO2978413.20190311140375" timestamp="2019-03-11T14:34:19.758Z">
 <Header>
 <From>
 <Credential domain="AribaNetworkUserID">
 <Identity>ariba@XXXXXXX.com</Identity>
 </Credential>
 </From>
 <To>
 <Credential domain="NetworkID">
 <Identity>XXXXXXXXXX</Identity>
 </Credential>
 </To>
 <Sender>
 <Credential domain="AribaNetworkUserID">
 <Identity>ariba@XXXXXX.com</Identity>
 <SharedSecret>XXXXXXXXX</SharedSecret>
 </Credential>
 <UserAgent>Celigo Invoice Request</UserAgent>
 </Sender>
 </Header>
 <Request deploymentMode="production">
 <InvoiceDetailRequest>
 <InvoiceDetailRequestHeader invoiceDate="2019-03-11T14:34:19-05:00" invoiceID="11315307" invoiceOrigin="supplier" operation="new" purpose="standard">
 <InvoiceDetailHeaderIndicator/>
 <InvoiceDetailLineIndicator isAccountingInLine="yes" isTaxInLine="yes" />
 <InvoicePartner>
 <Contact role="remitTo">
 <Name xml:lang="en-US">XXXXXXXXX</Name>
 <PostalAddress>
 <Street>XXXXXXX</Street>
 <Street></Street>
 <Street></Street>
 <City>XXXXXXXX</City>
 <State>XX</State>
 <PostalCode>XXXXXX</PostalCode>
 <Country isoCountryCode="">United States</Country>
 </PostalAddress>
 </Contact>
 <IdReference domain="supplierTaxID" identifier="XXXXXXXX"/>
 </InvoicePartner>
 <InvoicePartner>
 <Contact role="billTo">
 <Name xml:lang="en-US">XXXXXXXXXX</Name>
 <PostalAddress>
 <Street>XXXXXXXXX</Street>
 <Street>XXXXXXXX</Street>
 <City>XXXXXX</City>
 <State>XXX</State>
 <PostalCode>XXXXX</PostalCode>
 <Country isoCountryCode="US">United States</Country>
 </PostalAddress>
 </Contact>
 </InvoicePartner>
 <InvoicePartner>
 <Contact role="soldTo">
 <Name xml:lang="en-US">XXXXXXXX</Name>
 <PostalAddress>
 <Street>XXXXXXXX</Street>
 <Street></Street>
 <City>XXXXXX</City>
 <State>XX</State>
 <PostalCode>XXXXXXXX</PostalCode>
 <Country isoCountryCode="US">United States</Country>
 </PostalAddress>
 </Contact>
 </InvoicePartner>
 <InvoiceDetailShipping>
 <Contact role="shipFrom">
 <Name xml:lang="en-US">XXXXXX</Name>
 <PostalAddress>
 <Street>XXXXXX</Street>
 <Street></Street>
 <Street></Street>
 <City>XXXXXXX</City>
 <State>XXX</State>
 <PostalCode>XXXXXX</PostalCode>
 <Country isoCountryCode="">United States</Country>
 </PostalAddress>
 </Contact>
 <Contact role="shipTo">
 <Name xml:lang="en-US">XXX</Name>
 <PostalAddress>
 <Street>XXXXX</Street>
 <Street></Street>
 <Street></Street>
 <City>XXXXXX</City>
 <State>XXXXXX</State>
 <PostalCode>XXXXXX</PostalCode>
 <Country isoCountryCode=""></Country>
 </PostalAddress>
 </Contact>
 </InvoiceDetailShipping>
 <Extrinsic name="invoicePDF">
 <Attachment>
 <URL>cid:https://system.na2.netsuite.com/core/media/media.nl?id=XXXXXXXXXXXh=7528d4b175c15c719e89&_xt=.pdf</URL>
 </Attachment>
 </Extrinsic>
 </InvoiceDetailRequestHeader>
 <InvoiceDetailOrder>
 <InvoiceDetailOrderInfo>
 <OrderReference orderID="DO2978413">
 <DocumentReference payloadID="1551826564527.841867458.000002574@Hdw2llNIeZN+Ro4D2ATtzEA2KaI&#x3D;"/>
 </OrderReference>
 </InvoiceDetailOrderInfo> 
 <InvoiceDetailItem invoiceLineNumber="1" quantity="2">
 <UnitOfMeasure>EA</UnitOfMeasure>
 <UnitPrice>
 <Money currency="USD">1000.00</Money>
 </UnitPrice>
 <InvoiceDetailItemReference lineNumber="1">
 <ItemID>
 <SupplierPartID>XXXXXX</SupplierPartID>
 </ItemID>
 <Description xml:lang="en">XXXXXX</Description>
 </InvoiceDetailItemReference>
 <Extrinsic name="punchinItemFromCatalog">no</Extrinsic>
 </InvoiceDetailItem> 
 </InvoiceDetailOrder>
 <InvoiceDetailSummary>
 <SubtotalAmount>
 <Money currency="USD">2000</Money>
 </SubtotalAmount>
 <Tax>
 <Money currency="USD">0</Money>
 <Description xml:lang="en-US"/>

 <TaxDetail category="sales">
 <TaxableAmount>
 <Money currency="USD">2000</Money>
 </TaxableAmount>
 <TaxAmount>
 <Money currency="USD">0</Money>
 </TaxAmount>
 <Description xml:lang="en">Sales tax</Description>
 </TaxDetail>
 </Tax>
 <ShippingAmount>
 <Money currency="USD">332</Money>
 </ShippingAmount>
 <GrossAmount>
 <Money currency="USD">2332</Money>
 </GrossAmount>
 <NetAmount>
 <Money currency="USD">2332</Money>
 </NetAmount>

 <DueAmount>
 <Money currency="USD">2332</Money>
 </DueAmount>
 </InvoiceDetailSummary>
 </InvoiceDetailRequest>
 </Request>
 </cXML>
 --RJM4809370DO2978413
 Content-Type: application/pdf
 Content-ID: <https://system.na2.netsuite.com/core/media/media.nl?id=XXXXXXXXXXXX&h=7528d4b175c15c719e89&_xt=.pdf>
 Content-Disposition: attachment; filename=11315307.PDF

 --RJM4809370DO2978413--
 "
Response Headers:
Date:"Mon, 11 Mar 2019 16:46:11 GMT"
Server:"Apache"
Content-Length:"350"
Content-Encoding:"gzip"
Vary:"User-Agent"
Keep-Alive:"timeout=15, max=100"
Connection:"Keep-Alive"
Content-Type:"text/html; charset=UTF-8"
Strict-Transport-Security:"max-age=31536000"

Response Body:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE cXML SYSTEM "http://xml.cxml.org/schemas/cXML/1.2.041/cXML.dtd">

<cXML timestamp="2019-03-11T09:46:11-07:00" payloadID="1552322771952-2933358902296997425@10.162.97.171">

    <Response>

        <Status code="500" text="Internal Server Error">ANERR-110000000000000000345730259:can not have stream of negative length(start 7610, end 7585, original length 7844)</Status>

    </Response>
</cXML>

【问题讨论】:

    标签: xml netsuite sap-ariba


    【解决方案1】:

    cXML 标准指定通过 MIME 信封处理附件。

    一个 MIME 部分是一条常规 cXML 消息,其中包含一个 Attachment 元素作为对第二个 MIME 部分的 Content-ID 标头的引用。

    有关更多详细信息,请参阅cXML Reference Guide 中的第 2.1.5 节。

    【讨论】:

    • 我尽我所能遵循 cXML 参考指南。我添加了我试图通过 POSTMAN 发布的内容以及我正在恢复的状态。
    • 错误说它需要一个 XML 声明,但这里没有。你能检查一下 POSTMAN 生成的 HTTP 请求的实际 RAW 形式吗?我不建议改用curl。它得到了很大的知名度和支持。与您类似的情况是:stackoverflow.com/questions/19178813/…
    • 我设置了Header Content-Type Multipart/mixed;边界 = RJM4809370DO2978413 我现在收到“找到的值:“500”。响应正文:ANERR-110000000000000000345676037:不能有负长度流(开始 7481,结束 7458,原始长度 7742)“
    • @RJM1212016 为了帮助您,我需要查看整个 HTTP 请求。这意味着使用curl -v 或以某种方式在 POSTMAN 中显示 RAW 请求。
    • 添加了原始请求。我删除了所有专有信息。
    【解决方案2】:

    你能像 Yuri 建议的那样逃脱 & 吗?我的声望点只允许我提交作为答案而不是评论:

        cid:https://system.na2.netsuite.com/core/media/media.nl?id=XXXXXXXXXXXh=7528d4b175c15c719e89&amp;_xt=.pdf
    

    【讨论】:

      猜你喜欢
      • 2019-02-20
      • 2014-09-29
      • 1970-01-01
      • 2011-06-08
      • 1970-01-01
      • 1970-01-01
      • 2019-12-18
      • 1970-01-01
      相关资源
      最近更新 更多