Ingó Vals
Ingó Vals

Reputation: 4898

Consuming a web service in a WPF app

I wan't to consume a web service inside a WPF app.

I can add the Service Reference and all the objects show up in the object browser except for the ServiceClient itself.

I tried adding the service to a console application and it all worked out there.

Is there some limit on WPF apps using web services.

I noticed that in the console app he added a ServiceModel node into the app.config file but not in the WPF app.config file.

Is there anything I can do to make it work?

Upvotes: 1

Views: 5959

Answers (2)

Bahri Gungor
Bahri Gungor

Reputation: 2319

To answer your question specifically, no, there is nothing in WPF that would prevent you from using WCF to create a web service reference.

I have, however, run into issues (in general) with using the "Add Service Reference" for generating the proxy and service class.

I would start by using the WCF Test Client to test that your web service operates correctly and a generic proxy can be generated.

Once the WCF Test Client works, I would clean out the existing service reference. Make sure everything is deleted. Then add the service reference again.

If you have a complex web service, or the interface contains complex structures, you may want to look into using svcutil.exe to generate your proxy.

This is the best answer I can give with the information you've provided. I believe your issue is with the WCF proxy generation, however, not WPF. When learning about WPF, it is best to keep your service as simple as possible and verify that the communication works before adding anything that could break WPF (like passing a dataset or class structure).

P.S. Your executable app.config MUST have a system.serviceModel section to communicate, but its absence will not affect the reference and proxy generation.

Upvotes: 3

Muad'Dib
Muad'Dib

Reputation: 29256

now that you have generated the API, its time to start adding class instances and calling methods. really, that is all there is too it.

Check out this codeproject article for more detailed help.

BTW, a simple google for "using web services in wpf" revealed a metric-but-ton of results.

Upvotes: -1

Related Questions