Sunday, January 18, 2004

Unfortunately, InfoPath is not able to directly consume a Web Service that returns an ADO.NET DataSet. InfoPath is designed to handle generic XML payloads. By default, a DataSet that is returned by a Web Service is a serialized XML string that returns a format that InfoPath is not able to directly consume.

 

If you are like me, I use the DataSet as the base for everything I do around data access. I developed this little helper function that I use to convert a DataSet to an XML Document that InfoPath is able to understand.

 

<WebMethod()> Public Function InfoPathGetRequests(ByVal RequestedStatus

 As Boolean) As System.Xml.XmlDataDocument

' this is a wrapper service for conversion of the DataSet for use

' in an InfoPath form

 Dim requestds As DataSet

 ' call the Web Service to get the DataSet

 requestds = GetRequests(RequestedStatus:=RequestedStatus)

 ' create the XML Document

 requestds.Namespace = "Http://localhost/RequestType"

 Dim Info As System.Xml.XmlDataDocument = New  _     

            System.Xml.XmlDataDocument(requestds)

 Return Info

 

End Function

 

I then point my InfoPath form at this Web Service function and off it goes!


9:31:37 PM    

Today all code in InfoPath is written using the Microsoft Script Editor (MSE). The problem is that if you attempt to set breakpoints within MSE they are ignored. This can be rather frustrating for those that are new to InfoPath. In order to enter debug mode using InfoPath you need to place either a debugger (JavaScript) or stop (VBScript) statement inline. When hit this provides the ability to attach to the InfoPath process and enter debug mode.


9:00:44 PM