简体   繁体   中英

Error while accessing WCF serivce hosted on local IIS: “This operation is not supported for a relative URI.”

I am getting " This operation is not supported for a relative URI. " error while accessing WCF service from my web-browser. The service is hosted on local IIS and following is its configuration:

<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>

As error explains you can only have absolute URI not relative. try to give absolute URI instead of localhost/

<baseAddressPrefixFilters>
  <add prefix="localhost/" />
</baseAddressPrefixFilters>

Try this,

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

As Abhinay said, you need the http:// in the prefix in order for it to be a fully qualified URI (which requires a scheme). So I'd say try:

http://localhost (no trailing slash)

or

http://127.0.0.1

or

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

Also try including the port number (eg http://localhost:8080 ) if you are on a nonstandard port.

Lastly, your endpoint tag may actually require a relative path for its address (I have seen that before), so:

<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>

baseAddressPrefixFilters does not recognize “localhost”, use the fully qualified machine name instead.

Here's the source .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM