Ilyas
Ilyas

Reputation: 181

"No Endpoint listening" only when consuming WCF via windows service

I have deployed WCF web service in IIS (remote-host: godaddy) and trying to consume through windows service. But getting below error when I try to consume via Windows Service.

"Exception: There was no endpoint listening at http://mydomainname.com/vfolder1/vfolder2/HelloService.svc/HelloService" that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details.

But when i consume the same service via Windows Form, it works without any issue.

Below is my WCF web service configuration (web.config)

  <system.serviceModel>
<behaviors>
  <serviceBehaviors>
    <behavior name="mexBehaviour">
      <serviceMetadata httpGetEnabled="true"/>
    </behavior>
  </serviceBehaviors>
</behaviors>
<services>
  <service name="HelloService.HelloService" behaviorConfiguration="mexBehaviour">
    <endpoint address="HelloService" binding="basicHttpBinding" contract="HelloService.IHelloService"></endpoint>
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"></endpoint>
    <host>
      <baseAddresses>
        <add baseAddress="http://mydomainname.com/vfolder1/vfolder2/"/>
      </baseAddresses>
    </host>
  </service>
</services>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />

Below is my WCF client configuration (app.config)

  <system.serviceModel>
    <bindings>
        <basicHttpBinding>
            <binding name="BasicHttpBinding_IHelloService" />
        </basicHttpBinding>
    </bindings>
    <client>
        <endpoint address="http://mydomainname.com/vfolder1/vfolder2/HelloService.svc/HelloService"
            binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IHelloService"
            contract="HelloService.IHelloService" name="BasicHttpBinding_IHelloService" />
    </client>
</system.serviceModel>

Below is the code in Windows forms

       private void button1_Click(object sender, EventArgs e)
    {
        HelloService.HelloServiceClient client = new HelloService.HelloServiceClient();
        label1.Text = client.GetMessage(textBox1.Text);

    }

Below is the code in Windows Service

       public static void write_data()
    {
        try
        {
            HelloService.HelloServiceClient clNt = new HelloService.HelloServiceClient();
            for (int i = 0; i < 10; i++)
            {
                Write_Log(clNt.GetMessage(i.ToString()));

            }
            clNt.Close();

        }
        catch (Exception ex)
        {
            Write_Log("Exception: " + ex.Message.ToString());
        }

    }

When we initially developed & hosted in local network (IIS), we never had any issues. This is our first project in WCF and involving remote host. Tried to look all similar posts but all were talking on complete non-working. Nothing similar to our scenario exists.

Appreciate the great help.

Upvotes: 0

Views: 932

Answers (1)

Ilyas
Ilyas

Reputation: 181

The issue is resolved. Our company policy wasn't allowing the service to communicate to internet when running under "Local System" privilege. I temporarily changed to run with my user credentials and it went through.

Upvotes: 1

Related Questions