Designing a Template to Connect to a Web Service

 < Day Day Up > 

In the examples you have seen so far in this chapter, we had the benefit of Web service samples, which are located at a known URL and also prebuilt form templates to connect to the Web service's URL. Life won't always be so convenient , and we will need to locate a Web service online for which we want to design a form template.

InfoPath 2003 uses the Data Source Setup Wizard to connect to existing XML Web Services or to allow discovery of XML Web Services. To try it, follow these steps:

  1. Open the Design a Form task pane. In the Design a New Form section, select the New From Data Source option. Select the Web Service option (see Figure 8.17) in the resulting wizard window. Click the Next button.

    Figure 8.17. Selecting the Web Service option in the Data Source Setup Wizard.

    graphics/08fig17.gif

  2. On the next screen, you are offered three options:

    • Receive and Submit Data

    • Submit Data

    • Receive Data

    Choose the option that reflects how you wish to connect to the XML Web service. I have chosen the Receive Data option in Figure 8.18.

    Figure 8.18. Selecting an option for connecting to an XML Web service.

    graphics/08fig18.gif

  3. Click the Next button. On the following screen of the Data Source Setup Wizard, you are asked for the URL where the WSDL document is located. If you know the URL, skip to step 7.

    If you don't know the location of the WSDL document for the XML Web service to which you want to connect, you can use UDDI to attempt to locate the WSDL document by clicking the Search UDDI button (see Figure 8.19). The Universal Description, Discovery, and Integration (UDDI) protocol allows you to find Web services by connecting to a directory of XML Web services.

    Figure 8.19. The option to search UDDI.

    graphics/08fig19.gif

  4. In the next window, select a UDDI serverthe default is http://uddi.microsoft.com/ inquire . You can choose to search on Provider or Service, and you can also enter a search term .

    In Figure 8.20, I have chosen to search by Service name and to search on the term weather .

    Figure 8.20. A UDDI search is specified.

    graphics/08fig20.gif

  5. Click the Search button. Results appear in the Search Results pane of the Search Web Service window (see Figure 8.21).

    Figure 8.21. Results of a UDDI search.

    graphics/08fig21.gif

  6. Click a desired XML Web service. If it is not available or if it is an RPC Web service, an error message will be displayed.

  7. We will again use the sample Web service with the WSDL file located at http://localhost/infopathsdk/infopathwebservicesample/infopathwebservicesample.asmx?WSDL . Type or paste the URL into the text box (see Figure 8.22).

    Figure 8.22. Entering the URL for the WSDL file of an XML Web service.

    graphics/08fig22.gif

  8. Click the Next button. If all is in order, the Data Source Setup Wizard opens and displays a list of the available methods (see Figure 8.23) as specified in the WSDL file. Select the getOrders method and click the Next button.

    Figure 8.23. Methods available in the XML Web service.

    graphics/08fig23.gif

  9. The final screen of the Data Source Setup Wizard opens (see Figure 8.24) informing you whether setup was successful and asking whether you want to create the Query view or Data view first.

    Figure 8.24. The final screen of the Data Source Setup Wizard.

    graphics/08fig24.gif

  10. Select Design Query View First (the default) and click the Finish button. The Query view opens with the Data Source task pane open (see Figure 8.25).

    Figure 8.25. The Query view to query the sample XML Web service.

    graphics/08fig25.gif

  11. Unlike other uses of the Data Source Setup Wizard, the form controls are not automatically added to the form area. The simplest way to add the necessary form controls is to drag the s0:getOrders group from the queryFields onto the form area. You will be offered options. Select Section with Controls, and a section will be added to the form area. For the purposes of demonstrating the Web service, accept the section with a text box form control for the EmployeeID .

  12. Switch to the Data Entry view. Open the Data Source task pane, and drag the orders group in the dataFields group to the form area (see Figure 8.26).

    Figure 8.26. The Data Entry view created by dragging the orders group.

    graphics/08fig26.gif

    INCORRECT ERROR MESSAGES ACCESSING WSDL FILES

    If you cannot access the WSDL file, you might get misleading error messages. For example, on one occasion, I had neglected to start the IIS World Wide Web service, and the error message indicated that there was not enough storage. The real problem was that the World Wide Web service wasn't running.


  13. All that is left is to test the form. Switch to Query view. Click the Preview Form button, and enter the value 1 in the text box for Employee ID. The Data Entry view opens, populated by orders placed by the employee with EmployeeID of 1 (see Figure 8.27).

    Figure 8.27. Data on orders placed by one employee.

    graphics/08fig27.gif

FINDING DOCUMENT XML WEB SERVICES

At the time of this writing, I could find no XML Web services in the Microsoft UDDI registry that worked with InfoPath 2003. I hope that situation has changed by the time you read this.

One site worth visiting to identify document-type XML Web services is http://www.xmethods.net/ , where document-type XML Web services are identified as such, making it easier to explore XML Web services for possible compatibility with InfoPath 2003.


 < Day Day Up > 


Microsoft Office InfoPath 2003 Kick Start
Microsoft Office InfoPath 2003 Kick Start
ISBN: 067232623X
EAN: 2147483647
Year: 2004
Pages: 206

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