> Try checking the string returned by oWebService.DOM.xml. It should contain
> all the namespaces that are being used. You could then use this information
[quoted text clipped - 50 lines]
> > So, my guess is that because I'm not specifying the correct namespace
> > prefix, it can't find the AccountName data in oResponse?
If you look closely, you will see that there is a namespace defined on
GetMyProfileResponse:
<GetMyProfileResponse xmlns="http://tempuri.org/">
See the xmlns definition behind GetMyProfileResponse? If you look at the
namespaces defined under dfs:myFields, you will see that the prefix "tns" was
defined for "http://tempuri.org":
xmlns:tns="http://tempuri.org/"
So to retrieve GetMyProfileResponse, you would have to use something like:
var oResponse =
oWebService.DOM.selectSingleNode("/dfs:myFields/dfs:dataFields/tns:GetMyProfileResponse");
Just for fun, add the following line to your code and see what it returns:
XDocument.UI.Alert(oWebService.DOM.selectSingleNode("/dfs:myFields/dfs:dataFields/tns:GetMyProfileResponse").xml);
By studying the result, you will know that you would have to retrieve
AccountName as follows:
var oAccountName =
oWebService.DOM.selectSingleNode("/dfs:myFields/dfs:dataFields/tns:GetMyProfileResponse/tns:GetMyProfileResult/tns:AccountName").text;
If you want to know all about the use of namespaces in XML, check out the
following document: http://www.w3.org/TR/xmlschema-0/
There is no need to have nightmares over namespaces, and it's okay to be new
to InfoPath and Sharepoint. :)
---
S.Y.M. Wong-A-Ton
> I've gotten the output and found that the Web Service is returning no prefix
> at all. The schema looks like this:
[quoted text clipped - 86 lines]
> > > So, my guess is that because I'm not specifying the correct namespace
> > > prefix, it can't find the AccountName data in oResponse?
S.Y.M. Wong-A-Ton - 11 Feb 2006 11:24 GMT
Correction: oAccountName returns a string in this case.
---
S.Y.M. Wong-A-Ton
> If you look closely, you will see that there is a namespace defined on
> GetMyProfileResponse:
[quoted text clipped - 121 lines]
> > > > So, my guess is that because I'm not specifying the correct namespace
> > > > prefix, it can't find the AccountName data in oResponse?
DGibson - 22 Feb 2006 20:49 GMT
I appreciate the assistance so far, but I'm still having problems.
I've already removed the extra "my:" namespace declaration, so that line now
only says: oWebService.DOM.setProperty("SelectionNamespaces",
"xmlns:dfs='http://schemas.microsoft.com/office/infopath/2003/dataFormSolution'
xmlns:tns='http://tempuri.org' "); (I inserted the space at the end just in
case).
I went back to the Status Report example (which works fine) and inserted the
"XDocument.UI.Alert(oWebService.DOM.xml);" line and the output is the same
schema and namespaces that I was getting back from my form. This is strange
though because the example's code redeclares the tempuri.org namespace with a
"s0" prefix and that example works just fine:
oWebService.DOM.setProperty("SelectionNamespaces",
"xmlns:dfs='http://schemas.microsoft.com/office/infopath/2003/dataFormSolution' xmlns:s0='http://tempuri.org/'");
Taking the example code and replacing "s0" with "tns" just brings me back to
the "'null' is null or not an object" error.
I also attempted to insert the following line:
XDocument.UI.Alert(oWebService.DOM.selectSingleNode("/dfs:myFields/dfs:dataFields/tns:GetMyProfileResponse").xml);
This line returns an error of "Object required".
I feel like I understand namespaces a little better, but I still can't point
out why the one form works and the other doesn't.
> If you look closely, you will see that there is a namespace defined on
> GetMyProfileResponse:
[quoted text clipped - 121 lines]
> > > > So, my guess is that because I'm not specifying the correct namespace
> > > > prefix, it can't find the AccountName data in oResponse?
S.Y.M. Wong-A-Ton - 26 Feb 2006 12:41 GMT
The only thing I can advise you is to save your InfoPath form locally on
disk, open it in Notepad, and study its XML structure to see where you might
be going wrong. You can also download a tool called "Visual XPath" from
http://weblogs.asp.net/nleghari/articles/tools.aspx, load the XML from the
InfoPath form into it, and type in XPath expressions to find the correct one
to retrieve the nodes you require.
---
S.Y.M. Wong-A-Ton
> I appreciate the assistance so far, but I'm still having problems.
>
[quoted text clipped - 147 lines]
> > > > > So, my guess is that because I'm not specifying the correct namespace
> > > > > prefix, it can't find the AccountName data in oResponse?
DGibson - 28 Feb 2006 20:10 GMT
Visual XPath was exactly what I needed. I was able to get the proper XPath
to the node I wanted and the code now works as intended.
Many thanks!
David
> The only thing I can advise you is to save your InfoPath form locally on
> disk, open it in Notepad, and study its XML structure to see where you might
[quoted text clipped - 156 lines]
> > > > > > So, my guess is that because I'm not specifying the correct namespace
> > > > > > prefix, it can't find the AccountName data in oResponse?
S.Y.M. Wong-A-Ton - 01 Mar 2006 12:06 GMT
Glad you finally got it to work.
---
S.Y.M. Wong-A-Ton
> Visual XPath was exactly what I needed. I was able to get the proper XPath
> to the node I wanted and the code now works as intended.
[quoted text clipped - 163 lines]
> > > > > > > So, my guess is that because I'm not specifying the correct namespace
> > > > > > > prefix, it can't find the AccountName data in oResponse?
> I've gotten the output and found that the Web Service is returning no prefix
> at all.
Remove the definition you added earlier for the "my" namespace from your
code. I spotted that you are missing a space behind "
xmlns:tns='http://tempuri.org' " in the oWebService.DOM.setProperty(...)
method. That could be the culprit.
---
S.Y.M. Wong-A-Ton
> I've gotten the output and found that the Web Service is returning no prefix
> at all. The schema looks like this:
[quoted text clipped - 86 lines]
> > > So, my guess is that because I'm not specifying the correct namespace
> > > prefix, it can't find the AccountName data in oResponse?