You receive the "InfoPath cannot run the specified query" error message when a Web service data connection contains NULL characters in InfoPath 2003

SYMPTOMS
You create a Web Service that returns an ADO.NET DataSet. The DataSet contains data that is padded with the encoded NULL character "\0." The Web service serializes the DataSet as XML and serializes the NULL characters as "&#x0."

When you call the Web service from another .NET application, the .NET application successfully reads the Web service data.

When you call the Web service from a data connection in Microsoft Office InfoPath 2003, you receive the following error message:

InfoPath cannot run the specified query.

CAUSE
This problem occurs because the character "&#x0" is not a valid character in an XML document. Therefore, InfoPath 2003 cannot parse the encoded NULL character.

STATUS
This behavior is by design.

MORE INFORMATION
Although "&#x0" is not a valid character in the XML specification, the System.xml library in the .NET Framework permits the "&#x0" character. For backward compatibility reasons, there are no plans to remove this functionality. InfoPath 2003 uses the Microsoft XML Core Services (MSXML) library that does not let you use the "&#x0" character.

Steps to reproduce the problem
Create the Web service


1. Start Microsoft Visual Studio .NET.
2. On the File menu, click New, and then click Project.
3. In the Project Types list, click Visual C# Projects. In the Templates list, click ASP.NET Web Service.
4. In the Location box, type http://<server>/ContainsNullCharacters.

Note The placeholder <server> is the name of your Web server.

Click OK.
5. Right-click Service1.asmx, and then click View Code.
6. Add the following Web service method code sample to the Service1 class.
Code:
 * * *[WebMethod]
 * * *public DataSet GetInvalidDataSet()
 * * *{
 * * * * try
 * * * * {
 * * * * * *//Create a new ADO.NET DataSet.
 * * * * * *DataSet theDataSet = new DataSet();
 * * * * * *theDataSet.DataSetName = "ContainsNullCharacters";
 * * * * * *theDataSet.Namespace = "ContainsNullCharacters";

 * * * * * *//Create a table. Name the table "DaysOfTheWeek."
 * * * * * *DataTable theTable = new DataTable("DaysOfTheWeek");

 * * * * * *//Add a primary key to the table.
 * * * * * *DataColumn id = theTable.Columns.Add("ID", typeof(Int32));
 * * * * * *id.AutoIncrement = true;
 * * * * * *theTable.PrimaryKey = new DataColumn[]{id};

 * * * * * *//Add a column to the table. *Name the column "Day".
 * * * * * *DataColumn day = new DataColumn("Day", typeof(String));
 * * * * * *day.MaxLength = 9;
 * * * * * *theTable.Columns.Add( day );

 * * * * * *//Add the new table to the DataSet.
 * * * * * *theDataSet.Tables.Add( theTable );

 * * * * * *//Add the days of the week. *The \0 characters are encoded NULLs.
 * * * * * *String[] daysOfTheWeek = new String[]{
 * * * * * * * * * * * * * * * * * * * * * * * * * *"Monday\0\0\0",
 * * * * * * * * * * * * * * * * * * * * * * * * * *"Tuesday\0\0",
 * * * * * * * * * * * * * * * * * * * * * * * * * *"Wednesday",
 * * * * * * * * * * * * * * * * * * * * * * * * * *"Thursday\0",
 * * * * * * * * * * * * * * * * * * * * * * * * * *"Friday\0\0\0",
 * * * * * * * * * * * * * * * * * * * * * * * * * *"Saturday\0",
 * * * * * * * * * * * * * * * * * * * * * * * * * *"Sunday\0\0\0"};

 * * * * * *for(int i=0; i < daysOfTheWeek.Length; i++)
 * * * * * *{
 * * * * * * * //Create a new row for each day.
 * * * * * * * DataRow theRow = theTable.NewRow();
 * * * * * * * theRow["Day"] = daysOfTheWeek[i];
 * * * * * * * theTable.Rows.Add( theRow );
 * * * * * *}

 * * * * * *//Commit the changes to the DataSet.
 * * * * * *theDataSet.AcceptChanges();

 * * * * * *//Return the resulting DataSet.
 * * * * * *return theDataSet;
 * * * * }
 * * * * catch(Exception e)
 * * * * {
 * * * * * *//Try to log an event in the application event log.
 * * * * * *if(!EventLog.SourceExists("ContainsNullCharacters"))
 * * * * * * * EventLog.CreateEventSource("ContainsNullCharacters", "Application");

 * * * * * *EventLog myLog = new EventLog("Application");
 * * * * * *myLog.Source = "ContainsNullCharacters";
 * * * * * *myLog.WriteEntry(e.Message, EventLogEntryType.Error);

 * * * * * *//Return no dataset.
 * * * * * *return null;
 * * * * }
 * * *}
7. On the Build menu, click Build Solution.
8. Exit Visual Studio .NET

Create the InfoPath 2003 form

1. Start InfoPath 2003 Service Pack 1.
2. On the File menu, click Design a Form.
3. In the Design a Form task pane, click New from Data Source.
4. Click Web Service for the data source, and then click Next.
5. Click Receive data, and then click Next.
6. Type http://<SERVER/ContainsNullCharacters/Service1.asmx for the location of the Web service, and then click Next.
7. In the Select an operation list, click GetInvalidDataSet, and then click Next.

InfoPath 2003 calls the Web service to retrieve sample data. When the data is returned, InfoPath 2003 cannot parse the XML because it contains encoded NULL characters.

APPLIES TO
? Microsoft Office InfoPath 2003