views:

627

answers:

3

I'm trying to consume a SharePoint webservice from Coldfusion via cfinvoke('cause I don't want to deal with(read parse) the SOAP response itself).

The soap response includes a byte-order-mark character(BOM), which produces the following exception in 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."

The standard for UTF-8 encoding optionally includes the BOM character (http://unicode.org/faq/utf_bom.html#29). Microsoft almost universally includes the BOM character with UTF-8 encoded streams . From what I can tell there’s no way to change that in IIS. The XML parser that JRUN (ColdFusion) uses by default doesn’t handle the BOM character for UTF-8 encoded XML streams. So, it appears that the way to fix this is to change the XML parser used by JRUN (http://www.bpurcell.org/blog/index.cfm?mode=entry&entry=942).

Adobe says that it doesn't handle the BOM character(see comments from anoynomous and halL on May 2nd and 5th).
http://livedocs.adobe.com/coldfusion/8/htmldocs/Tags_g-h_09.html#comments

A: 

It sounds like ColdFusion is using Apache Axis under the covers.

This doesn't apply exactly to your solution, but I've had to deal with this issue once before when consuming a .NET web service with Apache Axis/Java. The only solution I was able to find (since the owner of the web service was unwilling to change anything on his end) was to write a Handler class that Axis would plug into the pipeline which would delete the BOM from the message if it existed.

So perhaps it's possible to configure Axis through ColdFusion? If so you can add additional Handlers to the message handling flow.

matt b
+1  A: 

I'm going to say that the answer to your question (is it possible?) is no. I don't know that definitively, but the poster who commented just above halL (in the comments on this page) gave a work-around for the problem -- so I assume it is possible to deal with when parsing manually.

You say that you're using CFInvoke because you don't want to deal with the soap response yourself. It looks like you don't have any choice.

Adam Tuttle
+1  A: 

As Adam Tuttle said already, the workaround is on the page that you linked to

<!--- 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>
Dan Cramer