Configure WCF Service address in Xamarion iOS

84 views Asked by At

In my Xamario.iOS application which I'm doing in VisualStudio, I'm consuming WCF services by adding the ServiceReferences (Add ServiceReference) and I get my services added in ServiceReference folder as below:

  • LoginService (This is of Login.svc)
  • RegisterService (This is of Register.svc)

my code looks like
LoginRequest req = new LoginRequest()
req.username = "test"
req.password = "test"

LoginResponse res = LoginService.Authenticate(req)

and I get my response which is fine.

But I would like to configure the WCF service's address dynamically, so that in future I can change my service URL just in one place rather than updating all the services under ServiceReference folder. Right now, I don't find any config file which has the configuration details for the WCF services added, in my Xamarin.iOS project.

If I create the Service Client in code behind, I can get the client for each service, but in such case how can I have my LoginRequest and LoginResponse type?

1

There are 1 answers

4
Jason On

Your client class should have a constructor overload that allows you to specify the address of the endpoint.