Format of value to be passed to a Web Service - InfoPath Dev
in

InfoPath Dev

Format of value to be passed to a Web Service

Last post 08-04-2014 10:36 AM by cputnamnc. 0 replies.
Page 1 of 1 (1 items)
Sort Posts: Previous Next
  • 08-04-2014 10:36 AM

    Format of value to be passed to a Web Service

    I am using Infopath 2010, Word 2010, Sharepoint 2010, and VB in the Infopath code.  (This all ties together because we have a document library in Sharepoint using a Word document template that has a Document Information Panel (DIP/Infopath form) where users can enter data that is then automatically inserted into the Word document and the Sharepoint document library.)

    The code I am using in the DIP/Infopath form is supposed to capture the value that a user types into a form, pass that value to a field within a SOAP .NET web service created by a colleague (setup in the form as a Web Service data connection), and validate that value according to rules within that web service.  (We are using the .NET ws for validation because validation of the same shared Sharepoint fields is done in a number of other places and we need to create a similar user experience throughout the application we are building.  We are also using a number of Sharepoint Managed Metadata fields and validating them isn't easily done in Infopath).  At this point in the process, I am having trouble figuring out how to format the XPathNavigator values so I can pass the values from the form to the WebService.

    Here is the code I am currently using:

    Public Function CallValidationService() As Boolean
                Dim wsConnection As WebServiceConnection = DirectCast(Me.DataConnections("Validate"), WebServiceConnection)
                Dim formNavigator As XPathNavigator = MainDataSource.CreateNavigator()
                Dim wsNavigator As XPathNavigator = Me.DataSources("Validate").CreateNavigator()

    'this line is where the value entered in the form is captured.

                Dim xformNav As XPathNavigator = formNavigator.SelectSingleNode("/pr:properties/p:properties/documentManagement/ns3:ProjectName", NamespaceManager)
                MessageBox.Show("Value of xFormNav" & xformNav.OuterXml.ToString())

    'this line is where the form value is being passed to the field in the data connection for the web service

                wsNavigator.SelectSingleNode("/dfs:myFields/dfs:queryFields/ns7:Validate/ns7:projectName", NamespaceManager).SetTypedValue(xformNav)

    'this line passes the data connection's field value to the actual web service (we never get to this line) 

                wsConnection.Execute()
    End Function

    As it stands now, when I debug this code, I get this error:  The method or operation is not implemented. 

    The value of the MessageBox (containing the OuterXml of sformNav looks like this:

    Value of xFormNav<ns3:ProjectName xmlns:ns3="c4fbbb.....>entered project name </ns3:ProjectName>

    where "entered project name" is the value I entered into the form.

    I tried to create string values from the XPathNavigator objects (using both .ToString and .Value but always got this error:

    System.Net.WebException 

    The query cannot be run for the following DataObject: Validate

    InfoPath cannot run the specified query.

    The SOAP response indicates that an error occurred

    Input string was not in a correct format.

    So my question is how do I manipulate what's in the XPathNavigator object and create something that I  can pass into the webservice using the wsConnection.Execute() line?  I hope I have explained things clearly enough but please let me know if you need more information.  Thanks in advance for any help you can give me.  Carol

    Filed under:
Page 1 of 1 (1 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.