Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

How to change the URL of a Web service in InfoPath 2003


View products that this article applies to.

Summary

This step-by-step article describes how to modify the URL of a Web service that is used as a data source for a Microsoft Office InfoPath form.

Introduction

The InfoPath user interface does not provide a way for you to change the URL for the Web service that is used as a data source. However, you can change the URL by first extracting the files for your form and then manually modifying Manifest.xsf.

Create a Simple Web Service

  1. Start Microsoft Visual Studio .NET. On the File menu, point to New, and then click Project.
  2. Under Project Types, select Visual Basic Projects. Under Templates, select ASP .NET Web Service.
  3. In the Location text box, type http://<SERVER>/SimpleWebService (where <SERVER> is the name of your Web server), and then click OK.
  4. Right-click Service1.asmx.vb, and then click View Code.
  5. Add the following Web service method to the Service1 class:
    	<WebMethod()> _
    	Public Function HelloWorld() As String
            	Return "Hello World"
    	End Function
  6. On the Build menu, click Build Solution.
  7. Close Visual Studio .NET.

Create a New Form from the Web Service

  1. Start InfoPath.
  2. On the File menu, click Design a Form.
  3. In the Design a Form task pane, click New from Data Source. The Data Source Setup Wizard begins.
  4. Set up the data source as follows:
    1. Select Web Service for the data source, and then click Next.
    2. Select Receive data, and then click Next.
    3. Type http://<SERVER>/SimpleWebService/Service1.asmx for the location of the Web service, and then click Next.
    4. In the Select an Operation list, select Hello World, and then click Next.
    5. Select Design data view first, and then click Finish.
  5. Switch to the Data Source task pane, and then expand dataFields.
  6. Expand HelloWorldResponse, and then drag the HelloWorldResult element to the view. InfoPath adds a Text Box control to the view.
  7. Test the form as follows:
    1. On the Task Pane menu, click Views.
    2. In the Views list, select Query. Right-click Query, and then click Set as Default.
    3. On the File menu, point to Preview Form, and then click Default.
    4. When the Query view of the form opens, click Run Query.
    5. On the View menu, click Data Entry. Verify the value that the Web service returns.

Change the URL of the Web Service

  1. Rename the service to change its URL, as follows:
    1. In Windows Explorer, locate C:\Inetpub\Wwwroot\SimpleWebService.
    2. Locate the Service1.asmx file, and then rename the file as Service2.asmx.
  2. Return to InfoPath and test the form as follows:
    1. Follow steps 7a through 7d in the "Create a New Form from the Web Service" section. InfoPath generates the following error message when you click Run Query:
      InfoPath cannot run the specified query.

      InfoPath either cannot connect to the data source or the service has timed out.
    2. Click OK to dismiss the dialog box.
    3. Click Close Preview to return to design mode.
  3. Change the URL of the Web service in the InfoPath form as follows:
    1. On the File menu, click Extract Form Files.
    2. In the Browse for Folder dialog box, select a folder that will contain the extracted files, and then click OK.
    3. Close InfoPath.
    4. In Windows Explorer, locate the folder where you extracted the files.
    5. Open the Manifest.xsf file in a text editor such as Notepad or an XML editor such as Visual Studio .NET 2003.
    6. Locate the <xsf:webServiceAdapter> tag. Change the wsdlUrl attribute from http://localhost/simplewebservice/service1.asmx?WSDL to http://localhost/simplewebservice/service2.asmx?WSDL.
    7. Locate the <xsf:operation> tag. Change the serviceUrl attribute from http://localhost/simplewebservice/service1.asmx to http://localhost/simplewebservice/service2.asmx.
    8. Save your changes to Manifest.xsf, and then close the file.
  4. Test the form as follows:
    1. In Windows Explorer, right-click Manifest.xsf, and then click Design. This opens the form in InfoPath.
    2. Follow step 7 in the "Create a New Form from the Web Service" section to test the form.
    3. Verify the value that the Web service returns.

↑ Back to the top


Keywords: KB827003, kbhowto

↑ Back to the top

Article Info
Article ID : 827003
Revision : 3
Created on : 9/22/2011
Published on : 9/22/2011
Exists online : False
Views : 474