Skip to main content

I am trying to automate the submission of a bunch of InfoPath forms to kick off their respective workflow processes.  I figured I'd be able to send the InfoPath xml to the 'SubmitInfoPathData' web service (provided by blackpearl) to do this.  However, when I send the InfoPath xml to the service, I always get the error 'The data submitted by the InfoPath form is not valid'.  Does anyone know how to send the InfoPath xml to this service correctly?  Within the InfoPath template, the service connection (configured by the InfoPath Integration Wizard) is set up to submit 'the entire form' as the parameter - this is more an InfoPath question I guess but behind the scenes, what consitutes an 'entire form' for InfoPath?

I don't know the answer to your question, but you could do some scouting around.


View the code of an infopath client event and look for the tempInfoPathUpload function ( I think, you'll need to get to that though the windows workflow view ) put a breakpoint on the bit of code that uploads the form to SharePoint... this should get you the correct representation of the form, as I believe the submitted XML is identical to that.


Martin


In my case, I just open the xsn file (not in design mode) in InfoPath and save the resulting xml.  But, I have a feeling you figured that out:)


Also relating to the SubmitInfoPathData Service, I get the following error when I submit HUNDREDS of forms to K2:  The operation has timed out


Has anybody found a good way to prevent a timeout?  I see the InfoPathService has a timeout paremeter.  Also, waiting a few minutes seems to prevent this, so I am probably just overloading the server somehow.


Just wondering if anybody had a similar problem since I would think it would be common if you are automating the submission of InfoPath forms to BlackPearl.


 Since the timeout problem is pretty unrelated, I posted about the timeout problem here: http://www.k2underground.com/forums/25263/ShowThread.aspx#25263


 


Can you change the parameter in the infopath service?  I am getting an error when deploying a process with a infopath form.  "Operation has timed out".

I remember there was a timeout property or parameter, but I had no success with that.  Once the K2 server got in a bad state, the operation would always timeout. 


 Your error sounds different though, I think there could be another timeout setting on the server you are looking for, but I'm not sure what that is, sorry.


So does anyone have any insight to the original problem?  I have the same problem and I can't figure this out at all.  The XML I have is perfectly valid.  In fact, if I open the form in InfoPath it submits just fine.  I am doing the following which _should_ submit the entire form as a string (which is how the Submit data source is configured):



XmlDocument formXmlDocument = new XmlDocument();
foreach (FileInfo form in FormOutputFolder.GetFiles("*.xml"))
{
  formXmlDocument.Load(form.FullName);
  K2InfoPathService.SubmitInfoPathData(formXmlDocument.OuterXml);
}


I have created a data migration tool to create InfoPath XML files based on a template and populate the data automatically.  I would like the tool to automatically submit the generated files, which is where I ran into this problem.  It shouldn't be that hard, so I assume it's an ID10T error...


Update: I was thinking of using the API instead, then I stumbled on this thread which looks like where I was heading, so I'll try this and update this thread with my results.

Update 2 : This worked perfectly.  I made a class called K2InfoPathHelper and call the submit method as follows i.e. K2InfoPathHelper.SubmitInfoPathData(string serverName, string connectionString, string formName, string folio, bool synchronous).


I am revisiting this as I need to be able to resubmit forms associated with running process instances.  I shouldn't need to (nor want to) go through the API when we have a perfectly working web service to use.


So, does _anyone_ know how to successfully submit via code to the SubmitInfoPathData() web method?


I ultimately was able to get it to work via api: 


SourceCode.Workflow.RuntimeServices.Client.InfoPathService .SubmitInfoPathData


I assume that it calls the web service within that api, but it provides a somewhat nice wrapper to do so.


Interesting.  This class doesn't appear in the documentation, so I never looked at it.


I added a reference and used it instead of going straight to the web service, but unfortunately the results are the same.  This is the error message:


"Error: Server was unable to process request. ---> The data submitted by the InfoPath form is not valid."


Here is the line of code that actually submits the data, and XmlDoc is an XmlDocument and was loaded straight from a file created by InfoPath without modification (other than setting the K2 ActionName node to an appropriate action string):


infoPathWebService.SubmitInfoPathData(

this.XmlDoc.OuterXml);


Bummer.  I was hoping that would fix it.  I wish the web service would return a meaningful error message :-(


This was a while ago that we got this working, so I am sorry I forgot if there were any other details.  I will review my notes and try to get you something concrete on Monday.
No worries.  Thank you very much for checking, Tim!  I'm going to keep digging to see if I can find the answer, and I'll post an updated if I do.

K2 support (thanks Pieter) set me straight on how to make this work.  When you call SubmitInfoPathData() you do this:


infoPathWebService.SubmitInfoPathData(new XmlTextt] { this.XmlDoc.CreateTextNode(this.XmlDoc.InnerXml) });


where XmlDoc is the complete XmlDocument created by InfoPath.


I hope this helps others :-)


Reply