Friday, May 17, 2013

Why is my InfoPath form failling to publish as a Site Content Type in SharePoint 2007/2010?

First of all, this assumes you have a form in InfoPath (any version older than 2013, I haven't tested that one), and that you want to publish that form into a SharePoint site as a Content Type.  This is advantageous to the site, because that form can be reused as much as you want in the Site Collection (although they work only so well in Content Type Hubs, the reason being the template XSN file crosses the Site Collection barrier, which is generally a no-no).

BUT:  You need to be careful how you document your content type in the Description box in InfoPath.  Here is where the Office team messed up:  They don't do any encoding or sanitizing of the text in that box before sending it off to the Webs web service in SharePoint (Webs.asmx).  As a result, any XML tags, or HTML tags, or hell, ANY stray double quotes (") or greater-than/less-than symbols (<) (>), will make their way into the call, and gum up the whole works.

The reason this fails is the call to the Webs.asmx service is SOAP, which is pure XML, and the description is sent as an Attribute, not as a text node value.

Here's the real rub, though: if you DO happen to have illegal characters in there, InfoPath won't error out.  Instead it will successfully publish the form to the site, but then prompt for credentials over and over and over again for the web service.  If you're foolish enough to continue clicking Ok you'll eventually lock out your AD account in the process.  When you click Cancel, it will say "Creating the site content type failed."  That's it.  No help at all.  What it should say, instead of prompting at all is "SOAP error" or "400: Bad Request" which is what is actually happening in the background.

What it took to find this little sucker was installing Fiddler on the local machine and watching the traffic going out to the website.  I was seeing HTTP 400 errors when the web calls were being made, and in looking at the RAW SOAP XML request to the service, that's where I saw the Description attribute, and it was invalid, thanks to double quotes in my description.

I lost 4 hours to this error, and had to drag in a sys-admin to help me figure out Fiddler to see the raw data.  I hope this helps someone else...

No comments:

Post a Comment