WCF changing endpoint baseAdress
I have several questions about the following config file:
<system.serviceModel>
<bindings />
<services>
<service behaviorConfiguration="WcfReporting.Service1Behavior"
name="WcfReporting.Service1">
<endpoint address=""
binding="basicHttpBinding" bindingConfiguration=""
contract="WcfReporting.IService1">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding"
contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="net.tcp://localhost:5050/" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="WcfReporting.Service1Behavior" >
<!-- To avoid disclosing metadata information, set the value below to false
and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="true"/>
<!-- To receive exception details in faults for debugging purposes,
set the value below to true. Set to false before deployment to
avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
-
Why when I press F5 to restart the service the service starts at this url http: // localhost: 2752 / ... why 5050 as I pointed out in the baseAddresses.
-
How can I add another endpoint. I tried with endpoint address = "/ Address2" binding = "basicHttpBinding" contract = "WcfReporting.IService1" / ">
should i be able to access the service not only from http: // localhost / VirtualDir / but also from http: // localhost / VirtualDir / address2 or how does this work?
If you are participating in Cassini from Visual Studio 2005 or later, you can specify the port using Project / Properties / Web / Use Visual Studio Development Server / Specific Port.
By default, the port will be automatically assigned - which is not very useful for web services, as your clients will probably want to use a fixed URL.
You don't need to specify <baseAddresses> in the config file when hosted in IIS or Cassini — the base URL is provided by the web server. The <baseAddresses> element is used for self-service.
a source to share
How can I add another endpoint. i tried with endpoint address = "/ address2" binding = "BasicHttpBinding" contract = "WcfReporting.IService1" / ">
The addresses you specify at this endpoint must be local and relative - eg. just point
<endpoint address="Address2"
binding="basicHttpBinding"
contract="WcfReporting.IService1" />
and this will create an endpoint at the full address
net.tcp://localhost:5050/Address2
But, as Darin already pointed out, if you are using IIS / WAS to host your service, the virtual directory where your .svc file resides will take precedence and the base addresses specified will be ignored. In order to actually use base addresses, you need to organize the service yourself in a console application or Windows service.
Mark
a source to share
If you are using a web server (like Cassini or IIS) to host your WCF service, the base address will be provided from that server. Also note that you cannot use TCP over HTTP bindings. If you want to set the base address property, you need to host the service yourself (for example, in an NT service, console, or Windows application).
a source to share