/// <summary>
        /// 根据证书中的appendDetail和客户端配置的WcfClientInvokeAttribute -> SystemCode
        /// 来解析出关联系统的服务连接
        /// </summary>
        /// <param name="code">客户端的配置System Code</param>
        /// <param name="appendDetail">证书中的appendDetail信息以分号分隔</param>
        /// <returns>关联系统的服务的信息</returns>
        private static WcfCredentialInfo resolveSubSystemCredentialInfo(SystemCode code, string appendDetail, WcfCredentialInfo mainCredentialInfo)
        {
            if (!string.IsNullOrEmpty(appendDetail))
            {
                string[] subServices = appendDetail.Split(';');
                if (subServices.Length > 0)
                {
                    foreach (string subService in subServices)
                    {
                        string[] subServiceAttribute = subService.Split(',');
                        if (subServiceAttribute.Length > 0 && subServiceAttribute.Length == 5)
                        {
                            string systemCode = subServiceAttribute[0].Substring(
                                subServiceAttribute[0].IndexOf("CfgName=") + "CfgName=".Length);

                            if (string.Compare(code.ToString(), systemCode, true) == 0)
                            {
                                WcfCredentialInfo subCredetialInfo = MB.Util.MyReflection.Instance.FillModelObject <WcfCredentialInfo>(mainCredentialInfo);
                                string            uri = subServiceAttribute[1].Substring("URL=".Length);
                                subCredetialInfo.EndpointFormatString = uri;
                                subCredetialInfo.BaseAddress          = uri.Substring(0, uri.Length - "{0}.svc".Length - 1);
                                subCredetialInfo.Domain   = subServiceAttribute[2].Substring("Domain=".Length);
                                subCredetialInfo.UserName = subServiceAttribute[3].Substring("LoginName=".Length);
                                subCredetialInfo.Password = subServiceAttribute[4].Substring("LoginPassword=".Length);
                                return(subCredetialInfo);
                            }
                        }
                    }
                }
            }

            return(null);
        }
Beispiel #2
0
        private StringBuilder createCredential()
        {
            string baseAddress = "Http://" + txtServerIP.Text;

            if (numPort.Value > 0 && numPort.Value != 80)
            {
                baseAddress += ":" + numPort.Value.ToString();
            }

            WcfCredentialInfo credential = new WcfCredentialInfo(baseAddress, txtUserName.Text, txtPassword.Text, true);

            credential.EndpointFormatString       = txtFormatString.Text;
            credential.ReplaceRelativePathLastDot = chkReplaceLastDot.Checked;
            if (cobHostType.Text == "IIS")
            {
                credential.HostType = WcfServiceHostType.IIS;
            }
            else
            {
                credential.HostType = WcfServiceHostType.WS;
            }

            if (!string.IsNullOrEmpty(txtDomain.Text))
            {
                credential.Domain = txtDomain.Text;
            }

            credential.AppendDetails = _CredentialDataHelper.CredentialToString();

            StringBuilder s = new StringBuilder();
            EntityXmlSerializer <WcfCredentialInfo> ser = new EntityXmlSerializer <WcfCredentialInfo>();

            s.Append(ser.SingleSerializer(credential, string.Empty));

            return(s);
        }