コード例 #1
0
ファイル: ProxyUtils.cs プロジェクト: lmunozv/Proyectos-GIT
        public static CustomBinding CreateCustomBinding()
        {
            ProxyUtils.ByPassCertificate();
            WSMessageEncoding msgEncoding;

            msgEncoding = WSMessageEncoding.Mtom;
            BasicHttpSecurityMode sec          = BasicHttpSecurityMode.TransportWithMessageCredential;
            BasicHttpBinding      basicBinding = new BasicHttpBinding(sec)
            {
                Security =
                {
                    Message                  =
                    {
                        ClientCredentialType = BasicHttpMessageCredentialType.UserName
                    }
                },
                MessageEncoding = msgEncoding,
            };
            var elements = basicBinding.CreateBindingElements();

            if (msgEncoding == WSMessageEncoding.Text)
            {
                TextMessageEncodingBindingElement te = elements.Find <TextMessageEncodingBindingElement>();
                te.MessageVersion = MessageVersion.Soap12;
            }
            else
            {
                MtomMessageEncodingBindingElement te = elements.Find <MtomMessageEncodingBindingElement>();
                te.MessageVersion = MessageVersion.Soap12;
            }
            CustomBinding customBinding = new CustomBinding(elements);

            return(customBinding);
        }
コード例 #2
0
ファイル: ProxyUtils.cs プロジェクト: lmunozv/Proyectos-GIT
 /**
  * funcion para obtener las credenciales basic enviadas en la cabecera del mensaje.
  *
  */
 public static NetworkCredential getReceivedCredentials()
 {
     return(new NetworkCredential(ProxyUtils.GetServiceUser("UsrServices"), ProxyUtils.GetServicePwd("PwdServices")));
     //HttpContext httpContext = HttpContext.Current;
     //string authHeader = httpContext.Request.Headers["Authorization"];
     //if (authHeader != null && authHeader.StartsWith("Basic"))
     //{
     //    string encodedUsernamePassword = authHeader.Substring("Basic ".Length).Trim();
     //    Encoding encoding = Encoding.GetEncoding("iso-8859-1");
     //    string usernamePassword = encoding.GetString(Convert.FromBase64String(encodedUsernamePassword));
     //    int seperatorIndex = usernamePassword.IndexOf(':');
     //    var username = usernamePassword.Substring(0, seperatorIndex);
     //    var password = usernamePassword.Substring(seperatorIndex + 1);
     //    return new NetworkCredential(username, password);
     //}
     //else
     //{
     //    return null;
     //}
 }
コード例 #3
0
ファイル: ProxyUtils.cs プロジェクト: lmunozv/Proyectos-GIT
        public static HttpRequestMessageProperty GetHttpRequestMessageProperty()
        {
            HttpRequestMessageProperty httpRequestMessageProperty = new HttpRequestMessageProperty();

            httpRequestMessageProperty.Headers[HttpRequestHeader.Authorization] = "Basic " + Convert.ToBase64String(Encoding.ASCII.GetBytes(ProxyUtils.GetServiceUser("UsrServices") + ":" + ProxyUtils.GetServicePwd("PwdServices")));
            return(httpRequestMessageProperty);
        }