Using .NET codes to set queryfield of webservice ?

T

Taggy

hi, my infopath template have a webservice data connection called
"getUserInfo". The webservice requires 1 argument, "userid" and return a few
values.

I am able to get the return value of the webservice by,
thisXDocument.DataObjects["getUserInfo"].Query();
string str =
thisXDocument.DataObjects["getUserInfo"].DOM.selectSingleNode("//Table/NAME").text;

But I am having problem in setting the input argument for the webservice.
Tried this, but it dun work
thisXDocument.DataObjects["getUserInfo"].DOM.selectSingleNode("//USERID")="taggy";

Can someone teach me please.

Thanks & Regards
Taggy
 
E

em

hi,
1) check if the XPath expression ("//USERID") really points to the
attribute/element you want to change (if USERID is an attribut it must read
as "//@USERID")
2) add the text property to the expression:
thisXDocument.DataObjects["getUserInfo"].DOM.selectSingleNode("//USERID").text="taggy";

regards
em
 
T

Taggy

hi em,

thanks for ur reply,
I tried to query a .NET webservice,

[WebMethod]
public string HelloWorld(string name)
{ return "Hello World ... " + name; }



In Infopath code, I tried this:
this.thisXDocument.DataObjects["HelloWorld"].DOM.selectSingleNode("//name").
text="123"; //line 50
this.thisXDocument.DataObjects["HelloWorld"].Query(); //line 51

But I got this error:
System.NullReferenceException
Object reference not set to an instance of an object.
at InfoPathProject3.InfoPathProject3.CTRL7_5_OnClick(DocActionEvent e) in
c:\documents and settings\adminstrator\my documents\visual studio
projects\infopathproject3\formcode.cs:line 50
at
Microsoft.Office.Interop.InfoPath.SemiTrust._ButtonEventSink_SinkHelper.OnCl
ick(DocActionEvent pEvent)

I tried using selectSingleNode("//@name") also, but still get the same
error.

Please advise,
thanks & regards
Taggy



em said:
hi,
1) check if the XPath expression ("//USERID") really points to the
attribute/element you want to change (if USERID is an attribut it must read
as "//@USERID")
2) add the text property to the expression:
thisXDocument.DataObjects["getUserInfo"].DOM.selectSingleNode("//USERID").te
xt="taggy";

regards
em

Taggy said:
hi, my infopath template have a webservice data connection called
"getUserInfo". The webservice requires 1 argument, "userid" and return a few
values.

I am able to get the return value of the webservice by,
thisXDocument.DataObjects["getUserInfo"].Query();
string str =
thisXDocument.DataObjects["getUserInfo"].DOM.selectSingleNode("//Table/NAME"
).text;
But I am having problem in setting the input argument for the webservice.
Tried this, but it dun work.
thisXDocument.DataObjects["getUserInfo"].DOM.selectSingleNode("//USERID")="t
aggy";
Can someone teach me please.

Thanks & Regards
Taggy
 
T

Taggy

hi em,

thanks for ur reply,
I tried to query a .NET webservice,

[WebMethod]
public string HelloWorld(string name)
{ return "Hello World ... " + name; }



In Infopath code, I tried this:
this.thisXDocument.DataObjects["HelloWorld"].DOM.selectSingleNode("//name").
text="123"; //line 50
this.thisXDocument.DataObjects["HelloWorld"].Query(); //line 51

But I got this error:
System.NullReferenceException
Object reference not set to an instance of an object.
at InfoPathProject3.InfoPathProject3.CTRL7_5_OnClick(DocActionEvent e) in
c:\documents and settings\adminstrator\my documents\visual studio
projects\infopathproject3\formcode.cs:line 50
at
Microsoft.Office.Interop.InfoPath.SemiTrust._ButtonEventSink_SinkHelper.OnCl
ick(DocActionEvent pEvent)

I tried using selectSingleNode("//@name") also, but still get the same
error.

Please advise,
thanks & regards
Taggy


em said:
hi,
1) check if the XPath expression ("//USERID") really points to the
attribute/element you want to change (if USERID is an attribut it must read
as "//@USERID")
2) add the text property to the expression:
thisXDocument.DataObjects["getUserInfo"].DOM.selectSingleNode("//USERID").te
xt="taggy";

regards
em

Taggy said:
hi, my infopath template have a webservice data connection called
"getUserInfo". The webservice requires 1 argument, "userid" and return a few
values.

I am able to get the return value of the webservice by,
thisXDocument.DataObjects["getUserInfo"].Query();
string str =
thisXDocument.DataObjects["getUserInfo"].DOM.selectSingleNode("//Table/NAME"
).text;
But I am having problem in setting the input argument for the webservice.
Tried this, but it dun work.
thisXDocument.DataObjects["getUserInfo"].DOM.selectSingleNode("//USERID")="t
aggy";
Can someone teach me please.

Thanks & Regards
Taggy
 
E

em

