Section 7.7.Link a Form to a Web Service


7.7. Link a Form to a Web Service

Another way to use a shared data source with InfoPath is to link the form to a web service. You can't just use any web service with InfoPath. If you try to use the Amazon or Google web services, for example, you'll get the error shown in Figure 7-34.

Figure 7-34. InfoPath rejecting an RPC-encoded web service


The InfoPath SDK installs these examples that demonstrate how to write a web service that can be used by InfoPath forms:

  • localhost/infopathsdk/infopathwebservicesample/infopathwebservicesample.asmx

  • localhost/infopathsdk/DataSubmit/SubmitService.asmx


Note: Web services provide a way to link InfoPath forms to non- Microsoft databases.

Tip: To install the InfoPath SDK web service examples locally, you must be running Windows XP Pro with IIS installed.

7.7.1. How to do it

The SDK has pretty good instructions on how the sample web services work and how to use them from InfoPath. I won't repeat those here, but to make your life a little easier, I've installed those services at www.mstrainingkits.com/Excel and modified the sample forms to work with that location. This means that you can run the samples without installing the SDK (Figure 7-35).

Figure 7-35. SDK web service sample (modified)


In addition to changing the data source for the web service sample, I also:

  • Changed the query view to be the default view displayed when the form is loaded.

  • Combined the query and data views to simplify the interface; in some cases, performing a query didn't automatically display the data view in the SDK sample.

  • Removed the Submit item from the File menu, because the sample didn't actually submit changes to orders, and leaving the Submit item there seemed misleading.

7.7.2. How it works

The SDK sample uses the InfoPathWebServiceSample.asmx web service as both a primary data source (to get the Order records) and as a secondary data source (to populate the Employee Name drop-down list).

In this sample, the web service functions as an interface to the Northwind database (renamed infnwind.mdb, in this case). This approach allows developers to link forms to any type of data store, including Oracle or MySQL databaseswhich aren't directly supported by InfoPathand to access those data stores remotely over the Internet.

It requires a fair amount of knowledge to create a web service, and there are some excellent books devoted to the subject.

7.7.3. What about...

ToLook here
Download the InfoPath SDKSearch www.microsoft.com/downloads for "InfoPath SDK"
Learn more about creating and using web services with InfoPath msdn.microsoft.com/office/understanding/infopath/devdocs/default.aspx




    Excel 2003 Programming. A Developer's Notebook
    Excel 2003 Programming: A Developers Notebook (Developers Notebook)
    ISBN: 0596007671
    EAN: 2147483647
    Year: 2004
    Pages: 133
    Authors: Jeff Webb

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net