Mostrando postagens com marcador WCF. Mostrar todas as postagens
Mostrando postagens com marcador WCF. Mostrar todas as postagens

quarta-feira, 19 de fevereiro de 2014

Activate the WCF trace

Hi!

Sometimes you can't find out whata hell is going on with your WCF service.
In those times you should youse this amazing tool.

Put those tags at the and of your config file.

Really usefull!


<system.diagnostics>
   <sources>
       <source name="UserTraceSource" switchValue="Warning, ActivityTracing" >
          <listeners>
              <add name="xml"
                 type="System.Diagnostics.XmlWriterTraceListener"
                 initializeData="C:\logs\MyTrace.svclog" />
          </listeners>
       </source>
   </sources>
   <trace autoflush="true" /> 
</system.diagnostics>
 

sexta-feira, 4 de outubro de 2013

Could not find a base address that matches scheme net.tcp for the endpoint with binding NetTcpBinding . The base address schemes are [ http , https ] .

Hi!

If you are receiving this error when you try to access your webservice, something like http://www.you.com/yourservice.svc?wsdl. The solution might be simple.
 

Could not find a base address that matches scheme net.tcp for the endpoint with binding NetTcpBinding . The base address schemes are [ http , https ] .Description : An unhandled exception occurred during the execution of the current web request Please review the stack trace for more information about the error and where it originated in the code .
Exception Details : System.InvalidOperationException : Could not find a base address that matches scheme net.tcp for the endpoint with binding NetTcpBinding . The base address schemes are [ http , https ] .
Source Error :Unhandled exception was generated during the execution of the current web request Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace :
[ InvalidOperationException : Could not find a base address that matches scheme net.tcp for the endpoint with binding NetTcpBinding . The base address schemes are [ http , https ] . ]
   
System.ServiceModel.ServiceHostBase.MakeAbsoluteUri ( Uri relativeOrAbsoluteUri , Binding binding , UriSchemeKeyedCollection baseAddresses ) +12349612
   
