MovGP0        Über mich        Hilfen        Artikel        Weblinks        Literatur        Zitate        Notizen        Programmierung        MSCert        Physik      

WCF Adresses

Bearbeiten
Transport Schemes
Scheme Example Adresses
HTTP, HTTPS
  • http://localhost:80
  • http://localhost:80/MyService
  • http://localhost:443
TCP
  • net.tcp://localhost:808/MyService
UDP
  • soap.udp://localhost:8001/MyService
IPC (Named Pipes)
  • net.pipe://localhost/MyPipe
P2P network
  • net.p2p://localhost:3030/
MSMQ
  • net.msmq://localhost/private/MyQueue
  • net.msmq://localhost/MyQueue
Service Bus
  • sb://MyNamespace.servicebus.windows.net/
WebSocket / WebSocketSecure
  • ws://localhost:80/
  • wss://localhost:443/

Configure a Base Address

Bearbeiten
  • Do not use null to indicate standard base address, because it will cause an exception
var tcpBaseAddress = new Uri("net.tcp://localhost:8001/");
var httpBaseAddress = new Uri("http://localhost:8002/");

using(var host = new ServiceHost(typeof(MyService), tcpBaseAddress, httpBaseAddress))
{
   // ...
}
web.config
<system.serviceModel>
<services>
   <service name="MyNamespace.MyService">
      <host>
         <baseAddresses>
            <add baseAddress="net.tcp://localhost:8001/" />
            <add baseAddress="http://localhost:8002/" />
         </baseAddresses>
      </host>
      <!-- ... -->
   </service>
</system.serviceModel>

Reserve a Port

Bearbeiten

Reserve Port for a specific user, such that the service doesn't need admin rights

netsh http add urlacl url="http://+:8001/" user="DOMAIN\User"