2011-11-22 26 views
1

我有一个web服务,它给了我一个发送邮件的列表。它在localhost上正常工作,但不在生产中。WCF webservice - 不能在生产中使用它

我的web服务应该可以访问,没有任何限制。这根本不安全,但坦率地说,在这一点上,我根本不在乎。

我得到了这些错误:

http://social.msdn.microsoft.com/Forums/en/wcf/thread/4b014224-d5d9-41d0-9441-48ccd2fb44cd

  • The request for security token has invalid or malformed elements,使用这种解决我一整天都在这里,我担心我不记得是哪一种修改我做了哪个错误。

    我得到的最新错误是...一个跛脚超时,没有innerexception。但是,有趣的是:我已经将每个超时配置为10个小时,几秒钟后我就会收到超时。

    我的web.config(服务器)有这个(实际上,它有4个web服务,但我只留下一个我想现在使用):

    <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;amp; outputs) 
              à System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc&amp;amp; rpc) 
              à System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc&amp;amp; rpc) 
              à System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage4(MessageRpc&amp;amp; rpc) 
              à System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage3(MessageRpc&amp;amp; rpc) 
              à System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage2(MessageRpc&amp;amp; rpc) 
              à System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage1(MessageRpc&amp;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;amp; outputs) 
              à System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc&amp;amp; rpc) 
              à System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc&amp;amp; rpc) 
              à System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage4(MessageRpc&amp;amp; rpc) 
              à System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage3(MessageRpc&amp;amp; rpc) 
              à System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage2(MessageRpc&amp;amp; rpc) 
              à System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage1(MessageRpc&amp;amp; rpc) 
              à System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet) 
             </ExceptionString> 
            </Exception> 
           </TraceRecord> 
          </DataItem> 
         </TraceData> 
        </ApplicationData> 
    </E2ETraceEvent> 
    

    请请相当好,有一个想法。我全都没了。而且我会有点生气。

    谢谢!

    编辑:解决了!在导线181 CentresInteret.vb,有:

    Dim req As HttpWebRequest = WebRequest.Create(pageModele) 
        req.Timeout = 10000 
        Dim resp As HttpWebResponse = req.GetResponse() ' throws the error 
    

    我在超时增加了一个零,而现在它的作品!显然,超时10秒还不够......

  • +0

    您是否能够在Web浏览器中访问MEX端点(即,如果您在URL的末尾添加“?wsdl”)?在Web浏览器中的实际.svc URL怎么样? – CodingWithSpike

    +0

    是的,这些工作很好。我可以使用WcfTestClient获得服务声明,但调用方法会引发相同的错误。 – thomasb

    +0

    您是否尝试过在客户端和服务器上启用完整的WCF跟踪日志记录?如果你的调用进入WCF服务层,它通常会提供一些非常详细的信息。请参阅:http://msdn.microsoft.com/en-us/library/ms733025.aspx – CodingWithSpike

    回答

    2

    如果此跟踪是从你的服务器(而不是客户端),那么我很好奇的错误:

    CentresInteret.RecupererContenuMail(Int32 contact_id, Int32 frequence_id, Int32 organisme_id) dans D:...\App_Code\WebServices\CentresInteret.vb:ligne 181

    它看起来像CentresInteret.RecupererContenuMail()方法是你的代码中的方法之一?如果是这样,文件CentresInteret.vb的行181是干什么的?看起来它可能会在查询某些内容时发生超时?也许它正在进行数据库调用或调用另一个Web服务?

    异常的这一部分:

    System.Net.WebException: Le délai d'attente de l'opération a expiré. à System.Net.HttpWebRequest.GetResponse()

    使它看起来像你的Web服务代码正在另一个网络请求到另一个服务,并且可能会超时。如果oyu查询另一个服务(例如Exchange或某个POP3邮件服务器),那么它的超时时间可能是10-15秒,并且该超时冒泡到您的WCF客户端(尽管作为the_ajp提到过,它应该在客户端被包装在FaultException中)

    +0

    我期望在客户端看到faultexception。也许@ cosmo0可以证实这一点。 – albertjan

    +0

    谢谢,我一定很累,不要看这条线......我解决了它:它试图使用httpwebrequest调用一个文件,并超时。我在请求的超时中添加了一个零,并且它可以工作。谢谢 !现在,我“只”必须实施安全......:P – thomasb