System.ServiceModel.Description.ConfigLoader.LoadServiceDescription ( ServiceHostBase host ServiceDescription description , ServiceElement serviceElement , Action ` 1 AddBaseAddress ) +12346965
   
System.ServiceModel.ServiceHostBase.LoadConfigurationSectionInternal ( ConfigLoader configLoader , ServiceDescription description , ServiceElement serviceSection ) +67
   
System.ServiceModel.ServiceHostBase.ApplyConfiguration ( ) +108
   
System.ServiceModel.ServiceHostBase.InitializeDescription ( UriSchemeKeyedCollection baseAddresses ) +192
   
System.ServiceModel.ServiceHost.InitializeDescription (Type serviceType , UriSchemeKeyedCollection baseAddresses ) +49
   
System.ServiceModel.ServiceHost .. ctor (Type serviceType , Uri [ ] baseAddresses ) +151
   
System.ServiceModel.Activation.ServiceHostFactory.CreateServiceHost (Type serviceType , Uri [ ] baseAddresses ) +30
   
System.ServiceModel.Activation.ServiceHostFactory.CreateServiceHost ( constructorString String , Uri [ ] baseAddresses ) +422
   
System.ServiceModel.HostingManager.CreateService ( String normalizedVirtualPath ) +1461
   
System.ServiceModel.HostingManager.ActivateService ( String normalizedVirtualPath ) +44
   
System.ServiceModel.HostingManager.EnsureServiceAvailable ( String normalizedVirtualPath ) +651
[ ServiceActivationException : Can not activate service ' / Fibra.Barramento.Calculo / Motor.svc ' due to an exception during compilation . The exception message is : Could not find a base address that matches scheme net.tcp for the endpoint with binding NetTcpBinding . The base address schemes are [ http , https ] ..]
   
System.Runtime.AsyncResult.End ( IAsyncResult result ) +688590
   
System.ServiceModel.Activation.HostedHttpRequestAsyncResult.End ( IAsyncResult result ) +190
   
System.ServiceModel.Activation.ServiceHttpModule.EndProcessRequest ( IAsyncResult ar) +310694
   
System.Web.AsyncEventExecutionStep.OnAsyncEventCompletion ( IAsyncResult ar) +94



Maybe, all you have to do is enable the protocol. The default protocol is http. Net.tcp must be enabled manually. So, add net.tcp, clicking on advanced settings and that's it.
 



Could not load type System.ServiceModel.Activation.HttpModule assembly System.ServiceModel, Version = 3.0.0.0, Culture = neutral, PublicKeyToken = b77a5c561934e089.

Well, this error took me a lot of time to understand. The message is completely misleading.
In my case the problem was that IIS had two versions of ServiceModel. For some reason the application was trying to load System.ServiceModel.dll version 3.0.0.0 , but was "suprised" by the version 4.0.0.0.
So, what was my solution? I removed the version 3. Did something crash? Not at all. Everything is working fine.
Never had the error again.
Há!


quinta-feira, 29 de agosto de 2013

Maximum number of items that can be serialized or deserialized in an object graph is '65536'. Change the object graph or increase the MaxItemsInObjectGraph quota.


OK, that's the problem.

The formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter http://tempuri.org/:ObterSituacaoClienteGrupoResult. The InnerException message was 'Maximum number of items that can be serialized or deserialized in an object graph is '65536'. Change the object graph or increase the MaxItemsInObjectGraph quota. '.  Please see InnerException for more details.

First of all, this message was received by the client of the service. So, the issue has two sides: client and server.

The server side

On the server side you're gonna have to add a new property to your behaviour.

Example



  <system.serviceModel>

    <behaviors>

      <serviceBehaviors>
        <behavior name="MyBehaviour">
          <serviceMetadata httpGetEnabled="False" httpsGetEnabled="True"/>
          <serviceDebug includeExceptionDetailInFaults="False"/>
          <dataContractSerializer maxItemsInObjectGraph="2147483647"/>
        </behavior>
    <services>


      <service behaviorConfiguration="MyBehaviour" name="Netdaniels.Services.Rating">
        <endpoint address="" binding="netTcpBinding" bindingConfiguration="MyBehaviour" bindingNamespace="http://www.netdaniels.com.br/product/risk/v1" contract="Netdaniels.Contract.IRisk" />



        <host>
          <baseAddresses>
            <add baseAddress="/Risk.svc" />
          </baseAddresses>
        </host>
      </service>

Unfortunately you have to change the client site too.

The client side

Example

<system.serviceModel>
<behaviors>
      <endpointBehaviors>
        <behavior name="MyBehaviour">
          <dataContractSerializer maxItemsInObjectGraph="2147483646" />
        </behavior>
      </endpointBehaviors>
</behaviors>

      <endpoint address="net.tcp://serverofclient:10261/Netdaniels.MyClient/shaba/"
                binding="netTcpBinding" behaviorConfiguration="MyBehaviour" bindingConfiguration="NetTcpBinding_IShaba"
                contract="ServicesNetdaniels.IShaba" name="NetTcpBinding_IShaba">
        <identity>
          <servicePrincipalName value="host/serverofclient" />
        </identity>
      </endpoint>

This is one of the most annoying problems I ever had.

I don't know if you noticed but there's a ripple effect related to this problem.

SERVER1 <- CLIENT 1 <- CLIENT 2 <- CLIENT 3

The scheme above means that, if you change configuration of server 1 you'll have to change configuration of client 1. If client 1 has a client, the configuration of this one must be changed too ans so on.

That's all folks!








terça-feira, 16 de julho de 2013

The socket connection was aborted. This could be caused by an error processing your message or a receive timeout being exceeded by the remote host, or an underlying network resource issue. Local socket timeout was '00:01:00'.

Hei!

Un muchacho como yo,
Que vive simplemente,
Que confía en los demás,
Y dice lo que siente,

- Palito Ortega -

Scenario
A WCF service was calling another WCF. The second wcf was exploding the message bellow.

How did I solve the problem?

Well, I used the following technique

 <system.serviceModel>
    <bindings>
      <netTcpBinding>
        <binding sendTimeout="00:10:00" />
      </netTcpBinding>
    </bindings>

And where did I find the solution?
Here => http://stackoverflow.com/questions/919287/wcf-windows-service-timeout

When you start to search for a solution you're gonna find a lot of "garbage". The solution presented, I can guarantee you, works!

PS: I'm using WCF on AppFabric, ok?



System.ServiceModel.CommunicationException: The socket connection was aborted. This could be caused by an error processing your message or a receive timeout being exceeded by the remote host, or an underlying network resource issue. Local socket timeout was '00:01:00'. ---> System.IO.IOException: The write operation failed, see inner exception. ---> System.ServiceModel.CommunicationException: The socket connection was aborted. This could be caused by an error processing your message or a receive timeout being exceeded by the remote host, or an underlying network resource issue. Local socket timeout was '00:01:00'. ---> System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host
   at System.Net.Sockets.Socket.Send(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)
   at System.ServiceModel.Channels.SocketConnection.Write(Byte[] buffer, Int32 offset, Int32 size, Boolean immediate, TimeSpan timeout)
   --- End of inner exception stack trace ---
   at System.ServiceModel.Channels.SocketConnection.Write(Byte[] buffer, Int32 offset, Int32 size, Boolean immediate, TimeSpan timeout)
   at System.ServiceModel.Channels.DelegatingConnection.Write(Byte[] buffer, Int32 offset, Int32 size, Boolean immediate, TimeSpan timeout)
   at System.ServiceModel.Channels.DelegatingConnection.Write(Byte[] buffer, Int32 offset, Int32 size, Boolean immediate, TimeSpan timeout)
   at System.ServiceModel.Channels.BufferedConnection.WriteNow(Byte[] buffer, Int32 offset, Int32 size, TimeSpan timeout, BufferManager bufferManager)
   at System.ServiceModel.Channels.BufferedConnection.Write(Byte[] buffer, Int32 offset, Int32 size, Boolean immediate, TimeSpan timeout)
   at System.ServiceModel.Channels.ConnectionStream.Write(Byte[] buffer, Int32 offset, Int32 count)
   at System.Net.Security.NegotiateStream.StartWriting(Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest)
   at System.Net.Security.NegotiateStream.ProcessWrite(Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest)
   --- End of inner exception stack trace ---
   at System.Net.Security.NegotiateStream.ProcessWrite(Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest)
   at System.Net.Security.NegotiateStream.Write(Byte[] buffer, Int32 offset, Int32 count)
   at System.ServiceModel.Channels.StreamConnection.Write(Byte[] buffer, Int32 offset, Int32 size, Boolean immediate, TimeSpan timeout)
   --- End of inner exception stack trace ---
   at System.ServiceModel.Channels.StreamConnection.Write(Byte[] buffer, Int32 offset, Int32 size, Boolean immediate, TimeSpan timeout)
   at System.ServiceModel.Channels.StreamConnection.Write(Byte[] buffer, Int32 offset, Int32 size, Boolean immediate, TimeSpan timeout, BufferManager bufferManager)
   at System.ServiceModel.Channels.FramingDuplexSessionChannel.OnSend(Message message, TimeSpan timeout)
   at System.ServiceModel.Channels.OutputChannel.Send(Message message, TimeSpan timeout)
   at System.ServiceModel.Dispatcher.DuplexChannelBinder.DuplexRequestContext.OnReply(Message message, TimeSpan timeout)
   at System.ServiceModel.Channels.RequestContextBase.Reply(Message message, TimeSpan timeout)
   at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.Reply(MessageRpc& rpc)