WCF test client after windows 10 and svcConfigEditor
Asked Answered
B

4

5

Been using the WCF Test Client for years now, testing externally hosted webservices that I consume.

I have often cursed about the inabillity to save a standard confuguration with settings about the bindings, as I for some of the methods needs to increse the maxRecievedMessageSize byond the standard 65536 - as well as occasionally other settings.

I would normally have to use the scvConfigEditor to update each time. But I lived with that.

UNFORTUNATLY - after updating to windows 10 and re-installing everything I can no longer edit the config file. Or I can edit, but the service will not reload with the new settings as it would before. I have tried editing the file manually also, and I have tried to refresh the service after saving both with the editor and manually..

Would anybody know the reason or a fix for this?

Berlauda answered 20/2, 2018 at 13:2 Comment(0)
A
3

I had the same problem and compared my new installation to my old working installation.

First you have to deselect Always regenerate config when launching services from Tools->Option and exit WCF Test Client.

I found that the new installation was missing the AddressToConfigMapping.xml file in C:\Users\<user>\Documents\Test Client Projects\15.0\CachedConfig folder, which I had to create.

The content of the AddressToConfigMapping.xml file should be:

<Mapping>
  <Entry>
    <Address>http://localhost/TestService.svc</Address>
    <ConfigPath>C:\Users\<user>\Documents\Test Client Projects\15.0\CachedConfig\Client.dll.config</ConfigPath>
  </Entry>
</Mapping>

Then you can then edit the config file in scvConfigEditor and save the file to C:\Users\<user>\Documents\Test Client Projects\15.0\CachedConfig\Client.dll.config and replace the content of the address element with the service you are testing.

Now the saved configuration should be loaded, when you add the service in the WCF Test Client.

If you have to test multiple services, it is possible to add additional entries for different services with different configuration in the AddressToConfigMapping.xml file.

Assortment answered 18/6, 2018 at 12:48 Comment(0)
M
3

I have found another solution for this problem. You can edit config file without svcConfigEditor using Restore to Default Config option.

Steps:

  1. Run WCF Test Client and add service.
  2. Right click on config file and select Copy Full Path.
  3. Open folder with Client.dll.config.
  4. Edit default.config.
  5. Return to WCF Test Client.
  6. Right click on config file and select Restore to Default Config.

This will replace Client.dll.config with default.config and re-apply settings.

Mall answered 28/5, 2021 at 14:22 Comment(0)
T
0

Krimson's answer is correct. With Windows 10 and VisualStudio 2018 Community, the directory and mapping files are not being created. You can work around it by creating them yourself.

One additional point that I would like to stress is the value that needs to be provided for the Address field MUST be the service's metadata endpoint and not simply the service's endpoint. You typically can find the metadata endpoint in your App.config as

 <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
    <host>
      <baseAddresses>
        <add baseAddress="http://localhost:80/MyTravelAgency/" />
      </baseAddresses>
    </host>

In my service, the AddressToConfigMapping.xml file would look like

 <Mapping>
   <Entry>
     <Address>http://localhost/MyTravelAgency/mex</Address>
     <ConfigPath>C:\Users\Roger\Documents\Test Client Projects\15.0\CachedConfig\Client.dll.config</ConfigPath>
   </Entry>
  </Mapping>
Taproot answered 10/2, 2019 at 5:9 Comment(0)
P
0

The problem seems to be the saving behaviour of svcConfigEditor. Normally a file changed event would be raised but a change coming from svcConfigEditor raises an renamed event which is not handled by wcf test client. One way to get it to work is to reverse engineer wcf test client and extend the FileSystemWatcher to grab the renamed event. Another way is to open up your favorite text editor and save the configuration file with a new blank line after you edit it. In this case the changed event is fired and the reload screen appears.

The configuration file can be found in %localappdata%\Temp\Test Client Projects\

To grab the renamed event you need to handle fileSystemWatcher.Renamed and to extend the fileSystemWatcher.NotifyFilter with the following settings:

NotifyFilters.Attributes | NotifyFilters.CreationTime | NotifyFilters.FileName | NotifyFilters.LastAccess | NotifyFilters.LastWrite | NotifyFilters.Size | NotifyFilters.Security

The related code to invoke if fileSystemWatcher.Renamed occurs is:

string fullPath = eventArgs.FullPath;
ServiceProject serviceProject = this.workspace.FindServiceProject(fullPath);
if (serviceProject != null)
{
    this.TryRefreshConfig(serviceProject);
}
Polyamide answered 4/4, 2019 at 8:9 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.