Nenad
Nenad

Reputation: 73

German umlauts in EndpointAddress with net.tcp

I'm trying to make instance of class EndpointAddress where parameter contains German umlaut.

For example:

EndpointAddress endpointAddress = new EndpointAddress("net.tcp://süd:8001/EmployeeService");

It always throws exception that given uri cannot be parsed. I have tried to replace the umlaut with an encoded value, but I get same exception:

Invalid URI: The hostname could not be parsed.

Did anyone had same problem before? Thank you in advance.

Upvotes: 6

Views: 537

Answers (4)

Praburaj
Praburaj

Reputation: 11547

Just as an extra note. WCF added support for IDN (both for hosting service + WCF client talking to a service with IDN name) in .Net 4.5. This documentation has some information about this.

So this exception will disappear as soon as you compile your app against .net 4.5

Upvotes: 2

deramko
deramko

Reputation: 2834

As suggested you have to enable IRI and IDN parsing before using this kind of URI.

Add this to your app.config:

 <configuration>
     <uri>
         <idn enabled="All" />
         <iriParsing enabled="true" />
     </uri>
 </configuration>

Upvotes: 1

hobbs
hobbs

Reputation: 240601

The parser probably doesn't know how to work with internationalized domain names (IDN). If you want to have such hostnames, you're going to have to do the Punycode encoding yourself. I haven't used it, but there's a core function IdnMapping.GetAscii that looks suitable — something like

EndpointAddress endpointAddress = new EndpointAddress(
    "net.tcp://" + IdnMapping.GetAscii("süd") + ":8001/EmployeeService"
);

will perhaps work (forgive me if it doesn't, C# isn't my language).

Upvotes: 4

bash.d
bash.d

Reputation: 13217

Try to use

string uri = System.Uri.EscapeDataString("net.tcp://süd:8001/EmployeeService");

Look here for further reference.

Upvotes: -2

Related Questions