We might think that it is quite easy to swtich from HTTP to HTTPS in the WCF Service binding configuration, as we just simply replace the HTTP in http:// WCFServiceServer/WCFServce.svc to HTTPS https:// WCFServiceServer/WCFServce.svc
when you launch the app and call the wcf service, you will encounter an exception during the service consumption.
it is little difference between the HTTP vs HTTPS binding in DAX WCF service configuration. this is better approach to have two configurations enable in the web.config file. I highlight the difference in bold.
one is the basicHttpBinding for http link
<basicHttpBinding>
<binding name="reqReplyEndpoint">
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Windows" />
</security>
</binding>
<binding name="DaxBinding" closeTimeout="00:01:00" openTimeout="00:01:00"
receiveTimeout="00:01:00" sendTimeout="00:01:00" maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="32" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Windows" />
</security>
</binding>
</basicHttpBinding>
another is basicHttpsBinding for https link
<basicHttpsBinding>
<binding name="SecurereqReplyEndpoint">
<security mode="Transport">
<transport clientCredentialType="Windows" />
</security>
</binding>
<binding name="DaxSecureBinding" closeTimeout="00:01:00" openTimeout="00:01:00"
receiveTimeout="00:01:00" sendTimeout="00:01:00" maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="32" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<security mode="Transport">
<transport clientCredentialType="Windows" />
</security>
</binding>
</basicHttpsBinding>
a blog to share Microsoft technologies Azure, DotNet, SharePoint, SQL Server,JavaScript Framework: Node.JS, Angular, React
Showing posts with label Web Service. Show all posts
Showing posts with label Web Service. Show all posts
Wednesday, October 19, 2016
Tuesday, March 6, 2012
Submit InfoPath Form Data to Web Service or WCF in InfoPath 2010
when we create a InfoPath form and configure the submit option to allow the user submit the form
to Web service or WCF(windows communication Foundation).

when you construct the data connection by following the data connection wizard, please ensure
you select Entire Form(XML document, Including processing instruction), when you decide to
submit the form to web service and parse the data in the web service.

in the web service you will need to have the following code snippet to parse the xml data and process it and push them back to the Database
[WebMethod]
public void SubmitDocument(XmlDocument doc)
{
XmlNamespaceManager nsManager = new XmlNamespaceManager(doc.NameTable);
nsManager.AddNamespace("my", "http://schemas.microsoft.com/office/infopath/2003/myXSD/2012-02-28T14:26:46");
nsManager.AddNamespace("dfs", "http://schemas.microsoft.com/office/infopath/2003/dataFormSolution");
XmlNode root = doc.DocumentElement;
XmlNode node = root.SelectSingleNode("/dfs:IPDocument/my:myFields", nsManager);
string recycleItemID = node.SelectSingleNode("/dfs:IPDocument/my:myFields/my:RecycleItemID", nsManager).InnerText;
string recycleItemName = node.SelectSingleNode("/dfs:IPDocument/my:myFields/my:RecycleItemName", nsManager).InnerText;
string recycleItemDesc = node.SelectSingleNode("/dfs:IPDocument/my:myFields/my:RecycleItemDescription", nsManager).InnerText;
string preferredMeasurmentUnitID = node.SelectSingleNode("/dfs:IPDocument/my:myFields/my:PreferredMeasurementUnitID", nsManager).InnerText;
RecycleItem recycleItemObj = new RecycleItem();
recycleItemObj.RecycleItemID = recycleItemID;
recycleItemObj.RecyleItemName = recycleItemName;
recycleItemObj.RecycleItemDescription = recycleItemDesc;
recycleItemObj.PreferredMeasureUnitID = Convert.ToInt32(preferredMeasurmentUnitID);
Update(recycleItemObj);
}
since we need to have the My namespace for parsing and processing in the code. usually i will use the debug mode to get the My Namespace by the trapping the submit XMLDocument in visual studio 2010. I just figure out we can retrieve the My Namespace value in the InfoPath Designer.
it is very simple and straightforward. select the group field name MyFields, then right click to view the Properties.

click on the Details tab. you will find the Namespace of MyFields. the Namespace is fixed for this group after it is created.
to Web service or WCF(windows communication Foundation).
when you construct the data connection by following the data connection wizard, please ensure
you select Entire Form(XML document, Including processing instruction), when you decide to
submit the form to web service and parse the data in the web service.
in the web service you will need to have the following code snippet to parse the xml data and process it and push them back to the Database
[WebMethod]
public void SubmitDocument(XmlDocument doc)
{
XmlNamespaceManager nsManager = new XmlNamespaceManager(doc.NameTable);
nsManager.AddNamespace("my", "http://schemas.microsoft.com/office/infopath/2003/myXSD/2012-02-28T14:26:46");
nsManager.AddNamespace("dfs", "http://schemas.microsoft.com/office/infopath/2003/dataFormSolution");
XmlNode root = doc.DocumentElement;
XmlNode node = root.SelectSingleNode("/dfs:IPDocument/my:myFields", nsManager);
string recycleItemID = node.SelectSingleNode("/dfs:IPDocument/my:myFields/my:RecycleItemID", nsManager).InnerText;
string recycleItemName = node.SelectSingleNode("/dfs:IPDocument/my:myFields/my:RecycleItemName", nsManager).InnerText;
string recycleItemDesc = node.SelectSingleNode("/dfs:IPDocument/my:myFields/my:RecycleItemDescription", nsManager).InnerText;
string preferredMeasurmentUnitID = node.SelectSingleNode("/dfs:IPDocument/my:myFields/my:PreferredMeasurementUnitID", nsManager).InnerText;
RecycleItem recycleItemObj = new RecycleItem();
recycleItemObj.RecycleItemID = recycleItemID;
recycleItemObj.RecyleItemName = recycleItemName;
recycleItemObj.RecycleItemDescription = recycleItemDesc;
recycleItemObj.PreferredMeasureUnitID = Convert.ToInt32(preferredMeasurmentUnitID);
Update(recycleItemObj);
}
since we need to have the My namespace for parsing and processing in the code. usually i will use the debug mode to get the My Namespace by the trapping the submit XMLDocument in visual studio 2010. I just figure out we can retrieve the My Namespace value in the InfoPath Designer.
it is very simple and straightforward. select the group field name MyFields, then right click to view the Properties.
click on the Details tab. you will find the Namespace of MyFields. the Namespace is fixed for this group after it is created.
Subscribe to:
Posts (Atom)