Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I might be able to prevent Ninja violence... if I understand your problem ... You can manually specify the complete address the service should use in the web.config as opposed to having the ServiceHost figure it out for you. You have to set the base address of your service:</p> <pre><code> &lt;service behaviorConfiguration="Behaviour1" name="Api.Poll"&gt; &lt;endpoint address="soap" binding="basicHttpBinding" bindingConfiguration="soapBinding" contract="Api.IPoll" /&gt; &lt;endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /&gt; &lt;host&gt; &lt;baseAddresses&gt; &lt;add baseAddress="http://www.mydomain.com/Api" /&gt; &lt;add baseAddress="http://10.10.20.30/Api" /&gt; &lt;/baseAddresses&gt; &lt;/host&gt; &lt;/service&gt; </code></pre> <p>Using this method, your service should accept the base address specified, plus the service name, with the additional endpoint address if you have one. Also, you would need to use a custom ServiceHostFactory to set the base address programmatically. See below:</p> <pre><code> public class ServiceHostFactory : System.ServiceModel.Activation.ServiceHostFactory { protected override ServiceHost CreateServiceHost(Type serviceType, Uri[] baseAddresses) { ServiceHost host; host = new ServiceHost(serviceType, baseAddresses[0]); return host; } </code></pre> <p>Lastly, once you've build the ServiceHostFactory class, you have to hook it up to your service by editing the markup in the .svc file:</p> <pre><code>&lt;%@ ServiceHost Language="C#" Debug="true" Service="Api.Poll" Factory="Api.ServiceHostFactory" CodeBehind="Poll.svc.cs" %&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload