Dynamically change the WebService URL with infopath

M

moute

Hi,

I'm using Infopath SP1 preview. To populate a drop-down list, I have
created a WebService that return a DataSet. But I would like to be
able to change the URL of the reference to this WebService during the
execution of the form, using C# code.

I saw that under infopath the URL of the WebService is stored in the
Manifest file of the infopath project, but I didn't managed to access
it.

I have a second question that can be an solution to my first question.
Is it possible to populate an infopath drop-down list using C# code ?
If yes, it will be possible to access the webservice with codes and to
populate the drop-down list with its response.

Best regards

Adrien
 
M

moute

I found the answer to my pb :

You can acces this value in Read Only with the following line :
((WebServiceAdapter2)thisXDocument.DataAdapters["DataAdapter
Name"]).WSDLURL

But if you want to change this value, you must modify the Operation
property of the DataAdapter :
//Get the Data Source WebServiceAdapter object
WebServiceAdapter2 myWSadapter =
(WebServiceAdapter2)thisXDocument.DataAdapters["DataAdapter Name"];
//Load the xsf:input element into an XML DOM
IXMLDOMDocument2 tempDOM =
(IXMLDOMDocument2)thisXDocument.CreateDOM();
tempDOM.validateOnParse = false;
tempDOM.preserveWhiteSpace = false;
tempDOM.loadXML(myWSadapter.Operation);
//set the WebService URL
tempDOM.documentElement.attributes.getNamedItem("serviceUrl").text=WebServiceURL;
//Save this setting
myWSadapter.Operation = tempDOM.xml;

Moute
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top