Updating WS data conn with code - InfoPath Dev
in

InfoPath Dev

Updating WS data conn with code

Last post 01-13-2011 01:55 PM by Rajeev. 1 replies.
Page 1 of 1 (2 items)
Sort Posts: Previous Next
  • 06-15-2005 06:23 AM

    Updating WS data conn with code

    I've been reading through Chapter 7 of the MS Infopath book (good reference). I have a C#/InfoPath project with a web service, where I've just converted from using Web References in VS.Net to the secondary data connections method, which is working just fine. My main reason was because I need to update the web service URL when I deliver this to our client, and I didn't want to have to change the code, but rather save the URL from our main application's web.config (it uses the same web service) and then get that URL from the pre-loaded InfoPath form.

    I took the code from page 220 and set up a test case, where the adapter I'm using has the same web method on two servers, but will return a different result depending which is hit (so I know which was hit). When I run the function on page 220, I have an alert tell me that the nodeServiceUrl.text property is now set to the URL of the web service I want it to hit. However, when it then goes back to call the web service, it's giving me a result from the original URL. I can see the code changes the serviceURL, but it seems to leave the wsdlURL alone...could the discrepency be the problem?

    Here's the code I modified into C# from page 220:

    private void RebindWSAdapter(string adapterName, string wsURL)
    {
    Uri webserviceUrl;
    WebServiceAdapter2 adapter;
    IXMLDOMDocument2 xmlOperation;
    IXMLDOMNode nodeServiceUrl;

    webserviceUrl = new Uri(wsURL);
    adapter = (WebServiceAdapter2) thisXDocument.DataAdapters[adapterName];
    xmlOperation = (IXMLDOMDocument2) thisXDocument.CreateDOM();
    xmlOperation.validateOnParse = false;
    xmlOperation.loadXML(adapter.Operation);

    nodeServiceUrl = xmlOperation.documentElement.selectSingleNode("@serviceUrl");
    nodeServiceUrl.text = webserviceUrl.AbsoluteUri.ToString();
    thisXDocument.UI.Alert("WS Adapter URL: " + nodeServiceUrl.text);
    }

    The call I make to this function is:
    RebindWSAdapter("GetCheckoutStatusReceive", "http://server2/sites/PMDTC_Phase2/_vti_bin/pmdtc_svc.asmx");

    The adapter code from my manifest.xsf file is:

    <xsf:dataObjects>
    <xsf:dataObject name="GetCheckoutStatusReceive" schema="GetCheckoutStatusReceive.xsd" initOnLoad="no">
    <xsf:query>
    <xsf:webServiceAdapter wsdlUrl="http://server1/sites/PMDTC_Phase2/_vti_bin/pmdtc_svc.asmx?WSDL" queryAllowed="yes" submitAllowed="no" name="GetCheckoutStatusReceive">
    <xsf:operation name="GetCheckoutStatus" soapAction="http://tempuri.org/PMDTC.WebService/PMDTC_Phase2_WS/GetCheckoutStatus" serviceUrl="http://server1/sites/PMDTC_Phase2/_vti_bin/pmdtc_svc.asmx">
    <xsf:input source="GetCheckoutStatusReceive.xml"></xsf:input>
    </xsf:operation>
    </xsf:webServiceAdapter>
    </xsf:query>
    </xsf:dataObject>
    </xsf:dataObjects>
  • 01-13-2011 01:55 PM In reply to

    • Rajeev
    • Not Ranked
    • Joined on 10-02-2010
    • Posts 1

    Re: Updating WS data conn with code

    Hi  

    Can you please help me to get the JScript for the above code?

    I am building a form where I want to dynamically load ( through Browse Button) an XML file ( data connection) and use the fields from that file to  process it further in the parent form.

    Your early help in this regard is highly appreciated.

    Note: I am not using and development environment except Microsoft Script Editor.

    Regards,
    Rajeev

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