sábado, 20 de marzo de 2010

WCF Error handling and best practices

Este post me parece util

http://blogs.msdn.com/pedram/archive/2008/01/25/wcf-error-handling-and-some-best-practices.aspx

viernes, 19 de marzo de 2010

Script para buscar cadena en Bases de Datos

Utiliza este script para buscar cualquier cadena (Campo, SP, Vista, Function, etc) en una o varias Bases de Datos, debes estar conectado a la base de datos Master de tu servidor para que funcione.


DECLARE @cadena varchar(50),
@bd varchar(50),
@str varchar(1024),
@servidor varchar(30)

select @servidor = @@servername

print 'Local Server: ' + @servidor + ''

select @cadena = 'session_id = 300'

DECLARE bdcursor cursor for select name from sysdatabases where name not in ('NADA')

open bdcursor
fetch bdcursor into @bd

WHILE @@FETCH_STATUS = 0
BEGIN
select @str = 'select '''
+ @bd + '''' + ' as DB, '
+ 'a.name as objeto, '
+ 'a.type as type, '
+ '''...'' + SUBSTRING(b.text, CHARINDEX(''' + @cadena + ''', b.text) - 60, LEN(''' + @cadena + ''') + 120) + ''...''' + ' as previo '
+ 'from '
+ @bd + '..sysobjects a, '
+ @bd + '..syscomments b '
+ 'where '
+ 'a.id = b.id '
+ 'and b.text like ''%' + @cadena + '%'''
+ ' order by objeto'

print 'Buscando en DB: [' + @bd + ' ] -- Cadena: [' + @cadena + ']'
--print @str
exec(@str)

fetch bdcursor into @bd
END

DEALLOCATE bdcursor

miércoles, 3 de marzo de 2010

Configuración para Servicio WCF y F5

Recientemente, tuve que exponer un Servicio WCF (Windows Communication Fundation) a través de F5 (BIG IP), donde la comunicación desde el cliente al F5 es a través de HTTPS y del F5 al el WFC a través de HTTP.

El verdadero reto cuando trabajas con WCF es su configuración y sus múltiples variantes para soportar todo tipo de protocolos, seguridad, identidad, etc. Debido a esto estuve varios días buscando y probando varias configuraciones que cumplieran con mis expectativas.

Primero agrega el atributo [ServiceBehavior(AddressFilterMode = AddressFilterMode.Any)] a la interfaz del servicio para permitir la conexión cliente-f5-wcf.

Lo siguiente es utilizar la siguiente configuración en el Servicio WCF

<system.serviceModel> <services> <service behaviorConfiguration="BIGIPBehavior" name="WCF_Service.ServiceDemo" > <endpoint address="" binding="wsHttpBinding" bindingConfiguration="BIGIPBinding" contract="WCF_Service.IServiceDemo"> </endpoint> </service> </services> <bindings> <wsHttpBinding> <binding name="BIGIPBinding" closeTimeout="05:00:00" maxBufferPoolSize="10000000" maxReceivedMessageSize="1000000000" openTimeout="05:00:00" receiveTimeout="05:00:00" sendTimeout="05:00:00"> <security mode="None"> <transport clientCredentialType="None" proxyCredentialType="None" /> <message clientCredentialType="Windows" establishSecurityContext="false" negotiateServiceCredential="true" /> </security> </binding> </wsHttpBinding> </bindings> <behaviors> <serviceBehaviors> <behavior name="BIGIPBehavior"> <serviceMetadata httpGetEnabled="True"/> <serviceDebug includeExceptionDetailInFaults="true"/> <dataContractSerializer maxItemsInObjectGraph="1000000000" /> </behavior> </serviceBehaviors> </behaviors> </system.serviceModel>

Finalmente, esta es la configuración a utilizar en el cliente

<system .servicemodel=""> <bindings> <wshttpbinding> <binding closetimeout="05:00:00" maxbufferpoolsize="100000000" maxreceivedmessagesize="1000000000" name="BIGIPBinding" opentimeout="05:00:00" receivetimeout="05:00:00" sendtimeout="05:00:00"> <security mode="Transport"> <transport clientcredentialtype="None" proxycredentialtype="None"> <message clientcredentialtype="Windows" establishsecuritycontext="false" negotiateservicecredential="true"> </message></transport></security> <readerquotas maxarraylength="1000000" maxbytesperread="1000000" maxdepth="1000000" maxnametablecharcount="1000000" maxstringcontentlength="1000000000"> </readerquotas></binding> </wshttpbinding> </bindings> <client> <endpoint address="https://test.mytest.com/WCF_BIG_IP_DEMO/ServiceDemo.svc" binding="wsHttpBinding" bindingconfiguration="BIGIPBinding" contract="ServiceDemoReference.IServiceDemo" name=""> </endpoint> </client> </system>

Nota: Los valores de los atributos de ambas configuraciones deben ser cambiados a la necesidad del proyecto.

Referencias

jueves, 25 de febrero de 2010

IIS7 Hosting WCF

I was setting up a project on my local box that was hosting a WCF service. These web services have a .svc file extension and apparently IIS 7 out of the box doesn’t know what to do with them.

The error you get will look something like this:

HTTP Error 404.3 - Not Found

The page you are requesting cannot be served because of the extension configuration. If the page is a script, add a handler. If the file should be downloaded, add a MIME map. Detailed Error InformationModule StaticFileModule

And there will be more info listed below that shows some items related to your local machine. So after much trial and error and a lot of Google slapping, I finally found the answer to my problem.
Open Visual Studio 2008 Command prompt.

Navigate to C:\Windows\Microsoft.NET\Framework\v3.0\Windows Communication Foundation

Run this command: servicemodelreg –i


Apparently when IIS 7 is installed they don’t turn everything on for you and so you are required to do it yourself.

Hopefully, this has saved some of you some time and frustration.

Referencia. http://tonytriguero.com/iis-7-and-webservices-svc-file-extension/