ColdFusion/Sharepoint Integration - Part 1 - Authenticating

I've been working a bit with Sharepoint lately for some team sites at work and needed a way to dynamically manage some user lists for a given site. Since Sharepoint has a pretty extensive API for interacting with the various bits I figured it would be pretty simple to create a scheduled task in ColdFusion that would pull a list of valid userid from my database and pass the list to Sharepoint to keep the authentication up to date without much intervention on my behalf.

Turns out it wasn't quite all that simple to even connect to the Sharepoint service. My attempts at setting/passing my NT credentials on the webservice call kept resulting in a 401 (Unauthorized) response from the service. Eventually I came across this post from Tom Jordahl that presented a fix. Let me quote Tom's post since he does a good job explaining:

Someone asked me how they could turn on NT Authentication for web service using Apache Axis (the web service used by ColdFusion). By default Axis uses its own HTTP client code, org.apache.axis.transport.http.HTTPSender, to send the XML/SOAP POST requests to a web service. This uses HTTP 1.0 and generally works file.

Axis also supports the Jakarta Commons HTTPClient library, and has since 1.0. To configure Axis to use this instead of its own library you must edit the client-config.wsdd file used by Axis. It gets found on the classpath and generally you don't actually have one and the one built in to axis.jar gets used. The interesting line is the http transport. To switch Axis to use the HTTPClient jar, you would change this:

<transport name="http" pivot="java:org.apache.axis.transport.http.HTTPSender"></transport>
To this:
<transport name="http" pivot="java:org.apache.axis.transport.http.CommonsHTTPSender"></transport>
Once you have this code configured, Axis will use the HTTPClient library for it HTTP needs. Since the HTTPClient library supports NT Authentication, you just set the username/password on the Stub object as you would normally do for (say) Basic Authentication and it will just work. If you are talking to a .NET web service, you are done.

So as he says, I made the change and "it just worked". I can now interact with the Sharepoint user service. Honestly, I haven't done a thing other then confirm that I can now authenticate at this point. Which is why I named this 'Part 1' - because I have a sinking suspicion that my journey to CF/Sharepoint enlightenment will have a few other bumps along the way.

As a side note, I am a bit unhappy that I had to mod the client-config.wsdd file to get this to work. If anyone knows of a simpler workaround please let me know.



Comments
Can you call a sharepoint webservice with CF 7.1? I made the change you suggested but I can't get past an initial error "Could not generate stub objects for web service invocation" which I believe means it is not event getting to the wsdl. I have spent two days trying to find a working snippet of code on the internet for doing ANYTHING with sharepoint from CF. I got nothing. Here is the code that gives me the aforementioned error:


<Cfset ws=createobject("webservice","http://websitename/sites/sitename/_vti_bin/lists.a...
<Cfdump var="#ws#">
# Posted By Steve Hammonds | 5/20/08 5:46 PM
Dumb questions:

Did you try the url directly in your browser to make sure you can view the WSDL?

Did you restart CF after making the change to the config file?
# Posted By todd sharp | 5/21/08 4:00 PM
Yes, I restarted CF. Typing into my browser works fine too except:

From my desktop I do not have to authenticate in the browser. When I do it from the server (local admin logged in, CF running under with another domain users credentials), I do have to autheticate with my domain credentials.

I don't know how to make this authentication happen in my code. The examples I have seen set the username password AFTER creating the webservice. I can't get that far.
# Posted By Steve Hammonds | 5/22/08 1:56 PM
I made this change and there was no difference in my inability to call sharepoint webserives. We need a much much much more detailed explaination of each step required to make this work.
# Posted By Kier Simmons | 6/5/08 12:27 PM
There will be a detailed article in the next edition of FAQU. Make sure you subscribe.
# Posted By todd sharp | 6/5/08 7:07 PM
When does the next issue of FAQU come out? For that matter is it at all possible to get a preview of this "detailed article" being as I've got a project that's due in a week and a half using this integration and I'm having a devil of a time with it?
# Posted By Jenn | 8/7/08 5:30 PM
Jenn:

Check your email.

Todd
# Posted By todd sharp | 8/7/08 9:12 PM
Todd, thanks again for the help. I've got things connecting and calling and returning and that's great. But I've hit another stumper. This blog seems to get better responses than others I've tried, so here's the question. I have to call the "UpdateListItems" method. It appears to take two parameters, first a String and second an XML snippet that contains the information about what to update. Seemed straightforward enough to call it, but it turns out that passing in the correctly formatted XML as the second parameter results in ColdFusion being unable to find the method call. When I generated the stubs and looked at them closely it looks like that second parameter is actually a microsoft object that contains an array of axis message objects. Any idea how you're supposed to pass that? Most of the list manipulation methods take these "XMLNode" input parameters, but passing XML to them does not actually work. I'm at a complete loss.
# Posted By Jenn | 8/8/08 2:44 PM
Steve,
I don't know if you're still following this post or not, but I bet your problem is one that I was having earlier. If the WSDL is actually using NTLM then you can't authenticate against it and you can't get the stubs to generate. To solve the problem access the WSDL from your browser and save it into a folder on your webserver. Then point your CFObject call to the file you've saved on your server. This will let the stubs generate but since the WSDL came off the sharepoint server originally all the method calls will still go to sharepoint. (I can't remember whose blog I found this tidbit on but it sure does work).
# Posted By Jenn | 8/8/08 3:25 PM
Jenn:

Can you email me an example of your call to the service and the error that is being thrown?

Todd
# Posted By todd sharp | 8/8/08 3:48 PM
PS...not sure this makes a difference for your particular problem, but as a general rule I'd suggest using the TCP monitor when working with any web service. It will totally save your sanity sometimes...

http://livedocs.adobe.com/coldfusion/7/htmldocs/ww...
# Posted By todd sharp | 8/8/08 3:51 PM

Calendar

Sun Mon Tue Wed Thu Fri Sat
      1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30       

Subscribe

Enter your email address to subscribe to this blog.

Tags

actionscript ajax blogging cfsnippets coldfusion flash forms flex funny stuff misc model-glue off topic personal project learn slidesix sql

Recent Comments

Editing A Query In A SQL Server DTS Package
JD said: Thanks for your post. Never unlike Microsoft to hide stuff in the hardest part time find. [More]

Mashing Spry Effects With CF8 Ajax Goodness
Mark Pitts said: I have had moderate success implementing Spry Accordian. Sadly the part that does is not working wil... [More]

Chinese Birth Calendar Accuracy Test
Toni Lehman said: This calendar was accurate for both my daughters and 4 grandchildren. I tried it for 11 of my other ... [More]

Virtual Memory - Am I The Last To Know?
Larry Miller said: The authors friend was right. Windows virtual memory system was designed by experts and they fully u... [More]

Using A PlayStation 2 HDD In Your PC
Alacres said: Thanks so much for the guide man! I did have a more specific question though, since I didn't see it ... [More]

RSS


coldfusionbloggers

FullAsAGoog MXNA

Consumed By Feed-Squirrel.com