Hi,

I a real newbie on WCF, and I want to implement a service that reads from a DB some data and returns generic lists of custom objects to the client.

So I implement the service like this:
Interface:

<ServiceContract()> _
Public Interface IRepositorio

    <OperationContract(Name:="ListarAlmacen")> _
    Function ListarAlmacen() As List(Of BE.Almacen)

End Interface

Implementation:

<AspNetCompatibilityRequirementsAttribute(RequirementsMode:=AspNetCompatibilityRequirementsMode.Allowed)> _
<ServiceBehavior(UseSynchronizationContext:=True, InstanceContextMode:=InstanceContextMode.PerSession, ConcurrencyMode:=ConcurrencyMode.Multiple)> _
Public Class Repositorio
    Implements IRepositorio

    Public Function ListarAlmacen() As List(Of BE.Almacen) Implements IRepositorio.ListarAlmacen
        Dim result As List(Of BE.Almacen)
        result = BL.Repositorio.Almacen.listar()
        Return result
    End Function

End Class

and on the client (a ASP.NET website, added the ServiceReference on the project),

'some code ...

            Dim oAlmacenWCF As New repositorio.RepositorioClient
            Dim oListaAlmacenBE As List(Of BE.Almacen)
            oListaItemAlmacenBE = oAlmacenWCF.ListarAlmacen(item_id)

'some code

So, my problem is that when I first call the ListarAlmacen method it works ok, but when I tried to call it a second time, it gave me a timeout exception, I tried to step into to debug it, the first time it works, the debug steps into it; but the second time, it didn't.

I just have no idea what's happening, I tried some tips, but no luck (service log, web.config hacks, etc.).

Please some can tell me where's is the problem or how can I know for sure where to look for the problem...

Thanks!

Set the timeout properties of WCF application to increase the default timeout. This can be done on the client side programmically or with a client side App.Config or a Web.config.

You can configure the OperationTimeout property for Proxy in the WCF client code.

For example

DirectCast(service, IContextChannel).OperationTimeout = New TimeSpan(0, 0, 240)

Refer: http://www.codeproject.com/KB/WCF/WCF_Operation_Timeout_.aspx

Hi Ramesh,

Thank you very much for the answer, I've been looking how to do it in the web.config (i have a website client, and I want to do it in the web.config), but have no luck...

This is my first try ... and I'm not quit sure if I have the concepts right.

My proxy is generated with the vs2008 with the option "Add Service Reference..."

My client web.config has:

<system.serviceModel>
    <bindings>
 <wsHttpBinding>
           <binding name="WSHttpBinding_IRepositorio" closeTimeout="00:01:00"
             openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
             bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
             maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text"
             textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false">
             <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                maxBytesPerRead="4096" maxNameTableCharCount="16384" />
             <reliableSession ordered="true" inactivityTimeout="00:10:00"
                enabled="false" />
             <security mode="Message">
                <transport clientCredentialType="Windows" proxyCredentialType="None"
                   realm="" />
                <message clientCredentialType="Windows" negotiateServiceCredential="true"
                   algorithmSuite="Default" establishSecurityContext="true" />
             </security>
          </binding>
       </wsHttpBinding>
    </bindings>
      <client>
<endpoint address="http://localhost:7604/Repositorio.svc" binding="wsHttpBinding"
    bindingConfiguration="WSHttpBinding_IRepositorio" contract="repositorio.IRepositorio"
    name="WSHttpBinding_IRepositorio">
    <identity>
     <dns value="localhost" />
    </identity>
   </endpoint>
      </client>
	</system.serviceModel>

And I'm not sure where to put the OperationTimeout property.

Thanks.

Omar

Set the timeout properties of WCF application to increase the default timeout. This can be done on the client side programmically or with a client side App.Config or a Web.config.

You can configure the OperationTimeout property for Proxy in the WCF client code.

For example

DirectCast(service, IContextChannel).OperationTimeout = New TimeSpan(0, 0, 240)

Refer: http://www.codeproject.com/KB/WCF/WCF_Operation_Timeout_.aspx

Another thing. The method time span is long enough (the default timeout value is 60 secs) to execute it (it's just a query of one table), and I have no idea why, when executes the first time, it works, and the second time it didn't.

Well, Someone might wanna know this...

I solved the problem putting the close method at the end of the call.

'some code ...

            Dim oAlmacenWCF As New repositorio.RepositorioClient
            Dim oListaAlmacenBE As List(Of BE.Almacen)
            oListaItemAlmacenBE = oAlmacenWCF.ListarAlmacen(item_id)
            oAlmacenWCF.Close()

'some code

I hope this helps someone...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.