viernes, 29 de septiembre de 2017

WebService CustomBinding

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

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