У меня есть веб-сервис, который дает мне список писем для отправки. Он отлично работает на локальном хосте, но не работает.
Мой веб-сервис должен быть доступен без каких-либо ограничений. Это вообще небезопасно, но, честно говоря, на данный момент мне все равно.
Я получил эти ошибки:
Я занимался этим целый день, и я боюсь, что не помню, какую модификацию я сделал для какой ошибки.
Самая последняя ошибка, которую я получил, это ... тайм-аут, без исключений. Но самое смешное: я настроил каждый тайм-аут на 10 часов, и через несколько секунд я получаю тайм-аут.
Мой web.config (сервер) имеет это (на самом деле, у него 4 веб-сервиса, но я оставил только тот, который сейчас пытаюсь использовать):
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="wsHttpBinding" allowCookies="true" maxReceivedMessageSize="20000000" maxBufferPoolSize="20000000" useDefaultWebProxy="true">
<security mode="Message">
<transport clientCredentialType="Windows" proxyCredentialType="None" realm="" />
</security>
</binding>
<binding name="NoSecurityBinding" allowCookies="true" maxReceivedMessageSize="20000000" maxBufferPoolSize="20000000" useDefaultWebProxy="true">
<security mode="Message">
<transport clientCredentialType="Windows" proxyCredentialType="None" realm="" />
<message clientCredentialType="Windows" negotiateServiceCredential="true" establishSecurityContext="true" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="CentresInteretBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" httpHelpPageEnabled="true" />
<serviceCredentials>
<windowsAuthentication allowAnonymousLogons="true" />
</serviceCredentials>
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service behaviorConfiguration="CentresInteretBehavior" name="CentresInteret">
<endpoint address="" binding="wsHttpBinding" contract="ICentresInteret" bindingConfiguration="NoSecurityBinding">
<identity>
<dns value="localhost" />
<userPrincipalName value=".\ASPNET" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
</system.serviceModel>
Мой app.config (клиент) имеет это (то же самое: несколько WS, только один вызванный):
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="WSHttpBinding_ICentresInteret" closeTimeout="10:00:00"
openTimeout="10:00:00" receiveTimeout="10:00:00" sendTimeout="10:00:00"
bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="20000000" maxReceivedMessageSize="20000000"
messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"
allowCookies="false">
<readerQuotas maxDepth="32" maxStringContentLength="200000000"
maxArrayLength="200000000" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<reliableSession ordered="true" inactivityTimeout="10:00:00" enabled="false" />
<security mode="None">
<transport clientCredentialType="Windows" proxyCredentialType="None" realm="" />
<message clientCredentialType="Windows" negotiateServiceCredential="false"
algorithmSuite="Default" establishSecurityContext="true" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint address="http://www.ourserver.com/WebServices/CentresInteret.svc"
binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_ICentresInteret"
contract="CentresInteretService.ICentresInteret" name="WSHttpBinding_ICentresInteret">
<identity>
<dns value="localhost" />
<userPrincipalName value=".\ASPNET" />
</identity>
</endpoint>
</client>
</system.serviceModel>
Серверная трассировка дает мне это через несколько секунд (около 10-15) по красной линии (пожалуйста, спросите меня, нужна ли вам еще одна строка):
<E2ETraceEvent xmlns="http://schemas.microsoft.com/2004/06/E2ETraceEvent">
<System xmlns="http://schemas.microsoft.com/2004/06/windows/eventlog/system">
<EventID>131076</EventID>
<Type>3</Type>
<SubType Name="Error">0</SubType>
<Level>2</Level>
<TimeCreated SystemTime="2011-11-28T17:46:26.6525694Z" />
<Source Name="System.ServiceModel" />
<Correlation ActivityID="{f624ff35-a8ae-4636-bd46-2138207af7a1}" />
<Execution ProcessName="w3wp" ProcessID="20424" ThreadID="7" />
<Channel />
<Computer>SRV-WEB-01</Computer>
</System>
<ApplicationData>
<TraceData>
<DataItem>
<TraceRecord xmlns="http://schemas.microsoft.com/2004/10/E2ETraceEvent/TraceRecord" Severity="Error">
<TraceIdentifier>http://msdn.microsoft.com/fr-FR/library/System.ServiceModel.Diagnostics.TraceHandledException.aspx</TraceIdentifier>
<Description>Traitement d’une exception.</Description>
<AppDomain>/LM/W3SVC/4/ROOT-1-129669759749681489</AppDomain>
<Exception>
<ExceptionType>System.Net.WebException, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</ExceptionType>
<Message>Le délai d'attente de l'opération a expiré.</Message>
<StackTrace>
à System.Net.HttpWebRequest.GetResponse()
à CentresInteret.RecupererContenuMail(Int32 contact_id, Int32 frequence_id, Int32 organisme_id) dans D:\...\App_Code\WebServices\CentresInteret.vb:ligne 181
à CentresInteret.GetEmails(Boolean PrendreEnCompteFrequence) dans D:\...\App_Code\WebServices\CentresInteret.vb:ligne 87
à SyncInvokeGetEmails(Object , Object[] , Object[] )
à System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(Object instance, Object[] inputs, Object[]&amp; outputs)
à System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc&amp; rpc)
à System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc&amp; rpc)
à System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage4(MessageRpc&amp; rpc)
à System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage3(MessageRpc&amp; rpc)
à System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage2(MessageRpc&amp; rpc)
à System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage1(MessageRpc&amp; rpc)
à System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)
</StackTrace>
<ExceptionString>
System.Net.WebException: Le délai d'attente de l'opération a expiré.
à System.Net.HttpWebRequest.GetResponse()
à CentresInteret.RecupererContenuMail(Int32 contact_id, Int32 frequence_id, Int32 organisme_id) dans D:\...\App_Code\WebServices\CentresInteret.vb:ligne 181
à CentresInteret.GetEmails(Boolean PrendreEnCompteFrequence) dans D:\...\App_Code\WebServices\CentresInteret.vb:ligne 87
à SyncInvokeGetEmails(Object , Object[] , Object[] )
à System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(Object instance, Object[] inputs, Object[]&amp; outputs)
à System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc&amp; rpc)
à System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc&amp; rpc)
à System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage4(MessageRpc&amp; rpc)
à System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage3(MessageRpc&amp; rpc)
à System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage2(MessageRpc&amp; rpc)
à System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage1(MessageRpc&amp; rpc)
à System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)
</ExceptionString>
</Exception>
</TraceRecord>
</DataItem>
</TraceData>
</ApplicationData>
</E2ETraceEvent>
Пожалуйста, пожалуйста, пожалуйста, есть идея. Я все из них. И я немного схожу с ума.
Спасибо!
Редактировать : решено! В CentresInteret.vb в строке 181 есть:
Dim req As HttpWebRequest = WebRequest.Create(pageModele)
req.Timeout = 10000
Dim resp As HttpWebResponse = req.GetResponse() ' throws the error
Я добавил ноль в тайм-аут, и теперь это работает! Очевидно, 10 секунд тайм-аута было недостаточно ...