Passing a parameter to a web service - InfoPath Dev
in

InfoPath Dev

Passing a parameter to a web service

Last post 06-02-2006 07:34 AM by JeffK627. 2 replies.
Page 1 of 1 (3 items)
Sort Posts: Previous Next
  • 11-05-2005 02:42 PM

    Passing a parameter to a web service

    I am trying to pass a parameter to a web service using XDocument.DataObjects
    var node = getNodeValue("/TestDoc/MyNode");
    var oDataObject = XDocument.DataObjects.Item("MyDataObject");
    oDataObject.DOM.setProperty( "SelectionNamespaces", 'xmlns:dfs="http://schemas.microsoft.com/office/infopath/2003/dataFormSolution" ' 'xmlns:tns="http://tempuri.org/"');
    var oQueryAdapter = oDataObject.QueryAdapter;
    // I need to set a parameter here.
    oQueryAdapter .Query();

    My web service takes in one input parameter. I need to set this parameter using code prior to querying the web service. This seems to be easily possible in an ADODataAdapter using the Command property but I cant figure out how to do this for a WebServiceAdapter

    Any help would be greatly appreciated.
  • 11-05-2005 03:00 PM In reply to

    Re: Passing a parameter to a web service

    Got it :)

    Just add the lines below
    var query = oDataObject.DOM.selectSingleNode('/dfs:myFields/dfs:queryFields/tns:MyDataObject/tns:myParam);
    query.text = myValue;
  • 06-02-2006 07:34 AM In reply to

    Re: Passing a parameter to a web service

    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!
Page 1 of 1 (3 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.