miércoles, 5 de mayo de 2021

CONSUMIR SERVICIO WEB SOAP - AUTENTIFICACION BASICAUTH

 Estimados,


En esta ocasion veremos como consumir un servicio web AUTENTIFICACION BASICAUTH, para ello despues de consumir el SW, tenemos que modificar lo siguiente en el web.config, deberia de quedar algo asi.


 <binding name="RecepcionOC_PortType_IniciarRecepcionOC_REQUEST_binding">

<!--   <security mode="Transport"  /> -->

<!--Para un SOAP DE MANERA SEGURA CON Aut Basic AGREGAR ESTO INICIO-->

<security mode="Transport">

<!--<security mode="None">-->

<!--<transport clientCredentialType="None" proxyCredentialType="None" realm=""/>

<message clientCredentialType="UserName" algorithmSuite="Default"/> -->


<transport clientCredentialType="Basic" proxyCredentialType="None" realm=""/>

<message clientCredentialType="UserName" algorithmSuite="Default"/>


</security>

<!--FINALIZA Basic-->

    </binding>

   

y en el .CS


SRVRecepcionOC_ENTEL.RecepcionOC_PortType_IniciarRecepcionOC_REQUESTClient 

                oRecepcionOC_PortType_IniciarRecepcionOC_REQUESTClient = new SRVRecepcionOC_ENTEL.RecepcionOC_PortType_IniciarRecepcionOC_REQUESTClient();

             

            oRecepcionOC_PortType_IniciarRecepcionOC_REQUESTClient.ClientCredentials.UserName.UserName= "USER_BASICAUTH";

            oRecepcionOC_PortType_IniciarRecepcionOC_REQUESTClient.ClientCredentials.UserName.Password= "PASSWORD_BASICAUTH";

            


            SRVRecepcionOC_ENTEL.recepcionOCRequest orecepcionOCRequest = new SRVRecepcionOC_ENTEL.recepcionOCRequest();

 

            SRVRecepcionOC_ENTEL.rtaType[] ortaType = oRecepcionOC_PortType_IniciarRecepcionOC_REQUESTClient.recepcionOC(orecepcionOCRequest);


            string Rpta = "";

            int RptaInt = 0;

            if (ortaType != null) {

                

                foreach (SRVRecepcionOC_ENTEL.rtaType prtaType in ortaType)

                {

                    RptaInt = prtaType.XV_COD_RPTA;

                    Rpta = prtaType.XV_MSG_RPTA.ToString();

                }

            }