I have a WCF-service running inside a windows service. There is an mex-endpoint at http://localhost/...
I can navigate to it via a browser but if I use MetadataResolver.Resolve, the above mentioned exception will be thrown (with inner exception of "The remote server returned an error: (404) Not Found.").
The only difference I spotted is, that the browser uses a get and Visual Studio a post.
What can I do to make that run?
Here the server-side:
protected override void OnStart(string[] args) {
_serviceHost = new ServiceHost(new TestService());
var binding = new WSHttpBinding();
_serviceHost.AddServiceEndpoint(typeof(ITestService),
binding,
"http://localhost:8081/WindowsServiceWcf/service");
_serviceHost.Open();
}
Here the config:
<system.serviceModel>
<services>
<service name="WindowsServiceWcf.TestService" behaviorConfiguration="MexGet" />
</services>
<behaviors>
<serviceBehaviors>
<behavior name="MexGet">
<serviceMetadata httpGetEnabled="true" httpGetUrl="http://localhost/WindowsServiceWcf/service/TestServiceMexAddress" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
Here the client-side:
private void SetUpService() {
var mexUri = new Uri("http://localhost/WindowsServiceWcf/service/TestServiceMexAddress");
var metaAddress = new EndpointAddress(mexUri);
try {
var endpoints = MetadataResolver.Resolve(typeof(TestService), metaAddress);
} catch (Exception) {
// above mentioned exception
}
}
I hope, it's clearer now!?