How to Update Data Connection Web Service URL Binding with Code - InfoPath Dev
in

InfoPath Dev

How to Update Data Connection Web Service URL Binding with Code

Last post 07-02-2010 04:17 AM by Jeep80. 1 replies.
Page 1 of 1 (2 items)
Sort Posts: Previous Next
  • 07-02-2010 02:02 AM

    • Jeep80
    • Not Ranked
    • Joined on 07-02-2010
    • Posts 2

    How to Update Data Connection Web Service URL Binding with Code

    Hi everybody!

    I would like to know how to update dynamically, by code, the DataConnection from Infopath, which in different enviroments works (test server, production server...).

    In the folowing links I found some information but the following method is called from the OnLoad event handler from InfoPath to rebind the Web service to a URL.

    VB: http://msdn.microsoft.com/en-us/library/aa218672(office.11).aspx

    C#: http://www.infopathdev.com/forums/p/4490/17465.aspx#17465

    I have to do a new class to update all data connection (web services) from de manifest.xsf

    This method should open the manifest file, get the name of the data connection and update it.

    That´s my first time with C#.

    Help me please!

    Thanks!

    Jeep

     

  • 07-02-2010 04:17 AM In reply to

    • Jeep80
    • Not Ranked
    • Joined on 07-02-2010
    • Posts 2

    Re: How to Update Data Connection Web Service URL Binding with Code

    For example, I´m trying to reuse the following method, but what´s happen with "thisXDocument"?

    How can I open my own manifest.xsf and use it instead of "thisXDocument"?

    //Change the service URL for the adapter specified by adapterName to the specified relative URL

    public static void RebindWSAdapter(string adapterName, string wsURL)

    {

       Uri webserviceUrl;   

       WebServiceAdapter2 adapter;   

       IXMLDOMDocument2 xmlOperation;

       IXMLDOMNode nodeServiceUrl;

       //calculate the new URL

       webserviceUrl = new Uri(wsURL);

       //get the data adapter

       adapter = (WebServiceAdapter2)thisXDocument.DataAdapters[adapterName];

       //get the operation from the data adapter

       //this is the manifest's xsf:operation node minus child nodes.

       xmlOperation = (IXMLDOMDocument2)thisXDocument.CreateDOM();  

       xmlOperation.validateOnParse = false;

       xmlOperation.loadXML(adapter.Operation);

       //change the service URL to the new URL

       nodeServiceUrl = xmlOperation.documentElement.selectSingleNode("@serviceUrl");

       nodeServiceUrl.text = webserviceUrl.AbsoluteUri.ToString();

       thisXDocument.UI.Alert(
    "WS Adapter URL: " + nodeServiceUrl.text);

    }

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