Secondary Data Source Web Service Parameters using C# at Runtime in InfoPath
page 2 of 3
by Michelle Beall
Average Rating: 
Views (Total / Last 10 Days): 23625/ 23

Setting up the Example

In this example, assume you want to call a web service and pass in a single parameter supplied by the user at runtime.  You have a textbox on the form called wsParam1.  You also have a drop down list which is populated using a secondary data source.  You want to populate the drop down dynamically based on the entry made by the user in the textbox (or any other control for that matter) while the user is entering data into the form.


To start you create a new InfoPath project in Visual Studio.  In the InfoPath IDE add a text box and a drop down list with the following properties:


Text Box Name wsParam1
Data Type Text (string)
Drop-Down List Box Name field2
Data Type Text (string)
List box entries Lookup values in a data connection to the database, Web service, file, or SharePoint library or list


Click on the Add… button for the Drop-Down List Box Data Connection and follow the wizard.  In the final step ensure that the Automatically retrieve data when form is opened checkbox is unchecked.  Set the value and display name of the drop-down list box from the result set returned by the web service.


The stage is set and we’re ready to do some coding.  We now need to use an event handler to call the web service when a user enters data into the text box.  To access the event handler reopen the text box properties dialog.


View Entire Article

User Comments

Title: Managed Code Question   
Name: Keith B
Date: 2005-02-06 1:19:33 AM
So far, all of my infopath developement has used Jscript, and the SP1 SDK provides some very useful JScript routines such as sorting an xml document object, etc. If I used managed code such as C#, or, will I need to re-create that Jscript funtionality, or can I use Jscript along with the managed code?
Title: Which Web Service does this example use?   
Name: Keith B
Date: 2005-02-06 1:15:29 AM
Thank you for the tutorial. I'm a newbie as far as Web Services are concerned. Here are some questions:
1) Your tutorial specifies a web service running under IIS 6.0. Why is that important? There are many online web services and some are not running under IIS 6.0. How would the example need to be different to work with a non-IIS 6.0 Web site?

2) I cannot find any reference in the tutorial to a specific web service. Probably, I do not know enough about Web Services to identify what aspects of the code relate to a specific web service. I guess another form of this question would be: If I followed the tutorial exactly and pasted your code from the code examples. Which web service would I be accessing when I run the example? Or, what do I need to do to provide the web service that this example uses?

Thanks again for creating this tutorial.
Title: Secondary Data Source Web Service Parameters using C# at Runtime in InfoPath   
Name: Anbukannan
Date: 2004-08-24 5:04:16 AM
It would be help for a web service newbie like me if this article covers abt writing web service bound as the secondary data source

Product Spotlight
Product Spotlight 

Community Advice: ASP | SQL | XML | Regular Expressions | Windows

©Copyright 1998-2024  |  Page Processed at 2024-07-23 5:40:45 PM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search