我有一个web服务,它给了我一个发送邮件的列表。它在localhost上正常工作,但不在生产中。WCF webservice - 不能在生产中使用它
我的web服务应该可以访问,没有任何限制。这根本不安全,但坦率地说,在这一点上,我根本不在乎。
我得到了这些错误:
The caller was not authenticated by the service
,我解决了这一点:http://forums.asp.net/t/1324170.aspxIncoming binary negotiation has invalid ValueType
,使用该解决:http://www.vistax64.com/indigo/151689-wcf-security-request-security-token-could-not-satisfied.html
: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; 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>
请请相当好,有一个想法。我全都没了。而且我会有点生气。
谢谢!
编辑:解决了!在导线181 CentresInteret.vb,有:
Dim req As HttpWebRequest = WebRequest.Create(pageModele)
req.Timeout = 10000
Dim resp As HttpWebResponse = req.GetResponse() ' throws the error
我在超时增加了一个零,而现在它的作品!显然,超时10秒还不够......
您是否能够在Web浏览器中访问MEX端点(即,如果您在URL的末尾添加“?wsdl”)?在Web浏览器中的实际.svc URL怎么样? – CodingWithSpike
是的,这些工作很好。我可以使用WcfTestClient获得服务声明,但调用方法会引发相同的错误。 – thomasb
您是否尝试过在客户端和服务器上启用完整的WCF跟踪日志记录?如果你的调用进入WCF服务层,它通常会提供一些非常详细的信息。请参阅:http://msdn.microsoft.com/en-us/library/ms733025.aspx – CodingWithSpike