3
votes

I created a simple WCF service, which is hosted on a web farm. Now when I load the service in the browser sometimes using http://www.example.com/somefolder/file.svc I get the below error. If I hit F5 several times, then the page eventually comes back up again.

Update 1: I noticed that even if I use the IP of the individual web server to load the svc in the browser then I get sometimes the same error message and sometimes it works.

A relative URI cannot be created because the 'uriString' parameter represents an absolute URI.http://www.example.com/somefolder/file.svc

[UriFormatException: A relative URI cannot be created because the 'uriString' parameter represents an absolute URI.http://www.example.com/somefolder/file.svc]
System.ServiceModel.Activation.ApplyHostConfigurationBehavior.ThrowIfAbsolute(Uri uri) +154
System.ServiceModel.Activation.ApplyHostConfigurationBehavior.FailActivationIfEndpointsHaveAbsoluteAddress(ServiceHostBase service) +128
System.ServiceModel.Activation.ApplyHostConfigurationBehavior.System.ServiceModel.Description.IServiceBehavior.Validate(ServiceDescription description, ServiceHostBase service) +65
System.ServiceModel.Description.DispatcherBuilder.ValidateDescription(ServiceDescription description, ServiceHostBase serviceHost) +161
System.ServiceModel.Description.DispatcherBuilder.InitializeServiceHost(ServiceDescription description, ServiceHostBase serviceHost) +84
System.ServiceModel.ServiceHostBase.InitializeRuntime() +37
System.ServiceModel.ServiceHostBase.OnBeginOpen() +27
System.ServiceModel.ServiceHostBase.OnOpen(TimeSpan timeout) +49
System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout) +261
System.ServiceModel.HostingManager.ActivateService(String normalizedVirtualPath) +121
System.ServiceModel.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath) +479

[ServiceActivationException: The service '/somefolder/file.svc' cannot be activated due to an exception during compilation. The exception message is: A relative URI cannot be created because the 'uriString' parameter represents an absolute URI.http://www.example.com/somefolder/file.svc.]
System.ServiceModel.AsyncResult.End(IAsyncResult result) +11653822
System.ServiceModel.Activation.HostedHttpRequestAsyncResult.End(IAsyncResult result) +194
System.ServiceModel.Activation.HostedHttpRequestAsyncResult.ExecuteSynchronous(HttpApplication context, Boolean flowContext) +176
System.ServiceModel.Activation.HttpHandler.ProcessRequest(HttpContext context) +23
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +181 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +75

I am not sure what is causing this. Like I said, I am just loading the service. I am also not using any URI in my code. The webservice is hosted on three servers using IIS7.5 and pointing all to a shared drive that contains the wcf files.

Here is section from the web.config:

<!-- Configuration For File.svc -->
    <system.serviceModel>
        <serviceHostingEnvironment aspNetCompatibilityEnabled="true" />

        <services>
            <service behaviorConfiguration="WebFileService.FileBehavior" name="WebFileService.File">
                <endpoint address="http://www.example.com/somefolder/file.svc" binding="wsHttpBinding" contract="WebFileService.IFile" bindingConfiguration="WSHttpBinding_IFile">
                    <identity>
                        <dns value="localhost" />
                    </identity>
                </endpoint>
                <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
            </service>
        </services>
        <behaviors>
            <serviceBehaviors>
                <behavior name="WebFileService.FileBehavior">
                    <serviceMetadata httpGetEnabled="true" />
                    <serviceDebug includeExceptionDetailInFaults="true" />
                </behavior>
            </serviceBehaviors>
        </behaviors>
        <bindings>
            <wsHttpBinding>
                <binding name="WSHttpBinding_IFile" closeTimeout="00:01:00" openTimeout="00:01:00"
                    receiveTimeout="00:10:00" sendTimeout="00:01:00" bypassProxyOnLocal="false"
                    transactionFlow="false" hostNameComparisonMode="StrongWildcard"
                    maxBufferPoolSize="524288" maxReceivedMessageSize="1000000"
                    messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"
                    allowCookies="false">
                    <readerQuotas maxDepth="32" maxStringContentLength="99999" maxArrayLength="999999"
                        maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                    <reliableSession ordered="true" inactivityTimeout="00:10:00"
                        enabled="false" />
                    <security mode="None">
                        <transport clientCredentialType="None" proxyCredentialType="None" realm=""/>
                        <message clientCredentialType="None" negotiateServiceCredential="true" algorithmSuite="Default" establishSecurityContext="true"/>
                    </security>
                </binding>
            </wsHttpBinding>
        </bindings>
    </system.serviceModel>
1
did you check your web.config file?Icepickle
web.config looks ok to me. I have edited my question with the service section from the config.vikasde
Is it possible the load balancer is not always passing along the full URL? Maybe it's a setting somewhere? Most likely not, but one never knows.Tim
I am not how I could check this. Any ideas?vikasde
Sorry to say that I don't have any suggestions, but wanted to share that I am also seeing this behavior, on a WCF Data Service. The service has been working fine for years in production on a shared web host, but in preparation for doing some site updates, I've been moving the site over to Azure Web Apps. When I run the service locally, on localhost in IIS Express (VS 2015 RC, just opened as a web site) the service works fine, but in the Azure Web App it fails with the error message you're seeing.devhammer

1 Answers

0
votes

I've just had the same issue and fixed it my making the endpoint a relative address (I removed the address attribute value making it an empty string - address="") on the the endpoint node. My .svc is located in the path being called from the URL so the empty address is not an issue.

I'm also not using the identity node, but i do have multipleSiteBindingsEnabled set to true.