C# WCF SOAP服务方法无原因超时
我有一个带有wsHttpBinding的WCFSOAP服务,我有两个方法,第一个执行得很好,但由于某种原因,对第二个方法的调用超时。我调试了这个方法,代码中的一切都很好,它执行并返回,但是在客户端,在同一台机器上,请求超时。我创建了一个新的WCF服务应用程序项目,将整个代码+配置复制到新项目中,然后运行它,该方法有几次没有超时,然后突然又开始执行 以下是配置:C# WCF SOAP服务方法无原因超时,c#,.net,wcf,soap,C#,.net,Wcf,Soap,我有一个带有wsHttpBinding的WCFSOAP服务,我有两个方法,第一个执行得很好,但由于某种原因,对第二个方法的调用超时。我调试了这个方法,代码中的一切都很好,它执行并返回,但是在客户端,在同一台机器上,请求超时。我创建了一个新的WCF服务应用程序项目,将整个代码+配置复制到新项目中,然后运行它,该方法有几次没有超时,然后突然又开始执行 以下是配置: <system.serviceModel> <services> <service b
<system.serviceModel>
<services>
<service behaviorConfiguration="PolicyServiceBehavior" name="IST.Broker.Services.PolicyServiceV2.PolicyService">
<endpoint address="" binding="wsHttpBinding" bindingConfiguration="PolicyServiceBindingConfiguration"
contract="IST.Broker.Services.PolicyServiceV2.IPolicyService" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:63915/" />
</baseAddresses>
<timeouts closeTimeout="00:01:00" openTimeout="00:01:00" />
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="PolicyServiceBehavior">
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
<serviceThrottling maxConcurrentCalls="2147483647" maxConcurrentSessions="2147483647" maxConcurrentInstances="2147483647" />
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<wsHttpBinding>
<binding name="PolicyServiceBindingConfiguration"
bypassProxyOnLocal="false"
transactionFlow="false"
hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="2000000"
maxReceivedMessageSize="2000000"
messageEncoding="Text"
textEncoding="utf-8"
useDefaultWebProxy="true"
allowCookies="true">
<readerQuotas
maxDepth="2000000"
maxStringContentLength="2000000"
maxArrayLength="2000000"
maxBytesPerRead="2000000"
maxNameTableCharCount="2000000" />
<reliableSession
enabled="true"
inactivityTimeout="00:01:00" />
<security mode="None"/>
</binding>
</wsHttpBinding>
</bindings>
<protocolMapping>
<add binding="basicHttpsBinding" scheme="https" />
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
<directoryBrowse enabled="true"/>
</system.webServer>
和执行:
[ServiceBehavior(ConcurrencyMode = ConcurrencyMode.Multiple, InstanceContextMode = InstanceContextMode.PerSession)]
public class PolicyService : IPolicyService
{
private Employee _currentEmployee;
public GetPolicyResponse GetPolicy(GetPolicyRequest request)
{
return new GetPolicyResponse(PolicyManager.GetPolicy(request.Id, request.PolicyNumber));
}
public void Initialize(int employeeId)
{
if (!InsuranceCompaniesServiceManager.IsInitialized)
{
var appPhysicalPath = HostingEnvironment.ApplicationPhysicalPath;
_currentEmployee = EmployeeManager.GetEmployee(employeeId);
InsuranceCompaniesServiceManager.Initialize(_currentEmployee, appPhysicalPath);
}
}
public CreateMtplApplicationResponse CreateMtplApplication(CreateMtplApplicationRequest request)
{
return new CreateMtplApplicationResponse(PolicyManager.CreateMtplApplication(request.CompanyId, request.Policy.ToBusinessObject(), request.Vehicle.ToBusinessObject(),
request.Clients.Select(x => x.ToBusinessObject()).ToList(), request.GreenCard.ToBusinessObject(), request.Sticker.ToBusinessObject()));
}
public void SignOut()
{
}
}
编辑:
该方法正在调用内部正在调用另一个服务的DLL。请在第行下方注释,因为它将在配置代理时自动添加
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
若您想检查,右键单击您添加服务代理的服务代理,选择“配置服务引用”,您会注意到/mex最后添加到服务的URL中
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />