Ejemplo de invocación de un servicio web de tipo customBindig.
Posibles mensajes de Error si estuviese mal configurado:
InnerExceptionMessage
The message with Action '' cannot be processed at the receiver, due to a ContractFilter mismatch at the EndPointDispatcher. This may be because of either a contract mismatch (mismatched Actions between sender and receiver) or a binding/security mismatch between the sender and the receiver. Check that sender and receiver have the same contract and the same binding (including security requirements, e.g.Message, Transport, None).
public static void Metodo_Configura_customBinding()
{
Uri epUri = new Uri("https://[URL WebService].svc");
CustomBinding binding = new CustomBinding();
binding.Name = "[NombreInterfaceWebService]";
binding.Elements.Add(new TextMessageEncodingBindingElement(MessageVersion.Soap12, System.Text.Encoding.UTF8));
binding.Elements.Add(new HttpsTransportBindingElement());
EndpointAddress endPoint = new EndpointAddress(epUri);
using (var service = new NombreServiceClient(binding, endPoint))
{
try
{
service.NombreDelMetodo(Parametros);
}
catch (Exception ex)
{
throw ex;
}
}
}
viernes, 29 de septiembre de 2017
jueves, 31 de agosto de 2017
Web.config Upload File POST size .NET
<httpRuntime targetFramework="4.5" maxRequestLength="61440" executionTimeout="60000" />
Donde:
maxRequestLength = [MB]*1024
<requestFiltering> <requestLimits maxAllowedContentLength="62914560" /> </requestFiltering>
Donde:maxAllowedContentLength = [MB]*1024*1024
jueves, 30 de marzo de 2017
GENERAR ARCHIVO TXT DESDE SQL SERVER
Para generar un archivo txt desde el SQL Server, se tiene que ejecutar la siguiente sentencia con la estructura:
DECLARE @Cmd AS VARCHAR(1000)
SET @Cmd ='bcp "SELECT DATA FROM [NOMBRE_TABLA] [WHERE CONDICION1]" queryout [RUTA_DIRECTORIO_DESTINO]/[NOMBRE_ARCHIVO].txt -c -T -S [NOMBRE_SERVIDOR_BD] -U [USUARIO_BD] -P [CLAVE_USUARIO_BD] -d [NOMBRE_BD]'
EXECUTE Master.dbo.xp_CmdShell @Cmd
Ejemplo:
DECLARE @Cmd AS VARCHAR(1000)
SET @Cmd ='bcp "SELECT DATA FROM TRN.PROCESO_SALIDA_DETALLE WHERE CODIGO_PROCESO_SALIDA=63" queryout D:\UNIQUE\Documentos\ejemplo\query01_out.txt -c -T -S uni010028021249 -U usr_app_sfc -P u$r_@pp_$fc -d FINANCIERO_PUENTE'
EXECUTE Master.dbo.xp_CmdShell @Cmd
DECLARE @Cmd AS VARCHAR(1000)
SET @Cmd ='bcp "SELECT DATA FROM [NOMBRE_TABLA] [WHERE CONDICION1]" queryout [RUTA_DIRECTORIO_DESTINO]/[NOMBRE_ARCHIVO].txt -c -T -S [NOMBRE_SERVIDOR_BD] -U [USUARIO_BD] -P [CLAVE_USUARIO_BD] -d [NOMBRE_BD]'
EXECUTE Master.dbo.xp_CmdShell @Cmd
Ejemplo:
DECLARE @Cmd AS VARCHAR(1000)
SET @Cmd ='bcp "SELECT DATA FROM TRN.PROCESO_SALIDA_DETALLE WHERE CODIGO_PROCESO_SALIDA=63" queryout D:\UNIQUE\Documentos\ejemplo\query01_out.txt -c -T -S uni010028021249 -U usr_app_sfc -P u$r_@pp_$fc -d FINANCIERO_PUENTE'
EXECUTE Master.dbo.xp_CmdShell @Cmd
jueves, 1 de diciembre de 2016
Enviar correo desde SQL Server
Para enviar correo por SQL Server es a través de la sentencia:
EXEC [msdb].[dbo].[sp_send_dbmail]
@profile_name = 'NombrePerfilCorreo',
@recipients = 'correoDestino@gmail.com',
@copy_recipients = 'otroCorreo@gmail.com',
@body = 'TEST2',
@body_format='html',
@subject = 'NombreDelAsunto'
EXEC [msdb].[dbo].[sp_send_dbmail]
@profile_name = 'NombrePerfilCorreo',
@recipients = 'correoDestino@gmail.com',
@copy_recipients = 'otroCorreo@gmail.com',
@body = 'TEST2',
@body_format='html',
@subject = 'NombreDelAsunto'
jueves, 13 de octubre de 2016
Cookies en ASP.NET C#
Para crear una Cookies en .NET se necesita colocarle un nombre propio. En C# sería:
private void createUserInformationCookie(string username, TokenSecurityGeneratedResponseTypeProxy tokenSecurity, string cookieName)
{
try
{
UserInformation userInformation = new UserInformation();
userInformation.userName = username;
userInformation.tokenSecurityId = tokenSecurity.tokenSecurity.TokenSecurityId;
userInformation.businessUnitCode = tokenSecurity.tokenSecurity.BusinessUnity;
String json = JsonConvert.SerializeObject(userInformation);
HttpCookie cookie = new HttpCookie(cookieName);
cookie.Expires = DateTime.Now.AddHours(Common.cookieExpirationTime);
cookie.Value = json;
cookie.HttpOnly = true;
HttpContext.Response.Cookies.Add(cookie);
}
catch (Exception ex)
{
}
}
private void createUserInformationCookie(string username, TokenSecurityGeneratedResponseTypeProxy tokenSecurity, string cookieName)
{
try
{
UserInformation userInformation = new UserInformation();
userInformation.userName = username;
userInformation.tokenSecurityId = tokenSecurity.tokenSecurity.TokenSecurityId;
userInformation.businessUnitCode = tokenSecurity.tokenSecurity.BusinessUnity;
String json = JsonConvert.SerializeObject(userInformation);
HttpCookie cookie = new HttpCookie(cookieName);
cookie.Expires = DateTime.Now.AddHours(Common.cookieExpirationTime);
cookie.Value = json;
cookie.HttpOnly = true;
HttpContext.Response.Cookies.Add(cookie);
}
catch (Exception ex)
{
}
}
sábado, 8 de octubre de 2016
No se puede cargar el archivo o ensamblado (Excepción de HRESULT: 0x80070020)
Cuando tengan un error en visual studio de tipo "No se puede cargar el archivo o ensamblado (Excepción de HRESULT: 0x80070020)" es probable que otro puerto está siendo usado por el mismo puerto que usa visual studio .net 80 y 443.
miércoles, 5 de octubre de 2016
SQL Service Broker
Los Service Brocker es un servicio que se activa en la base de datos del servidor del SQL Server para realizar una comunicación de Servidor a Cliente.
https://msdn.microsoft.com/es-es/library/bb522893.aspx
Las sentencias en base de datos para activar este servicio son:
ALTER DATABASE [db name] SET ENABLE_BROKER WITH ROLLBACK IMMEDIATE
ALTER AUTHORIZATION ON DATABASE::[db name] TO [sa];
https://msdn.microsoft.com/es-es/library/bb522893.aspx
Las sentencias en base de datos para activar este servicio son:
ALTER DATABASE [db name] SET ENABLE_BROKER WITH ROLLBACK IMMEDIATE
ALTER AUTHORIZATION ON DATABASE::[db name] TO [sa];
Suscribirse a:
Comentarios (Atom)

