When InfoPath submits data to a Web service, it submits the contents of the XML node that was selected as a parameter, but it does not submit the XML node itself. This generally works well. For example, you have a Web service method like the following:
[WebMethod]
public void SendSampleString( string sampleString )
{
//Do something interesting with the sample string.
}
If you submit the following XML element to this Web service method, the
sampleString parameter is filled with
"Hello, World!" (as you expect).
<sampleElement>"Hello, World!"</sampleElement>
Unfortunately, this behavior can make it difficult to submit XML nodes or the whole InfoPath form to a Web service. For example, you have a Web service method like the following:
[WebMethod]
public string SendXMLElement( System.Xml.XmlElement theElement )
{
//Report how many children the submitted node had.
return "Node with " + theElement.ChildNodes.Count + " children submitted.";
}
If you submit the example XML element to this method by using the built-in InfoPath submit functionality, the contents of the
theElement parameter generate an error. This error occurs because only the contents of the XML element ("Hello, World!"), are sent to the Web service method. Because the string is not a valid XML element, the .NET Framework generates an error; the error message appears in InfoPath.
A similar problem occurs if you try to submit the whole InfoPath form to the example Web service method. In this case, InfoPath submits all the child nodes of the InfoPath form, but does not submit the root node. This results in multiple top-level XML nodes being submitted. Because this is also not valid XML, the .NET Framework selects the first top-level XML node and uses it as the
theElement parameter. All the other nodes are ignored, and this gives the appearance that they were not submitted.