仅在通过Windows服务

时间:2015-11-15 13:25:27

标签: c# wcf

我在IIS(远程主机:godaddy)中部署了WCF Web服务,并试图通过Windows服务进行消费。但是当我尝试通过Windows服务消费时,低于错误。

  

“异常:http://mydomainname.com/vfolder1/vfolder2/HelloService.svc/HelloService没有可以接受该消息的端点监听”。这通常是由错误的地址或SOAP操作引起的。有关更多详细信息,请参阅InnerException(如果存在)。

但是,当我通过Windows窗体使用相同的服务时,它没有任何问题。

以下是我的WCF Web服务配置(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" />

以下是我的WCF客户端配置(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>

以下是Windows窗体中的代码

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

    }

以下是Windows服务中的代码

       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());
        }

    }

当我们最初开发&amp;托管在本地网络(IIS)中,我们从未遇到任何问题。这是我们在WCF中的第一个涉及远程主机的项目。试图查看所有类似的帖子,但所有人都谈论完全不工作。没有类似于我们的场景。

感谢大家的帮助。

1 个答案:

答案 0 :(得分:1)

问题已解决。我们的公司政策不允许该服务在“本地系统”下运行时与互联网进行通信。特权。我暂时更改为使用我的用户凭据运行,它已经通过。

相关问题