Delphi Technology Solutions - development, websites, computers and networks

Development   |   Computers & Networks   |   Websites   |   Products & Services   |   Client Success   |   News

David's Ramblings on Development

SharePoint, InfoPath, .Net and more




Programmatically Send Parameters to a Web Service in InfoPath

Share |
clock April 16, 2009 20:26 by author David Lozzi

I wrote a web service that queries the users in certain groups and I bound a dropdown in my InfoPath form to it. The web service requires two values, the site name and the group name. In using the InfoPath Data Connection wizard I specified the values.

We now are looking to move this form to another server (from dev to staging to prod) and this form is going to become the base for about a dozen other forms, so changing this value manually every time will become a hassel at best.

I figured out how to update the webservice from the code behind, and send it the values I want to send it. Very effective and useful.

IMPORTANT First thing though, you need to stop the web service data connection from getting values on start up. That option is in the last screen of the data connection wizard.

Then, in the Form_Load use the similar code as below and blamo, you're off and running.

WebServiceConnection webservConn = (WebServiceConnection)DataConnections["ListGroupUsers"];

XmlDocument inputDoc = new XmlDocument();

inputDoc.LoadXml("<ListGroupUsers xmlns=\"http://site/\"><SiteURL>" + SPContext.Current.Web.Url + "</SiteURL><GroupName>Site Members</GroupName></ListGroupUsers>");

XPathNavigator inputNav = inputDoc.CreateNavigator();

XmlDocument outputDoc = new XmlDocument();

XPathNavigator outputNav = outputDoc.CreateNavigator();

XmlDocument errorDoc = new XmlDocument();

XPathNavigator errorNav = errorDoc.CreateNavigator();

//Need to specify the XPath to dump the results into, so grab the Web Service repsonse

XPathNavigator root = MainDataSource.CreateNavigator();

XPathNavigator node = root.SelectSingleNode("/dfs:myFields/dfs:dataFields/tns:ListGroupUsersResponse/tns:ListGroupUsersResult", NamespaceManager);

webservConn.Execute(inputNav,node,errorNav);

Hope this helps!





SharePoint Designer is Free!

Share |
clock April 13, 2009 18:32 by author David Lozzi

Microsoft announced March 30 that SharePoint Designer 2007 is now a free download!

http://office.microsoft.com/en-us/sharepointdesigner/HA103607611033.aspx

SharePoint Designer is a great tool for easy customizations of your existing SharePoint sites. You can make simple workflows, cross site data shares and customize the look and feel of the site.

 




RSSRSS Subscribe

About David Lozzi

I love what I do. I'm not the sketchy type that hides in his basement coding all day. I have a beautiful wife and two great children. I've spent my last 10 years plus in the technology arena. more...

Login