4

从我的网络浏览器访问 WCF 服务时,我收到“相对 URI 不支持此操作。 ”错误。该服务托管在本地 IIS 上,其配置如下:

<system.serviceModel>
    <!-- change -->
    <bindings>
      <customBinding>
        <binding name="Wrabind" closeTimeout="00:05:00" openTimeout="00:05:00" sendTimeout="00:25:00">
          <textMessageEncoding/>
          <security authenticationMode="SecureConversation" includeTimestamp="true" messageSecurityVersion="WSSecurity11WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10">
            <localClientSettings maxClockSkew="00:30:00" />
            <localServiceSettings maxClockSkew="00:30:00" />
            <secureConversationBootstrap messageSecurityVersion="WSSecurity11WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10">
              <localClientSettings maxClockSkew="00:30:00" />
              <localServiceSettings maxClockSkew="00:30:00" />
            </secureConversationBootstrap>
          </security>
          <httpTransport maxBufferPoolSize="20000000" maxReceivedMessageSize="20000000" allowCookies="true" maxBufferSize="20000000" keepAliveEnabled="false" />
        </binding>
      </customBinding>
    </bindings>
<services>
      <service behaviorConfiguration="wrCoreService.Service1Behavior" name="wrCoreService.Service1">
        <endpoint address="http://localhost/service1.svc" binding="customBinding" bindingConfiguration="Wrabind" contract="wrCoreService.IService1" />
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="wrCoreService.Service1Behavior">
          <serviceThrottling
maxConcurrentCalls="200"
maxConcurrentSessions="200"
maxConcurrentInstances="200" />
          <!-- To avoid disclosing metadata information, set the value below to false before deployment -->
          <serviceMetadata httpGetEnabled="false" />
          <!-- change -->
          <!--<serviceCredentials>
            <userNameAuthentication userNamePasswordValidationMode="Custom" customUserNamePasswordValidatorType="wrCoreService.Authentication.DistributorValidator, wrCoreService"/>
            <serviceCertificate findValue="wrCoreService" storeLocation="LocalMachine" storeName="TrustedPeople" x509FindType="FindBySubjectName"/>
          </serviceCredentials>-->
          <!-- change -->
          <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
          <serviceDebug includeExceptionDetailInFaults="true" />

        </behavior>
      </serviceBehaviors>
    </behaviors>
    <serviceHostingEnvironment>
      <baseAddressPrefixFilters>
        <add prefix="localhost/" />
      </baseAddressPrefixFilters>
    </serviceHostingEnvironment>
    <!--<standardEndpoints>
      <webHttpEndpoint>
        <standardEndpoint name="" helpEnabled="true"
          automaticFormatSelectionEnabled="true"/>
      </webHttpEndpoint>
    </standardEndpoints>-->

  </system.serviceModel>
4

4 回答 4

0

尝试这个,

<serviceHostingEnvironment> <baseAddressPrefixFilters>
<add prefix="http://localhost/" />
</baseAddressPrefixFilters>
</serviceHostingEnvironment>

于 2013-10-24T12:47:41.293 回答
0

baseAddressPrefixFilters 无法识别“localhost”,请改用完全限定的机器名称。

这是来源

于 2013-10-29T20:31:37.507 回答
0

正如错误所解释的,您只能拥有绝对 URI 而不是相对的。尝试给出绝对 URI 而不是localhost/

<baseAddressPrefixFilters>
  <add prefix="localhost/" />
</baseAddressPrefixFilters>
于 2013-10-21T15:00:47.517 回答
0

正如 Abhinay 所说,您需要http://in 前缀才能使其成为完全限定的 URI(这需要一个方案)。所以我想说试试:

http://localhost(没有尾部斜杠)

或者

http://127.0.0.1

或者

http://your-machine-name.domain.whatever

http://localhost:8080如果您在非标准端口上,还可以尝试包括端口号(例如)。

最后,您的端点标签实际上可能需要其地址的相对路径(我以前见过),所以:

<service behaviorConfiguration="wrCoreService.Service1Behavior" name="wrCoreService.Service1">
    <endpoint address="service1.svc" binding="customBinding" bindingConfiguration="Wrabind" contract="wrCoreService.IService1" />
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
于 2013-10-28T19:58:59.917 回答