我创建了一个简单的WCF服务,该服务托管在Web场中。现在,当我使用http://www.example.com/somefolder/file.svc在浏览器 有时 中加载服务时,我收到以下错误。如果我多次点击F5,那么页面最终会再次恢复。
更新1: 我注意到,即使我使用单个Web服务器的IP在浏览器中加载svc,我有时会收到相同的错误消息,有时它会起作用。
无法创建相对URI,因为' uriString'参数 表示绝对URI。http://www.example.com/somefolder/file.svc
[UriFormatException:A 无法创建相对URI,因为' uriString'参数 代表绝对 URI。http://www.example.com/somefolder/file.svc]
System.ServiceModel.Activation.ApplyHostConfigurationBehavior.ThrowIfAbsolute(URI uri)+154
System.ServiceModel.Activation.ApplyHostConfigurationBehavior.FailActivationIfEndpointsHaveAbsoluteAddress(ServiceHostBase 服务)+128
System.ServiceModel.Activation.ApplyHostConfigurationBehavior.System.ServiceModel.Description.IServiceBehavior.Validate(ServiceDescription description,ServiceHostBase服务)+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(时间跨度 超时)+261
System.ServiceModel.HostingManager.ActivateService(字符串 normalizedVirtualPath)+121
System.ServiceModel.HostingManager.EnsureServiceAvailable(字符串 normalizedVirtualPath)+479[ServiceActivationException:service' /somefolder/file.svc'不能 由于编译期间的异常而被激活。例外 消息是:无法创建相对URI,因为' uriString' 参数表示绝对值 URI。http://www.example.com/somefolder/file.svc.]
System.ServiceModel.AsyncResult.End(IAsyncResult result)+11653822
System.ServiceModel.Activation.HostedHttpRequestAsyncResult.End(IAsyncResult的 结果)+194
System.ServiceModel.Activation.HostedHttpRequestAsyncResult.ExecuteSynchronous(HttpApplication的 context,Boolean flowContext)+176
System.ServiceModel.Activation.HttpHandler.ProcessRequest(HttpContext的 上下文)+23
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +181 System.Web.HttpApplication.ExecuteStep(IExecutionStep step,Boolean& completedSynchronously)+75
我不确定是什么原因造成的。就像我说的,我只是加载服务。 我也没在我的代码中使用任何URI。 webservice使用IIS7.5托管在三台服务器上,并指向包含wcf文件的共享驱动器。
以下是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>
答案 0 :(得分:0)
我刚刚遇到了同样的问题并修复了我将端点设为相对地址(我删除了地址属性值,使其成为空字符串 - 地址=&#34;&#34;)端点节点。我的.svc位于从URL调用的路径中,因此空地址不是问题。
我也没有使用身份节点,但我确实将multipleSiteBindingsEnabled设置为true。