1

When I deploy an Infopath 2007 form to the SharePoint server, the SelectSingleNode always returns null but always works locally. Here is an example of the following code that is failing:

XPathNavigator vendor = payeeDS.SelectSingleNode(
"/dfs:myFields/dfs:dataFields/tns:GetVendorsResponse/tns:GetVendorsResult/NewDataSet/Vendor s[Name='" + payeeTypedName + "']", NamespaceManager);

I'm writing to the event viewer so I can confirm that the code is actually hit. The form is Administrator approved and has Full Trust.

Any ideas on what could be causing this issue?

Thanks

Jav_Rock
  • 22,059
  • 20
  • 123
  • 164

2 Answers2

0

Verify your node path.("/dfs:myFields/dfs:dataFields/tns:GetVendorsResponse/tns:GetVendorsResult/) The first part of the path is in one name space(dfs:) and other part is in other name space(tns:). You can do two things

1.Set the name space of the tns: with your web service

 IXMLDOMDocument2 domXml = (IXMLDOMDocument2)xDocument.DataObjects[dataSource].DOM;
            string selectionNamespaceValue = string.Empty;
   public const string SELECTION_NAMESPACE_VALUE =
        "xmlns:dfs='http://schemas.microsoft.com/office/infopath/2003/dataFormSolution' xmlns:ns1='{0}'";

                selectionNamespaceValue = string.Format(CultureInfo.CurrentCulture, Constants.SELECTION_NAMESPACE_VALUE,Constants.DEFAULT_WEB_SERVICE);
 domXml.setProperty("SelectionNamespaces", selectionNamespaceValue);
  1. You can access the node by either like this.

    payeeDS.SelectSingleNode("/dfs:myFields/dfs:dataFields)..firstChild.firstChild;

udaya726
  • 1,010
  • 6
  • 21
  • 41
0

XPathNavigator behavior doesn't change based on environment. I'm not certain, but you likely have one of two problems.

Either the payeeDS isn't loading as a valid XML file and cannot be read, or more likely,

Sharepoint has added some NameSpacing to the XML file, and you need to change your navigation.

Wesley
  • 5,381
  • 9
  • 42
  • 65