0

I have an application where users will connect to one or more WCF services running on machines in their network. Because the address of these connections are not known at the time of installation, the application must programmatically connect to these services (i.e. I cannot use Add Service Reference). I have the connection working using the following code:

string url = "...the url...";
BasicHttpBinding binding = new BasicHttpBinding();            
EndpointAddress address = new EndpointAddress(url);
ILicenseService service = ChannelFactory<ILicenseService>.CreateChannel(binding, address);

However, some of the members of my service class return an ObservableCollection of elements. I know how to change the collection type in the Service Reference dialog box, using Advanced settings. However, I cannot figure out a way to set this value programatically so that my client knows to read the return type as an ObservableCollection instead of a List. Any clues?

James Montagne
  • 77,516
  • 14
  • 110
  • 130
Daniel Simpkins
  • 674
  • 5
  • 18

1 Answers1

0

It should deserialize to the type which is defined by the interface of the service class, or to the type of the property of the serialized object. Try just changing the collection type on the interface/class.

By the way, you stated that you cannot use Add service reference because the service endpoint address is not known at compile time, but that shouldn't stop you from using it. Obtain a copy of the WSDL and import it in Add service reference from local WSDL file, then when creating a service proxy specify the actual endpoint address as shown here.

Community
  • 1
  • 1
Boris B.
  • 4,933
  • 1
  • 28
  • 59
  • Thanks. I used your comment in addition to this: http://stackoverflow.com/questions/6119124/c-sharp-client-how-to-invoke-wsdl-file – Daniel Simpkins May 14 '13 at 19:00