我有一个带有wsHttpBinding的WCF SOAP服务,我有2个方法,第一个执行正常,但由于某种原因,对第二个方法的调用超时。我对方法进行了调试,一切都很好我的代码,它执行并返回,但在客户端,在同一台机器上,请求超时。我创建了一个新的WCF服务应用程序项目,将整个代码+配置复制到新项目中,运行它,并且该方法没有超时几次,然后突然又开始重新执行它。
这是配置:
<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>
服务cotnract:
[ServiceContract(SessionMode = SessionMode.Required)]
public interface IPolicyService
{
[OperationContract(IsInitiating = true)]
void Initialize(int employeeId);
[OperationContract(IsInitiating = false, IsTerminating = false)]
GetPolicyResponse GetPolicy(GetPolicyRequest request);
[OperationContract(IsInitiating = false, IsTerminating = false)]
CreateMtplApplicationResponse CreateMtplApplication(CreateMtplApplicationRequest request);
[OperationContract(IsInitiating = false, IsTerminating = true)]
void SignOut();
}
并实施:
[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。
答案 0 :(得分:0)
在下面注释掉,因为它会在配置代理时自动添加。
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
如果要查看,请右键单击添加了服务代理的服务代理,然后选择“配置服务参考”,您将注意到/ mex最后添加到服务的URL中