Examining the Web Service for the Web Service Developer Sample Form [InfoPath 2003 SDK Documentation]

Applies to:

Microsoft Office InfoPath 2003

Microsoft Office InfoPath 2003 Service Pack 1

For information on a new capability in Service Pack 1 that allows you to connect forms to Web services that receive data from and submit data to ADO.NET datasets, see About ADO.NET dataset integration in the InfoPath Developer's Reference.

To design Microsoft Office InfoPath forms that access an XML Web service, you should first understand how a Web service works. Examining a sample Web service and rebuilding the Web Service developer sample form can help you better understand the issues and processes involved in using InfoPath with a Web service. The following sections guide you through viewing the sample Web service with Microsoft Internet Information Services (IIS), viewing the Web service Help page, and using the Web Services Description Language (WSDL), all in preparation for building the Web Service developer sample form. Available methods and design plans using these methods are also discussed.

The sample XML Web service installed with the Microsoft Office InfoPath 2003 Software Development Kit may be used on the local machine or accessed remotely. You can use a Web browser to view the Web service description and the public methods available.

Viewing the sample Web service with IIS

When the InfoPath SDK is installed and configured, the sample Web service is installed in the Internet Information Services (IIS) Web server. Follow these steps to check the sample Web service with IIS.

Note   This procedure assumes you are using Microsoft Windows XP Professional or Windows Server 2003, and you have IIS installed.

  1. From the Windows Start menu, open Control Panel, and then double-click Administrative Tools.
  2. Double-click Internet Information Services.
  3. In the Internet Information Services folder tree, expand the folders for the local computer, the Web Sites directory, and the Default Web Site. You should see the InfoPathSDK virtual directory, which contains the InfoPathWebServiceSample virtual directory; within this directory is a representation of the files for the sample Web service.

The Default Web Site of the local machine is typically located in the <drive>:\Inetpub\wwwroot directory. A virtual directory is set up so that the files do not have to be located in the wwwroot directory, but the Web is still managed by IIS. The InfoPath SDK Web service files are installed by default in <drive>:\Program Files\Microsoft Office 2003 Developer Resources\Microsoft Office InfoPath 2003 SDK\Samples\WebSvc\server, and the IIS InfoPathWebServiceSample virtual directory is mapped there.

The InfoPath SDK Samples Setup has security permissions that enable the sample Web service to modify the database. You may need to check the permissions if you move the Web service to a different virtual directory when you rebuild the sample form. Follow these steps to review the permissions for the Web Service developer sample form:

  1. To review permissions in IIS, right-click InfoPathWebServiceSample, and then click Properties on the shortcut menu. On the Virtual Directory tab, the Read and Write check boxes are selected, and the Execute Permissions list box shows Scripts only.

    For IIS 6.0 in Windows Server 2003, the Application pool list box should be set to DefaultAppPool. The default user for that application pool is the local Network Service.

  2. To see the properties of the directory where the Web service database is located, navigate to <drive>:\Program Files\Microsoft Office 2003 Developer Resources\Microsoft Office InfoPath 2003 SDK\Samples\WebSvc\, open the properties dialog box for the server directory, and make sure the Read-only check box is cleared on the General tab. Click the Security tab to check permissions for the user and group names. To allow the Web Service sample form to access the server directory, add the group, Everyone, and enable write permission for this group.

    Caution  Adding the group, Everyone, is not recommended for deployment, but only to allow the Web Service sample form to access the sample database. To work with your own Web services and databases, customize the group and user permissions for your specific IIS and database server setup.

    In Windows XP, note that the ASP.NET Machine Account is included with the permissions check boxes selected for Modify, Read & Execute, List Folder Contents, Read, and Write. The Launch IIS Processes Account should also be included, with the same permissions check boxes selected, except that the Modify check box may be cleared for this account.

    In Windows Server 2003, you must add the IIS Worker Process Group, with the same permissions as in Windows XP. This group includes the local NT Authority\Network Service user. Click Add, and then select the local system name (the computer name) for the Location in which to search for the user. Enter IIS_WPG, and then click Check Names. The group [system name]\IIS_WPG should then be added.

Note  If you receive a SOAP error that says, in part, "Operation must use an updatable query" when you try to submit a change in the Shipped Date field, permissions for the IIS virtual directory or the database directory might not be set correctly. If the IIS or ASP.NET processes cannot write to the database, they cannot perform an update.

Viewing the Web service Help page with a Web browser

Address Barlocalhost

You will see the title InfoPathWebServiceSample in the browser, with a description of the three operations (methods) exposed by the Web service and a link to a details page for each operation: getEmployees, updateOrders, and getOrders. The details pages include a description of the Simple Object Access Protocol (SOAP) request and response.

It is not necessary in this sample form to be concerned with creating a valid XML SOAP request, or with parsing the response. InfoPath handles the SOAP communication with a Web service. For an example of how to programmatically create a SOAP request, see

Visit About the Data Submission Developer Sample Form

Using the WSDL schema

The Service Description link on the InfoPathWebServiceSample page returns a page from the Web server that shows the formal definition of the Web service. The definition conforms to the schemas for SOAP and the Web Service Description Language (WSDL), and includes the XML schema within the <types> tag. The URL of the WSDL schema is http://localhost/infopathsdk/infopathwebservicesample/infopathwebservicesample.asmx?WSDL.

The following sample from the WSDL describes the getOrders method. This is the description that is displayed in InfoPath design mode when you select a Web service operation in the Data Source Setup Wizard.

<operation name="getOrders">
   <documentation>Given an EmployeeID returns all orders submitted by that Employee.
      Orders' list is return as OUT parameter. 
      Method's return value is used to return error messages.
   </documentation>
   <input message="s0:getOrdersSoapIn" />
   <output message="s0:getOrdersSoapOut" />
</operation>

Planning the sample form

As you begin to plan the sample form, learning about the methods and data available from the Web service will help you to determine your choice of data sources for the controls placed on the form. Use the browser to examine the Web service Help and WSDL pages, as described previously.

The getEmployees method

<soap:Body>
   <getEmployeesResponse xmlns="http://tempuri.org/">
   <getEmployeesResult>string</getEmployeesResult>
      <employees>
         <Employee>
            <EmployeeID>int</EmployeeID>
            <Firstname>string</Firstname>
            <Lastname>string</Lastname>
            <Fullname>string</Fullname>
         </Employee>
         [more Employee records...]
      </employees>
   </getEmployeesResponse>
</soap:Body>

Design Plan

Use a Query view with a drop-down list box control that is populated by the employee names when the form is opened.

The getOrders method

getOrdersgetEmployeesgetOrders

<soap:Body>
   <getOrders xmlns="http://tempuri.org/">
      <employeeID>int</employeeID>
   </getOrders>
</soap:Body>

Design Plan

Include a Query button control in the Query view that sends the employeeID parameter obtained in the list box selection to the getOrders method. Then open an Order Information view with the order data returned in the getOrders method response. InfoPath handles this nearly automatically. For the Order Information view, use a repeating section for the repeating orders group, containing a table to hold the individual order fields.

Note  As you can see in the WSDL description, the getOrders method simply returns data—it does not accept changed data and update the server's database. To do that, you would need to use the updateOrders method.

The updateOrders method

updateOrdersupdateOrdersShipped Date

Design Plan

Include a button control in the Order Information view that submits changed data to the updateOrders method.