Ho riscontrato un problema nel chiamare un endpoint WCF webHttpBinding utilizzando HttpClient e la proprietà BaseAddress.HttpClient con BaseAddress
HttpClient
ho creato un'istanza HttpClient specificando la proprietà BaseAddress come endpoint host locale.
GetAsync chiamata
ho quindi chiamare il metodo GetAsync passando nel supplementare inforamtion Uri.
HttpResponseMessage response = await client.GetAsync(string.Format("/Layouts/{0}", machineInformation.LocalMachineName()));
endpoint di Service
[OperationContract]
[WebGet(UriTemplate = "/Layouts/{machineAssetName}", ResponseFormat = WebMessageFormat.Json)]
List<LayoutsDto> GetLayouts(string machineAssetName);
Problema
Il problema che sto avendo è che il è che /AndonService.svc
parte del BaseAddress viene troncato in modo che il la chiamata risultante va a https://localhost:44302/Layouts/1100-00277
piuttosto che https://localhost:44302/AndonService.svc/Layouts/1100-00277
risultante in un 404 non trovato.
C'è un motivo per cui il BaseAddress viene troncato nella chiamata GetAsync? Come faccio a evitare questo?
possibile duplicato di [? Perché HttpClient BaseAddress non funziona] (http://stackoverflow.com/questions/23438416/why-is-httpclient-baseaddress- non funzionante) –