【问题标题】:Issues while Creating an instance of the Uri class to hold the base address of the WCF service创建 Uri 类的实例以保存 WCF 服务的基地址时出现问题
【发布时间】:2018-12-20 08:40:31
【问题描述】:

我已经创建了单独的解决方案,如下所示:

  1. 解决方案 A - 定义和实现服务 R 的服务合同,接口为 IR,项目名称为 ALib。
  2. 解决方案 B - 托管服务合同并运行它。

当我运行主机应用程序时,它运行良好,但我无法使用提供的基地址访问 url。我按照里面的说明更新了 App.config 文件 WCF Tutorial

让我们分解一下 App.config 文件中的更新内容。

1. <service name="ALib.R"> 
2. <add baseAddress = "http://localhost:8000/A/R" />
3. <endpoint address="" binding="wsHttpBinding" contract="ALib.IR">

当我输入 URL“http://localhost:8000/A/R”时,我收到 HTTP 400 错误,但我得到的页面是“http://localhost:8000/A/”。这不是教程中的做法。我也启用了元数据:

            var smb = new ServiceMetadataBehavior
            {
                HttpGetEnabled = true
            };
            selfHost.Description.Behaviors.Add(smb);

到目前为止所做的事情有什么遗漏吗?

【问题讨论】:

  • 我认为配置应该是&lt;endpoint address="" binding="wsHttpBinding" contract="ALib.IR"&gt;&lt;add baseAddress = "http://localhost:8000/A" /&gt;,因为你想使用多个服务的基地址

标签: wcf


【解决方案1】:

请尝试以下配置。

<system.serviceModel>
    <services>
      <service name="Server6.MyService">
        <endpoint address="" binding="wsHttpBinding" contract="Server6.IService">
        </endpoint>
        <endpoint address="mex" binding="mexHttpBinding" contract="Server6.IService"></endpoint>
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:13050/A/R"/>
          </baseAddresses>
        </host>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <serviceMetadata httpGetEnabled="true"></serviceMetadata>
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>

如果有什么我可以帮忙的,请随时告诉我。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2023-03-30
    • 2011-02-26
    • 1970-01-01
    • 1970-01-01
    • 2013-09-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多