I am trying to pass the contents of a text box as a parameter to a webservice. I tried using betazed's code - adapted to C# - with the appropriate names plugged in for the Data Object and parameter, but it throws a nullReferenceException. I have nailed down the exception to the left side of the assignment, specifically where it tries to assign a value to query.text. It seems that as far as the code is concerned, "query" is null and you can't assign to null because it's not an instance of an object and that's that.
My actual code is as follows:
private void RequeryWebService()
{
try
{
//Get a reference to the Web Service
DataObject wsGLE = thisXDocument.DataObjects["getLEArray"];
//Get a reference to the Web Service's DOM
IXMLDOMDocument3 wsDOM = (IXMLDOMDocument3)wsGLE.DOM;
//Set the SelectionNamespaces so that you can find the correct field
wsDOM.setProperty("SelectionNamespaces",
"xmlns:dfs=\"http://schemas.microsoft.com/office/infopath/2003/dataFormSolution\""
+ " xmlns:tns=\"http://tempuri.org/\"");
//Set Web Service parameters
IXMLDOMNode aNode = wsDOM.selectSingleNode("/dfs:myFields/dfs:queryFields/tns:getLEArray/tns:userInput");
aNode.text = thisXDocument.DOM.selectSingleNode("/my:myFields/my:wsParam1").text;
//Requery the webservice datasource
wsGLE.Query();
}
catch(Exception e)
{
Console.WriteLine(e);
}
}
I would be grateful for any help!