Hi,
i have created the WhoAmI web service to get the username of the current
user using the form. I have added a textbox to the form and bound this to the
secondary datasource which is the whoami web service.
In the on load event of the form i retrieve the username and based on the
user i do something. But appearantly in the on load event this datasource has
not yet been fired so the username has not been retrieved when i want to do
the conditional action.
SO i tried to solve this by executing the datasource in code and retrieve
the username through the DOM with following code:
thisXDocument.DataObjects["GetUser"].Query();
ADOAdapterObject adapt =
(ADOAdapterObject)thisXDocument.DataObjects["GetUser"].QueryAdapter;
IXMLDOMDocument3 oSecondDoc =
(IXMLDOMDocument3)thisXDocument.DataObjects["GetUser"].DOM;
oSecondDoc.setProperty("SelectionNamespaces","xmlns:dfs=\"http://schemas.microsoft.com/office/infopath/2003/dataFormSolution\"
xmlns:d=\"http://schemas.microsoft.com/office/infopath/2003/ado/dataFields\"");
IXMLDOMNode oSecDocNode =
oSecondDoc.selectSingleNode("/dfs:myFields/dfs:dataFields");
//loop through oSecDocNode:
foreach (IXMLDOMNode oN in oSecDocNode.childNodes)
{
if (oN.nodeType == DOMNodeType.NODE_ELEMENT)
{
strUser = oN.selectSingleNode("@UserName").text;
}
}
But than i get a cast error. So can't i cast a sec. datasource which is a
web service to an "ADOAdapterObject"? How can i read this web service?
Thnx,
Stanley
Stanley - 14 Nov 2005 15:06 GMT
i solved it by not using the data connection but by just setting a web
refenence and using the web service in code.
> Hi,
>
[quoted text clipped - 34 lines]
>
> Stanley
virgul - 15 Nov 2005 09:24 GMT
Hi,
Instead of ADoAdaptateur use:
thisXDocument.DataObjects["GetUser"].Query();
IXMLDOMDocument2 oDomSearchHRG =
(IXMLDOMDocument2)thisXDocument.GetDOM("GetUser");
oSecondDoc.setProperty("SelectionNamespaces","xmlns:dfs=\"http://schemas.microsoft.com/office/infopath/2003/dataFormSolution\"");
IXMLDOMNode oSecDocNode =
oSecondDoc.selectSingleNode("/dfs:myFields/dfs:dataFields");
//loop through oSecDocNode:
foreach (IXMLDOMNode oN in oSecDocNode.childNodes)
{
if (oN.nodeType == DOMNodeType.NODE_ELEMENT)
{
strUser = oN.selectSingleNode("@UserName").text;
}
}
hope this help
++
Thierry
Stanley - 15 Nov 2005 10:52 GMT
Thnx for your response. But i think i will stick with the web service
solution i have tried. Or do you suggest using the dataconnection of IP
instead? Are there advantages/disadvantages using a a direct web service
connection instead through the data connection?
Thnx,
Stanley
> Hi,
>
[quoted text clipped - 21 lines]
>
> Thierry