将MIME编码的附件发布到Ariba Supplier Network时出现问题 [英] Problem Posting MIME encoded attachment to Ariba Supplier Network

查看:113
本文介绍了将MIME编码的附件发布到Ariba Supplier Network时出现问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在尝试使用VB.NET和WebRequest对象发布一些cXML文本和附件时遇到问题.我相信我正在格式化我要正确发布的数据文本,因为它与Ariba提供的样本匹配.我不确定的是,是否可以正确使用WebRequest对象进行发布.我将方法设置为"POST",将ContentType设置为"multipart/mixed".我可以成功发布cXML(使用ContentType为"text/xml"的内容),因此我知道在常规作品中发布.我从Ariba收到的消息是无法解析文档:缺少起始边界[ANCLS-741552]",但是,如以下代码所示,存在起始边界.我已经删除了一些专有数据,并将其替换为"...".在MIME文本之后,我包括了我正在使用的相关VB.NET代码.

I'm having an issue with trying to use VB.NET and the WebRequest object to post some cXML text and an attachment. I believe I am formatting the text of the data I wish to post correctly, as it matches samples Ariba has supplied. What I am uncertain of is if I am correctly using the WebRequest object to do the posting. I am setting the Method as "POST" and the ContentType as "multipart/mixed". I can successfully post cXML (using a ContentType of "text/xml"), so I know posting in general works. The message I get back from Ariba is "The document could not be parsed: Missing start boundary [ANCLS-741552]", however, as the following code shows, there is a start boundary. I have removed some proprietary data and replaced it with "...". Following the MIME text, I have included the relevant VB.NET code I am using.

任何人和所有建议都将受到欢迎和赞赏!

Any and all suggestions are most welcome and appreciated!

------=_boundary.20100210154837663.173702
Content-Type: text/xml; charset=UTF-8
Content-ID: Part1.5213.20100210154837663.319349

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

------=_boundary.20100210154837663.173702
Content-Type: application/octet-stream
Content-transfer-encoding: base64
Content-ID: 5213.20100210154837663.319349
Content-Disposition: attachment; filename=attachment_20100210154837663_125705.jpg
Content-Length: 5660

/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAkGBwgHBgkIBwgKCgkLDRYPDQwMDRsUFRAWIB0iIiAd
.
.
.
dC2Nz9dOaQ1ZVIilwIpaWvLEg7aWuauv/9k=
------=_boundary.20100210154837663.173702--


Dim myWriter As StreamWriter = Nothing

Dim strUri As String = "https://service.ariba.com/service/transaction/cxml.asp"

Dim WebReq As WebRequest = System.Net.WebRequest.Create(strUri)

WebReq.Method = "POST"
WebReq.ContentType = "multipart/mixed"

myWriter = New StreamWriter(WebReq.GetRequestStream())
myWriter.Write(xmlText)
myWriter.Close()

Dim WebRsp As HttpWebResponse
WebRsp = CType(WebReq.GetResponse(), HttpWebResponse)

推荐答案

比尔-我从Ariba获得了一些信息,并认为这可能对您有用:

Bill - I got some info from Ariba and thought it might be useful to you:

  • 整个有效内容的Content-type声明指定了边界
  • 每个部分前面都有一个'-',后面是边界
  • 文档以'-'结尾,后跟边界,后跟'-'
  • 每个部分的Content-ID用尖括号括起来
  • 在不带尖括号的注释/附件"中的URL元素中引用了附件的Content-ID

也许您可以尝试使用较短的边界字符串.另外,请注意开始"参数.这是为我工作的人:

Maybe you could try with a shorted boundary string. Also, note the 'start' parameter. Here's the one that worked for me:

request.ContentType =  "multipart/related;boundary=outerboundary1;type=""text/xml"";start=""<x.xml>"""

具有上述边界&开始设置如下:

A sample XML with the above boundary & start settings looks like this:

--outerboundary1

Content-Type: text/xml

Content-ID: <x.xml>

<?xml version="1.0"?>

<!DOCTYPE cXML SYSTEM "http://xml.cxml.org/schemas/cXML/1.2.007/InvoiceDetail.dtd">

<cXML payloadID="za1saasxsx" timestamp="2003-04-04" xml:lang="en"><Header><From> 

... 

<Comments>These also use bluetooth<Attachment><URL>cid:xx@cxml.org</URL></Attachment></Comments>

...

</Request></cXML>

--outerboundary1

Content-type: text/plain; charset=US-ASCII

Content-Disposition: attachment; filename=PremiereCatalog.xxx

Content-Length: 4

Content-ID: <xx@cxml.org>

xxxx

--outerboundary1-- 

我知道,如果没有什么帮助,这可能会非常令人沮丧.因此,我知道您是否需要对我有用的完整代码.

I know it can be very frustrating with very little help out there. So lemme know if you need the complete code that worked for me.

普拉文

这篇关于将MIME编码的附件发布到Ariba Supplier Network时出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