我在C#Web應用程序中使用了一個ASP.NET,它使用來自Web服務的數據。它在大多數情況下都能正常工作,但有時候,通常在請求更大的數據集時,它只會返回一個Access is denied錯誤。Web服務返回「訪問被拒絕」僅用於某些請求
例如,如果我打電話給服務以返回某個日期範圍之間的某些文檔,並且範圍足夠小,則它工作得很好。但是,如果我將範圍擴大得太遠,則會返回此錯誤。這導致我相信它是一個大小或時間問題。
但是,如果我嘗試返回所有文檔,它將幾乎立即返回Access被拒絕錯誤,而不會等待。
我很確定問題出在服務和應用程序之間,甚至在應用程序的配置中。
任何人都可以幫助我發現爲什麼我得到這個模糊的訪問被拒絕的錯誤?如果有更多我應該提供的信息,請告訴我。
編輯: 我確實控制了網絡服務。
我已經嘗試通過一個小窗口窗體應用程序調用服務,我從來沒有見過任何錯誤。
我打電話通過某種合約客戶端的Web服務?我不確定具體情況,但我只是有一個指向該服務的服務引用,然後我可以聲明一個客戶端,然後使用其中的方法。
我能夠在瀏覽器中正常訪問服務。
至於其他問題,我還不確定。我會進一步研究。
編輯2: 下面是客戶端的配置:
<?xml version="1.0"?>
<configuration>
<connectionStrings>
//omitted
</connectionStrings>
<system.web>
<httpRuntime executionTimeout="300" maxRequestLength="51200" />
<pages theme="Theme1" />
<compilation debug="true" targetFramework="4.0">
<assemblies>
//omitted
</assemblies>
</compilation>
<authentication mode="Windows" />
<authorization>
<deny users="?" />
</authorization>
<membership>
<providers>
<clear />
<add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="ApplicationServices" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" applicationName="/" />
</providers>
</membership>
<profile>
<providers>
<clear />
<add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="ApplicationServices" applicationName="/" />
</providers>
</profile>
<roleManager enabled="false">
<providers>
<clear />
<add name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider" connectionStringName="ApplicationServices" applicationName="/" />
<add name="AspNetWindowsTokenRoleProvider" type="System.Web.Security.WindowsTokenRoleProvider" applicationName="/" />
</providers>
</roleManager>
<httpHandlers>
<add path="Telerik.Web.UI.WebResource.axd" type="Telerik.Web.UI.WebResource" verb="*" validate="false" />
</httpHandlers>
</system.web>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true" />
<validation validateIntegratedModeConfiguration="false" />
<handlers>
<add name="Telerik_Web_UI_WebResource_axd" verb="*" preCondition="integratedMode" path="Telerik.Web.UI.WebResource.axd" type="Telerik.Web.UI.WebResource" />
</handlers>
</system.webServer>
<appSettings>
//omitted
</appSettings>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="DefaultEndpoint" closeTimeout="00:09:00" openTimeout="00:09:00" receiveTimeout="00:10:00" sendTimeout="00:09:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="2147483647" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Ntlm" proxyCredentialType="None" realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
<binding name="DefaultEndpoint1" closeTimeout="00:09:00" openTimeout="00:09:00" receiveTimeout="00:10:00" sendTimeout="00:09:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="2147483647" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Ntlm" proxyCredentialType="None" realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="/*omitted*/ " binding="basicHttpBinding" behaviorConfiguration="ServiceBehavior" bindingConfiguration="DefaultEndpoint" contract="/*omitted*/ " name="DefaultEndpoint" />
<endpoint address="/*omitted*/ " binding="basicHttpBinding" behaviorConfiguration="ServiceBehavior" bindingConfiguration="DefaultEndpoint1" contract="/*omitted*/ " name="DefaultEndpoint1" />
</client>
<behaviors>
<endpointBehaviors>
<behavior name="ServiceBehavior">
<dataContractSerializer maxItemsInObjectGraph="2147483647" />
</behavior>
</endpointBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
下面是該服務的配置:
<?xml version="1.0"?>
<configuration>
<configSections>
<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=/*omitted*/" >
<section name="ITSLogger.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=/*omitted*/" requirePermission="false" />
</sectionGroup>
</configSections>
<system.web>
<compilation debug="true" targetFramework="4.0" />
<authentication mode="Windows"></authentication>
<!--<anonymousIdentification enabled="false"/>-->
</system.web>
<system.serviceModel>
<services>
<service behaviorConfiguration="RWS.ServiceImplementation.ResearchService_Behavior"
name="RWS.ServiceImplementation.ResearchService">
<endpoint address="" binding="basicHttpBinding" name="DefaultEndpoint"
bindingNamespace="http://researchwebservice.model/research" bindingConfiguration="userHttp"
contract="RWS.ServiceContracts.IResearchServiceContract"/>
<!--<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />-->
</service>
</services>
<bindings>
<basicHttpBinding>
<binding name="userHttp"
closeTimeout="00:01:00"
openTimeout="00:01:00"
receiveTimeout="00:10:00"
sendTimeout="00:01:00"
allowCookies="false"
bypassProxyOnLocal="false"
hostNameComparisonMode="StrongWildcard"
maxBufferSize="2147483647"
maxBufferPoolSize="2147483647"
maxReceivedMessageSize="2147483647"
messageEncoding="Text"
textEncoding="utf-8"
transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="2147483647"
maxStringContentLength="2147483647"
maxArrayLength="2147483647"
maxBytesPerRead="2147483647"
maxNameTableCharCount="2147483647" />
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Ntlm" />
<message clientCredentialType="UserName"/>
</security>
</binding>
</basicHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpGetEnabled="false" />
<serviceDebug includeExceptionDetailInFaults="true" />
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
</behavior>
<behavior name="RWS.ServiceImplementation.ResearchService_Behavior">
<serviceDebug includeExceptionDetailInFaults="true" />
<serviceMetadata httpGetEnabled="true" />
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
<connectionStrings>
<add name="ITSLogger.Properties.Settings.ITSLoggerConnectionString"
connectionString=/*omitted*/
providerName="System.Data.SqlClient" />
</connectionStrings>
<applicationSettings>
<ITSLogger.Properties.Settings>
<setting name="LogFilePath" serializeAs="String">
<value>C:\ITSLogger\LoggerTest\</value>
</setting>
<setting name="MailServer" serializeAs="String">
<value>/*omitted*/</value>
</setting>
<setting name="MailRecipient" serializeAs="String">
<value>[email protected]</value>
</setting>
<setting name="CanLogToEmail" serializeAs="String">
<value>False</value>
</setting>
<setting name="CanLogToFlatFile" serializeAs="String">
<value>False</value>
</setting>
<setting name="CanLogToTrace" serializeAs="String">
<value>False</value>
</setting>
<setting name="CanLogToConsole" serializeAs="String">
<value>False</value>
</setting>
<setting name="CanLogToEventLog" serializeAs="String">
<value>true</value>
</setting>
<setting name="CanLogToDB" serializeAs="String">
<value>False</value>
</setting>
</ITSLogger.Properties.Settings>
</applicationSettings>
<system.diagnostics>
<sources>
<source name="System.ServiceModel"
switchValue="Information, ActivityTracing"
propagateActivity="true">
<listeners>
<add name="traceListener"
type="System.Diagnostics.XmlWriterTraceListener"
initializeData= "/*omitted*/" />
</listeners>
</source>
</sources>
</system.diagnostics>
</configuration>
我在這裏省略了一些東西,那裏,我認爲可能太透露了。
你自己寫了Web服務嗎? –
需要更多信息。你是否控制web服務?你有沒有嘗試從一個單獨的應用程序(如控制檯應用程序)調用服務來測試是否可以重現該問題?運行像Fiddler 2這樣的調試工具時,你會看到什麼?你打電話給web服務怎麼樣?什麼是返回的實際HTTP狀態碼?您是否可以通過瀏覽器訪問Web服務? –
這是一個WCF Web服務,還是舊式的.asmx SOAP服務? –