Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I have a WCF SOAP Service with wsHttpBinding, i have 2 methods, the first one executes fine, but for some reason the call to the second method times out. I debuged the method and the everything is fine i my code, it executes and returns, but the in the client, on the same machine, the requests times out. I created a new WCF Service Application project, copied the entire code + config to the new project, ran it, and the method didn't time out for a few times, then suddenly it started doing it again.

here is the config:

<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>

The service 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();
    }

And implementation:

[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()
        {
        }
    }

EDIT: The method is calling a DLL that inside is calling another service.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
175 views
Welcome To Ask or Share your Answers For Others

1 Answer

Comment out below line because it'll be added automatically while configuring the proxy.

<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />

If you want to check, Right click on service proxy where you added service proxy, and select "Configure Service Reference" and you'll notice /mex is added in URL of the service at last


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...