2008-09-11 45 views
2

我想通过cfinvoke(因为我不想处理(读取:解析)SOAP响应本身)从ColdFusion消费SharePoint webservice。物料清单预计在CF但由IIS/SharePoint发送

的SOAP响应包括字节顺序标记字符(BOM),其产生以下异常在CF:

"Cannot perform web service invocation GetList. 
The fault returned when invoking the web service operation is: 
'AxisFault 
faultCode: {http://www.w3.org/2003/05/soap-envelope}Server.userException 
faultSubcode: 
faultString: org.xml.sax.SAXParseException: Content is not allowed in prolog." 

为UTF-8编码的标准任选包括BOM字符(http://unicode.org/faq/utf_bom.html#29)。 Microsoft几乎普遍包含具有UTF-8编码流的BOM字符。从我所能告诉的是,无法在IIS中更改它。 JRun(ColdFusion)默认使用的XML解析器不处理UTF-8编码的XML流的BOM字符。所以,解决这个问题的方法似乎是更改JRun使用的XML解析器(http://www.bpurcell.org/blog/index.cfm?mode=entry&entry=942)。

Adob​​e表示它不处理BOM字符(请参阅5月2日和5日的来自anoynomous和halL的评论)。
http://livedocs.adobe.com/coldfusion/8/htmldocs/Tags_g-h_09.html#comments

+0

我有完全相同的问题,使用WebSphere 6.1 Web服务的页面上。 – djangofan 2012-05-31 18:12:39

回答

2

我要说的是,你的问题的答案(是否有可能?)是否定的。我不知道这个问题,但是评论刚刚超过halL(in the comments on this page)的海报解决了这个问题 - 所以我认为可以在手动解析时处理。

你说你正在使用CFInvoke,因为你不想自己处理肥皂响应。看起来你没有任何选择。

0

听起来好像ColdFusion正在使用Apache Axis。

这并不适用于您的解决方案,但在使用Apache Axis/Java使用.NET Web服务之前,我不得不处理此问题。我找到的唯一解决方案(因为Web服务的所有者不愿意改变任何事情)是编写一个Axis将插入到管道中的Handler类,如果该消息存在,则会从消息中删除BOM。

所以也许有可能通过ColdFusion配置Axis?如果是的话you can add additional Handlers to the message handling flow

2

正如亚当·塔特尔已经说了,解决办法是,你链接到

<!--- Remove BOM from the start of the string, if it exists ---> 
<cfif Left(responseText, 1) EQ chr(65279)> 
<cfset responseText = mid(xmlText, 2, len(responseText))> 
</cfif>