hi,
it seems that the xpath expression is not correct. Try it this way:
thisXDocument.DataObjects("HelloWorld").DOM.selectSingleNode("//*[local-name()='xxx']").text
= "123" and be aware, that the name of the element (in this case "xxx") is
case-sensitive.
good luck!

Taggy said:
hi em,

thanks for ur reply,
I tried to query a .NET webservice,

[WebMethod]
public string HelloWorld(string name)
{ return "Hello World ... " + name; }



In Infopath code, I tried this:
this.thisXDocument.DataObjects["HelloWorld"].DOM.selectSingleNode("//name").
text="123"; //line 50
this.thisXDocument.DataObjects["HelloWorld"].Query(); //line 51

But I got this error:
System.NullReferenceException
Object reference not set to an instance of an object.
at InfoPathProject3.InfoPathProject3.CTRL7_5_OnClick(DocActionEvent e) in
c:\documents and settings\adminstrator\my documents\visual studio
projects\infopathproject3\formcode.cs:line 50
at
Microsoft.Office.Interop.InfoPath.SemiTrust._ButtonEventSink_SinkHelper.OnCl
ick(DocActionEvent pEvent)

I tried using selectSingleNode("//@name") also, but still get the same
error.

Please advise,
thanks & regards
Taggy


em said:
hi,
1) check if the XPath expression ("//USERID") really points to the
attribute/element you want to change (if USERID is an attribut it must read
as "//@USERID")
2) add the text property to the expression:
thisXDocument.DataObjects["getUserInfo"].DOM.selectSingleNode("//USERID").te
xt="taggy";

regards
em

Taggy said:
hi, my infopath template have a webservice data connection called
"getUserInfo". The webservice requires 1 argument, "userid" and return a few
values.

I am able to get the return value of the webservice by,
thisXDocument.DataObjects["getUserInfo"].Query();
string str =
thisXDocument.DataObjects["getUserInfo"].DOM.selectSingleNode("//Table/NAME"
).text;
But I am having problem in setting the input argument for the webservice.
Tried this, but it dun work.
thisXDocument.DataObjects["getUserInfo"].DOM.selectSingleNode("//USERID")="t
aggy";
Can someone teach me please.

Thanks & Regards
Taggy
 
T

Taggy

hi em,

thanks for your help! finally got it.


thisXDocument.GetDOM("HelloWorld").selectSingleNode("//*[local-name()='name'
]").text="abc";
thisXDocument.DataObjects["HelloWorld"].Query();
thisXDocument.UI.Alert
(

thisXDocument.GetDOM("HelloWorld").selectSingleNode("//*[local-name()='Hello
WorldResult']").text
);


My main problem is poor command of xpath query skill,
kept trying this and it do not works.
thisXDocument.GetDOM("HelloWorld").selectSingleNode("//tns:name").text="abc"
;

Thanks & regards
Taggy



em said:
hi,
it seems that the xpath expression is not correct. Try it this way:
thisXDocument.DataObjects("HelloWorld").DOM.selectSingleNode("//*[local-name
()='xxx']").text
= "123" and be aware, that the name of the element (in this case "xxx") is
case-sensitive.
good luck!

Taggy said:
hi em,

thanks for ur reply,
I tried to query a .NET webservice,

[WebMethod]
public string HelloWorld(string name)
{ return "Hello World ... " + name; }



In Infopath code, I tried this:
this.thisXDocument.DataObjects["HelloWorld"].DOM.selectSingleNode("//name").
text="123"; //line 50
this.thisXDocument.DataObjects["HelloWorld"].Query(); //line 51

But I got this error:
System.NullReferenceException
Object reference not set to an instance of an object.
at InfoPathProject3.InfoPathProject3.CTRL7_5_OnClick(DocActionEvent e) in
c:\documents and settings\adminstrator\my documents\visual studio
projects\infopathproject3\formcode.cs:line 50
at
Microsoft.Office.Interop.InfoPath.SemiTrust._ButtonEventSink_SinkHelper.OnCl
ick(DocActionEvent pEvent)

I tried using selectSingleNode("//@name") also, but still get the same
error.

Please advise,
thanks & regards
Taggy


em said:
hi,
1) check if the XPath expression ("//USERID") really points to the
attribute/element you want to change (if USERID is an attribut it must read
as "//@USERID")
2) add the text property to the expression:
thisXDocument.DataObjects["getUserInfo"].DOM.selectSingleNode("//USERID").te
xt="taggy";
regards
em

:

hi, my infopath template have a webservice data connection called
"getUserInfo". The webservice requires 1 argument, "userid" and
return a
few
values.

I am able to get the return value of the webservice by,
thisXDocument.DataObjects["getUserInfo"].Query();
string str =
thisXDocument.DataObjects["getUserInfo"].DOM.selectSingleNode("//Table/NAME"
).text;
But I am having problem in setting the input argument for the webservice.
Tried this, but it dun work.
thisXDocument.DataObjects["getUserInfo"].DOM.selectSingleNode("//USERID")="t
aggy";
Can someone teach me please.

Thanks & Regards
Taggy
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top