Web Services C#

S

Shem

Hi Folks,

If I create a Infopath form in C# and I add a web reference to my web
service. How do I get a hold of the web services via the code and execute
it's methods??

Cheers
 
D

Davie

Hi Shem, you would access the webservice in the code behind of infopath
just as you would if you weren't using infopath.

So if you have a webservice defined as Service1 and you have a method
called

[WebMethod]
public string helloworld(){
return "Hello World";
}

you could write in you FormCode.cs file

Service1 myService = new Service1();
thisXDocument.UI.Alert(myService.HelloWorld());

I hope this helps.

-- Davie
http://dotnetjunkies.com/weblog/dsweis/
 
D

Davie

Hi Shem, you would access the webservice in the code behind of infopath
just as you would if you weren't using infopath.

So if you have a webservice defined as Service1 and you have a method
called

[WebMethod]
public string helloworld(){
return "Hello World";
}

you could write in you FormCode.cs file

Service1 myService = new Service1();
thisXDocument.UI.Alert(myService.HelloWorld());

I hope this helps.

-- Davie
http://dotnetjunkies.com/weblog/dsweis/
 
D

Davie

Hi Shem, you would access the webservice in the code behind of infopath
just as you would if you weren't using infopath.

So if you have a webservice defined as Service1 and you have a method
called

[WebMethod]
public string helloworld(){
return "Hello World";
}

you could write in you FormCode.cs file

Service1 myService = new Service1();
thisXDocument.UI.Alert(myService.HelloWorld());

I hope this helps.

-- Davie
http://dotnetjunkies.com/weblog/dsweis/
 
M

Matthew Blain \(Serriform\)

Or you can use the DataAdapters just like you would using script for any
other InfoPath form.

--Matthew Blain
http://tips.serriform.com/
http://www.developingsolutionswithinfopath.com/

Davie said:
Hi Shem, you would access the webservice in the code behind of infopath
just as you would if you weren't using infopath.

So if you have a webservice defined as Service1 and you have a method
called

[WebMethod]
public string helloworld(){
return "Hello World";
}

you could write in you FormCode.cs file

Service1 myService = new Service1();
thisXDocument.UI.Alert(myService.HelloWorld());

I hope this helps.

-- Davie
http://dotnetjunkies.com/weblog/dsweis/

Hi Folks,

If I create a Infopath form in C# and I add a web reference to my web
service. How do I get a hold of the web services via the code and execute
it's methods??

Cheers
 
S

Shem

Hi this has been really helpful except when I call teh method I always get
Unauthorized access even though I am ana dministrator. I also have Sharepoint
sevices installed which does some crazy stuff. Are you familiar with
Sharepoint?

Davie said:
Hi Shem, you would access the webservice in the code behind of infopath
just as you would if you weren't using infopath.

So if you have a webservice defined as Service1 and you have a method
called

[WebMethod]
public string helloworld(){
return "Hello World";
}

you could write in you FormCode.cs file

Service1 myService = new Service1();
thisXDocument.UI.Alert(myService.HelloWorld());

I hope this helps.

-- Davie
http://dotnetjunkies.com/weblog/dsweis/

Hi Folks,

If I create a Infopath form in C# and I add a web reference to my web
service. How do I get a hold of the web services via the code and execute
it's methods??

Cheers
 
D

Davie

Try adding this...

service1.Credentials = System.Net.CredentialCache.DefaultCredentials;

-- Davie
http://dotnetjunkies.com/weblog/dsweis/
Hi this has been really helpful except when I call teh method I always get
Unauthorized access even though I am ana dministrator. I also have Sharepoint
sevices installed which does some crazy stuff. Are you familiar with
Sharepoint?

Davie said:
Hi Shem, you would access the webservice in the code behind of infopath
just as you would if you weren't using infopath.

So if you have a webservice defined as Service1 and you have a method
called

[WebMethod]
public string helloworld(){
return "Hello World";
}

you could write in you FormCode.cs file

Service1 myService = new Service1();
thisXDocument.UI.Alert(myService.HelloWorld());

I hope this helps.

-- Davie
http://dotnetjunkies.com/weblog/dsweis/

Hi Folks,

If I create a Infopath form in C# and I add a web reference to my
web
service. How do I get a hold of the web services via the code and execute
it's methods??

Cheers
 

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