转:How to submit rows of a repeating table in InfoPath to a web service? 如何将重复表中的记录传给Web Service ?
2009-07-31 19:33
531 查看
关键点及注意事项:
1, 注意其中红色字体部分,namespace 必须和对应的 InfoPath Form 中一致,其中一个办法就是在 InfoPath Form 设计阶段查看Group 对应的属性,可直接取得其 namespace;
2, 在 RepeatingTable class 定义中,必须确保其中两个Group 的名称和 InfoPath Form 中对应的Group 名称完全一致,否则将无法成功调用此 class;
3, 除了 Group 的名称要一致外,还必须确保在Class 中定义的 Field 的名称也必须和 Repeating Table 包括的每个数据列的名称完全一致,否则也将无法保存成功;
4, 如果调用Web Service 时出现错误,如 NullException 等,请先检查是否以上3点正确。
转: http://www.bizsupportonline.net/infopath2007/how-to-submit-repeating-table-infopath-web-service.htm
Learn how you can create a .NET web service that accepts data from the rows of a repeating table on an InfoPath form.
In InfoPath, create a new form template.
Add a Repeating Table control with 3 columns to the InfoPath form template. By default the repeating table will contain a non-repeating group node named group1, a repeating group node named group2, and 3 fields named field1, field2, and field3.
Figure 1. The default structure of a repeating table in InfoPath.
The repeating table shown above can be seen as an array of group2 nodes. This logic will be used by the web service to accept the XML data of the repeating table that is passed from the InfoPath form, and serialize this XML into an array of group2 items.
In Visual Studio 2005, create a new Web Site project.
Select the ASP.NET Web Service Visual Studio template, and name the web service SubmitRepeatingTableInfoPath.
Add a new Class to the App_Code folder and name it RepeatingTable.
Add the following code to the RepeatingTable class:
Note: You must replace the Namespace parameter of XmlRootAttribute with the namespace for your own InfoPath form template. To find this namespace, in InfoPath, on the File menu, click Save As Source Files, and select a folder where to extract the files contained in the form template. Go to the folder where you extracted the files, open the sampledata.xml file in Notepad, copy the namespace for the my namespace prefix and paste it into the class file in Visual Studio.
Delete the HelloWorld web method that Visual Studio adds by default to web service projects and add the following SubmitRepeatingTable web method to the web service:
In InfoPath, on the Tools menu, click Data Connections.
On the Data Connections dialog box, click Add.
On the Data Connection Wizard, select Create a new connection to, select Submit data, and click Next.
On the Data Connection Wizard, select To a Web service, and click Next.
On the Data Connection Wizard, type in the location for your web service, and click Next.
On the Data Connection Wizard, select SubmitRepeatingTable from the Select an operation list, and click Next.
On the Data Connection Wizard, click the button behind the Field or group field.
On the Select a Field or Group dialog box, expand the nodes, select the group1 node, and click OK.
On the Data Connection Wizard, select XML subtree, including selected element from the Include drop-down list box, and click Next.
Figure 2. Data Connection Wizard in InfoPath to select the repeating table node to submit to the web service.
On the Data Connection Wizard, click Finish.
On the Data Connections dialog box, click Close.
On the Tools menu, click Submit Options.
On the Submit Options dialog box, select Allow users to submit this form, select Web service from the Send form data to a single destination drop-down list box, select the web service submit data connection you created from the Choose a data connection for submit drop-down list box, and click OK.
You should now be able to preview the InfoPath form, enter data in the repeating table, and click the Submit button to submit the data of the repeating table to the web service.
1, 注意其中红色字体部分,namespace 必须和对应的 InfoPath Form 中一致,其中一个办法就是在 InfoPath Form 设计阶段查看Group 对应的属性,可直接取得其 namespace;
2, 在 RepeatingTable class 定义中,必须确保其中两个Group 的名称和 InfoPath Form 中对应的Group 名称完全一致,否则将无法成功调用此 class;
3, 除了 Group 的名称要一致外,还必须确保在Class 中定义的 Field 的名称也必须和 Repeating Table 包括的每个数据列的名称完全一致,否则也将无法保存成功;
4, 如果调用Web Service 时出现错误,如 NullException 等,请先检查是否以上3点正确。
转: http://www.bizsupportonline.net/infopath2007/how-to-submit-repeating-table-infopath-web-service.htm
Learn how you can create a .NET web service that accepts data from the rows of a repeating table on an InfoPath form.
Problem
You have a repeating table on an InfoPath form and you want to submit the data from all of the rows in the repeating table to a .NET web service.Solution
Create a .NET web service that accepts a parameter that can be serialized as an array of XML elements.Discussion
You can achieve this functionality as follows:In InfoPath, create a new form template.
Add a Repeating Table control with 3 columns to the InfoPath form template. By default the repeating table will contain a non-repeating group node named group1, a repeating group node named group2, and 3 fields named field1, field2, and field3.
Figure 1. The default structure of a repeating table in InfoPath.
The repeating table shown above can be seen as an array of group2 nodes. This logic will be used by the web service to accept the XML data of the repeating table that is passed from the InfoPath form, and serialize this XML into an array of group2 items.
In Visual Studio 2005, create a new Web Site project.
Select the ASP.NET Web Service Visual Studio template, and name the web service SubmitRepeatingTableInfoPath.
Add a new Class to the App_Code folder and name it RepeatingTable.
Add the following code to the RepeatingTable class:
[System.Xml.Serialization.XmlRootAttribute( Namespace = "http://schemas.microsoft.com/office/infopath/2003/myXSD/2009-02-23T05:14:24", IsNullable = false)] public class RepeatingTable { [System.Xml.Serialization.XmlArray("group1")] public group2[] rows; } public class group2 { public string field1; public string field2; public string field3; }
Note: You must replace the Namespace parameter of XmlRootAttribute with the namespace for your own InfoPath form template. To find this namespace, in InfoPath, on the File menu, click Save As Source Files, and select a folder where to extract the files contained in the form template. Go to the folder where you extracted the files, open the sampledata.xml file in Notepad, copy the namespace for the my namespace prefix and paste it into the class file in Visual Studio.
Delete the HelloWorld web method that Visual Studio adds by default to web service projects and add the following SubmitRepeatingTable web method to the web service:
[WebMethod] public void SubmitRepeatingTable( RepeatingTable myRepTable) { for (int i = 0; i < myRepTable.rows.Length; i++) { string field1 = myRepTable.rows[i].field1; string field2 = myRepTable.rows[i].field2; string field3 = myRepTable.rows[i].field3; } }
In InfoPath, on the Tools menu, click Data Connections.
On the Data Connections dialog box, click Add.
On the Data Connection Wizard, select Create a new connection to, select Submit data, and click Next.
On the Data Connection Wizard, select To a Web service, and click Next.
On the Data Connection Wizard, type in the location for your web service, and click Next.
On the Data Connection Wizard, select SubmitRepeatingTable from the Select an operation list, and click Next.
On the Data Connection Wizard, click the button behind the Field or group field.
On the Select a Field or Group dialog box, expand the nodes, select the group1 node, and click OK.
On the Data Connection Wizard, select XML subtree, including selected element from the Include drop-down list box, and click Next.
Figure 2. Data Connection Wizard in InfoPath to select the repeating table node to submit to the web service.
On the Data Connection Wizard, click Finish.
On the Data Connections dialog box, click Close.
On the Tools menu, click Submit Options.
On the Submit Options dialog box, select Allow users to submit this form, select Web service from the Send form data to a single destination drop-down list box, select the web service submit data connection you created from the Choose a data connection for submit drop-down list box, and click OK.
You should now be able to preview the InfoPath form, enter data in the repeating table, and click the Submit button to submit the data of the repeating table to the web service.
相关文章推荐
- 转:How to submit the rows of a repeating table in InfoPath to a SharePoint list
- Here's an example that shows how to enumerate through the features of a selection set, returning the value of each field in the attribute table except for the geometry colum.
- How to get the size of file in C++ - 在C++中如何获取文件的大小
- [转]how to programatically access built-in properties of open xml word doc(如何读取open xml格式文档属性)
- How To Automate Cleanup Of Dead Connections And INACTIVE 【如何自动清理ORACLE中的死连接和非活动会话】
- How to submit data in InfoPath form services
- A Stored Procedure To Count Numbers Of Rows In Table
- SQL Tips: How to detect duplicate rows in table
- [YFHomeViewController tableView:numberOfRowsInSection:]: unrecognized selector sent to instance 0x79
- How to prevent multiple clicks of a submit button in ASP.NET
- How to use outline levels to create a table of contents (TOC) in Word 2003 and in Word 2002
- How to change the language of oracle sqlplus from chinese to english in windows(如何将oracle sql plus中的中文变成英文版)
- 【iOS】Ambiguous reference to member 'tableView(_:numberOfRowsInSection:)'
- 转:Infopath Repeating Table 如何控制最大行数? Limiting number of repeating tables a user can add
- How-to find the SQL that using lots of temp tablespace in Oracle
- [转载]4 Ways to programmatically add a row to a repeating table in InfoPath
- How to Get the Frequency Table of a Categorical Variable as a Data Frame in R
- 如何调整Dreamhost主机PHP上传尺寸的限制/How to change the maximal size of uploading in your Dreamhost
- All-In-One Code Framework(AIO): 如何使用C#编写进程外的COM组件 (How to write an out-of-proc COM server in C#)
- How to access the properties of an object in Javascript