0

我创建了简单的 WCF 服务并将其端点配置如下。

<services>
  <service name="AsynchWCFService.MathOperation">
    <endpoint address="MathsOperation" binding="wsHttpBinding" contract="AsynchWCFService.IMathOperation">
      <identity>
        <dns value="localhost" />
      </identity>
    </endpoint>
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
    <host>
      <baseAddresses>            
        <add baseAddress="http://localhost:8080/OperationService/" />
      </baseAddresses>
    </host>
  </service>
</services>

我在一个独立的 exe 中托管了这个 WCF 服务。我希望我的服务可以在以下地址访问。

http://localhost:8080/OperationService/MathsOperation/

但服务可在http://localhost:8080/OperationService/

我想使用http://localhost:8080/OperationService/MathsOperation/链接访问服务。谁能帮我?

4

1 回答 1

2

我认为您的服务在http://localhost:8080/OperationService. 您看到的只是一个由 WCF 创建的 HTML 页面,它描述了可用的mex端点或 WSDL 的路径。这些 mex 端点描述了 WCF 服务的 ABC,其中 A = address => http://localhost:8080/OperationService/MathsOperation/。潜在客户通过查询 mex 端点了解您的服务 url。

默认情况下,此 HTML 页面将显示在您的基本地址处。serviceDebug但是,您可以通过使用行为禁用此页面或将其设置为显示在某些不同的 url 。

<system.serviceModel>
    <behaviors>
        <serviceBehaviors>
            <behavior>
                <serviceDebug httpHelpPageUrl="http://localhost:8080/OperationService/myhelppage"
                               /> <!-- use httpHelpPageEnabled="false" to disable the page -->
            </behavior>
        </serviceBehaviors>
    </behaviors>
</system.serviceModel>

不幸的是,我认为您不能设置httpHelpPageUrl为与服务端点相同的地址。

于 2013-06-02T18:40:01.803 回答