Microsoft KB Archive/870845

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

Article ID: 870845

Article Last Modified on 10/27/2004

-

APPLIES TO


 * Microsoft SOAP Toolkit 3.0
 * Microsoft Office 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 &quot;\0.&quot; The Web service serializes the DataSet as XML and serializes the NULL characters as &quot;&#x0.&quot;

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 &quot;&#x0&quot; 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 &quot;&#x0&quot; is not a valid character in the XML specification, the System.xml library in the .NET Framework permits the &quot;&#x0&quot; 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 &quot;&#x0&quot; character.

Create the Web service
 Start Microsoft Visual Studio .NET. On the File menu, click New, and then click Project. In the Project Types list, click Visual C# Projects. In the Templates list, click ASP.NET Web Service. In the Location box, type http:// /ContainsNullCharacters.

Note The placeholder  is the name of your Web server.

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

//Create a table. Name the table &quot;DaysOfTheWeek.&quot; DataTable theTable = new DataTable(&quot;DaysOfTheWeek&quot;);

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

//Add a column to the table. Name the column &quot;Day&quot;. DataColumn day = new DataColumn(&quot;Day&quot;, 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[]{ &quot;Monday\0\0\0&quot;, &quot;Tuesday\0\0&quot;, &quot;Wednesday&quot;, &quot;Thursday\0&quot;, &quot;Friday\0\0\0&quot;, &quot;Saturday\0&quot;, &quot;Sunday\0\0\0&quot;};

for(int i=0; i < daysOfTheWeek.Length; i++) {              //Create a new row for each day. DataRow theRow = theTable.NewRow; theRow[&quot;Day&quot;] = 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(&quot;ContainsNullCharacters&quot;)) EventLog.CreateEventSource(&quot;ContainsNullCharacters&quot;, &quot;Application&quot;); EventLog myLog = new EventLog(&quot;Application&quot;); myLog.Source = &quot;ContainsNullCharacters&quot;; myLog.WriteEntry(e.Message, EventLogEntryType.Error);

//Return no dataset. return null; }     } </li> On the Build menu, click Build Solution.</li> Exit Visual Studio .NET</li></ol>

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.

Keywords: kbtshoot kbprb KB870845

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.