InfoPath 2007 – Calling a WebMethod with parameters

Being new to InfoPath I had to scratch my head for a moment on this one.  The WebMethod simply takes one parameter then returns a list of values to be displayed on the form.  First I went and added a data connection.  This is fairly simple and straight forward.  Then I started looking at some code behind to actually set the parameter for the web method and make the call.
I guess you could say I ended up finding a more InfoPath correct/simple way to go about it.  When designing the InfoPath template open up the "Form Option" dialog by going to the  Tools menu.  On the "Open and Save" item select the "Rules" button under "Open Behaviour".  We are going to add a rule to call the web service on form load.  Add a new rule giving it a meaningful name, add a "Set a field’s value" action to the rule.  When adding the action be sure to select the web service data source and the paramater you want to set from the query fields.  Then select a value for the action.  My value was sourced from the base xml document being loaded.  Now add a "Query data connection" action and select the web service data connection. 
Hit ok and give it a test.  Basically the rule is used to call the web service when loading the form, the first action is setting value that will be used for the parameter in the WebMethod call, and the last action is actually calling the WebMethod.
This entry was posted in InfoPath. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s