How do I execute InfoPath Submit Data Connection from c#

I currently have four different Submit Data Connections that are implemented as Rules behind a button.

I need to execute them two different ways:
-Code behind
-Separate process, code called by a timer.

Thank in advance,
Who is Participating?
Clay FoxConnect With a Mentor Director of Business IntegrationCommented:
It looks like you already have the web service fields pointed at the fields in the form schema.
Those would need to have the appropriate values set before submit, regardless of whether via code or via rules.

You can specify a specific submit date connection via code.

Unless you are just submitting the whole xml file, there would not be a way to submit it external to InfoPath.

If your process cannot be completed during the initial user session, then possibly some workflow or an admin form which would query form data from a SP list or something and then submit in bulk or whatever are other options.
Clay FoxDirector of Business IntegrationCommented:
This post has some sample code that might be helpful.
rezlabAuthor Commented:
Thanks. Not quite. I am looking for something along the lines of
DataConnection fsc = DataConnections["NameOfDataConnection"];

But I am unsure if I need to pass in parameters as noted in the images and if so how does one do that?

The other questions is can all of this be done away from InfoPath in a stand alone process?
rezlabAuthor Commented:
I ended up with:

WebServiceConnection wsc = (WebServiceConnection)DataConnections["Submit to Database"];

I guess for the second half I will just have to parse the XML and call the web services like normal, I was just hoping for a short cut.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.