Exemplo n.º 1
0
        public void WcfServiceTest()
        {
            WfNetworkCredential credential = new WfNetworkCredential();
            string url        = @"http://localhost/MCSWebApp/WcfServiceDemo/Service1.svc";
            string addressKey = "testaddress";
            WfServiceAddressDefinition addressDef =
                new WfServiceAddressDefinition(WfServiceRequestMethod.Post, credential, url);

            addressDef.Key         = addressKey;
            addressDef.ContentType = WfServiceContentType.Json;

            WfGlobalParameters.Default.ServiceAddressDefs.Add(addressDef);

            string paraVal = @"{""BoolValue"":""true"",""StringValue"":""test""}";
            WfServiceOperationParameter operationParam =
                new WfServiceOperationParameter()
            {
                Name = "composite", Type = WfSvcOperationParameterType.String, Value = paraVal
            };
            WfServiceOperationDefinition operationDef =
                new WfServiceOperationDefinition(addressKey, "PostContract", new WfServiceOperationParameterCollection()
            {
                operationParam
            }, "");
            WfServiceInvoker invoker = new WfServiceInvoker(operationDef);
            var result = invoker.Invoke();

            Console.WriteLine(result.ToString());
        }
Exemplo n.º 2
0
        protected void btnConfirm_Click(object sender, EventArgs e)
        {
            try
            {
                string key                     = this.opKey.Value.Trim();
                string address                 = this.txtServiceAddress.Text.Trim();
                string requestMethod           = this.dropSendType.SelectedValue;
                string credentialKey           = this.dropCredential.SelectedValue;
                WfNetworkCredential credential = new WfNetworkCredential();

                WfGlobalParameters         parameters     = WfGlobalParameters.LoadProperties(ParametersKey);
                WfServiceAddressDefinition serviceAddress = parameters.ServiceAddressDefs[key];

                if (serviceAddress == null)
                {
                    serviceAddress = new WfServiceAddressDefinition();
                }

                serviceAddress.Key           = key;
                serviceAddress.Address       = address;
                serviceAddress.RequestMethod = (WfServiceRequestMethod)Enum.Parse(typeof(WfServiceRequestMethod), requestMethod);
                serviceAddress.ContentType   = (WfServiceContentType)Enum.Parse(typeof(WfServiceContentType), this.ddlContentType.SelectedValue);
                serviceAddress.Credential    = parameters.Credentials.FirstOrDefault(p => p.Key == credentialKey);

                parameters.ServiceAddressDefs.Remove(p => p.Key == serviceAddress.Key);
                parameters.ServiceAddressDefs.Add(serviceAddress);
                parameters.Update();
                WebUtility.RefreshParentWindow();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
		protected void btnConfirm_Click(object sender, EventArgs e)
		{
			try
			{
				string key = this.opKey.Value.Trim();
				string address = this.txtServiceAddress.Text.Trim();
				string requestMethod = this.dropSendType.SelectedValue;
				string credentialKey = this.dropCredential.SelectedValue;
				WfNetworkCredential credential = new WfNetworkCredential();

				WfGlobalParameters parameters = WfGlobalParameters.LoadProperties(ParametersKey);
				WfServiceAddressDefinition serviceAddress = parameters.ServiceAddressDefs[key];

				if (serviceAddress == null)
				{
					serviceAddress = new WfServiceAddressDefinition();
				}

				serviceAddress.Key = key;
				serviceAddress.Address = address;
				serviceAddress.RequestMethod = (WfServiceRequestMethod)Enum.Parse(typeof(WfServiceRequestMethod), requestMethod);
				serviceAddress.ContentType = (WfServiceContentType)Enum.Parse(typeof(WfServiceContentType), this.ddlContentType.SelectedValue);
				serviceAddress.Credential = parameters.Credentials.FirstOrDefault(p => p.Key == credentialKey);

				parameters.ServiceAddressDefs.Remove(p => p.Key == serviceAddress.Key);
				parameters.ServiceAddressDefs.Add(serviceAddress);
				parameters.Update();
				WebUtility.RefreshParentWindow();
			}
			catch (Exception ex)
			{
				throw ex;
			}
		}
		public override object Deserialize(IDictionary<string, object> dictionary, Type type, JavaScriptSerializer serializer)
		{
			WfNetworkCredential credential = new WfNetworkCredential();

			credential.Key = DictionaryHelper.GetValue(dictionary, "Key", string.Empty);
			credential.LogOnName = DictionaryHelper.GetValue(dictionary, "LogOnName", string.Empty);
			credential.Password = DictionaryHelper.GetValue(dictionary, "Password", string.Empty);

			return credential;
		}
        public static void AreEqual(this WfNetworkCredential actual, LogOnIdentity identity)
        {
            if (actual == null && identity == null)
            {
                return;
            }

            Assert.AreEqual(actual.LogOnNameWithoutDomain, identity.LogOnNameWithoutDomain);
            Assert.AreEqual(actual.Password, identity.Password);
            Assert.AreEqual(actual.Domain, identity.Domain);
        }
Exemplo n.º 6
0
 public WfServiceInvokerFactory()
 {
     Url        = @"http://localhost/MCSWebApp/WebTestProject/Services/ProcessTestService.asmx";
     ParaList   = new WfServiceOperationParameterCollection();
     Credential = new WfNetworkCredential();
     AddressDef = new WfServiceAddressDefinition(WfServiceRequestMethod.Get,
                                                 Credential, Url);
     AddressDef.Key = Guid.NewGuid().ToString();
     WfGlobalParameters.Default.ServiceAddressDefs.Add(AddressDef);
     AddressDef.ServiceNS = @"http://tempuri.org/";
     SvcOpDef             = new WfServiceOperationDefinition(AddressDef.Key, Operation, ParaList, "");
 }
		public WfServiceInvokerFactory()
		{
			Url = @"http://localhost/MCSWebApp/WebTestProject/Services/ProcessTestService.asmx";
			ParaList = new WfServiceOperationParameterCollection();
			Credential = new WfNetworkCredential();
			AddressDef = new WfServiceAddressDefinition(WfServiceRequestMethod.Get,
				Credential, Url);
			AddressDef.Key = Guid.NewGuid().ToString();
			WfGlobalParameters.Default.ServiceAddressDefs.Add(AddressDef);
			AddressDef.ServiceNS = @"http://tempuri.org/";
			SvcOpDef = new WfServiceOperationDefinition(AddressDef.Key, Operation, ParaList, "");
		}
Exemplo n.º 8
0
 private void SetHiddenJsonData()
 {
     try
     {
         string Key = MCS.Web.Library.WebUtility.GetRequestParamString("key", string.Empty);
         if (!string.IsNullOrEmpty(Key))
         {
             WfGlobalParameters  parameters = WfGlobalParameters.LoadProperties(ParametersKey);
             WfNetworkCredential obj        = parameters.Credentials.Find(p => p.Key == Key);
             this.txtKey.Value       = obj.Key;
             this.txtLogonName.Value = obj.LogOnName;
         }
     }
     catch (Exception ex)
     {
         WebUtility.ShowClientError(ex.Message, ex.StackTrace, "错误");
     }
 }
        protected void btnConfirm_Click(object sender, EventArgs e)
        {
            string key = this.txtKey.Value;
            string logonName = this.txtLogonName.Value;
            string password = this.txtPassword.Value;

            WfGlobalParameters parameters = WfGlobalParameters.LoadProperties(ParametersKey);
            WfNetworkCredential credential = parameters.Credentials.Find(obj => obj.Key == key);

            if (credential == null)
            {
                credential = new WfNetworkCredential();
                credential.Key = key;
            }

            credential.LogOnName = logonName;
            credential.Password = password;

            parameters.Credentials.Remove(obj => obj.Key == key);
            parameters.Credentials.Add(credential);
            parameters.Update();
        }
Exemplo n.º 10
0
        protected void btnConfirm_Click(object sender, EventArgs e)
        {
            string key       = this.txtKey.Value;
            string logonName = this.txtLogonName.Value;
            string password  = this.txtPassword.Value;

            WfGlobalParameters  parameters = WfGlobalParameters.LoadProperties(ParametersKey);
            WfNetworkCredential credential = parameters.Credentials.Find(obj => obj.Key == key);

            if (credential == null)
            {
                credential     = new WfNetworkCredential();
                credential.Key = key;
            }

            credential.LogOnName = logonName;
            credential.Password  = password;

            parameters.Credentials.Remove(obj => obj.Key == key);
            parameters.Credentials.Add(credential);
            parameters.Update();
        }
Exemplo n.º 11
0
		public void WcfServiceTest()
		{
			WfNetworkCredential credential = new WfNetworkCredential();
			string url = @"http://localhost/MCSWebApp/WcfServiceDemo/Service1.svc";
			string addressKey = "testaddress";
			WfServiceAddressDefinition addressDef =
				new WfServiceAddressDefinition(WfServiceRequestMethod.Post, credential, url);
			addressDef.Key = addressKey;
			addressDef.ContentType = WfServiceContentType.Json;

			WfGlobalParameters.Default.ServiceAddressDefs.Add(addressDef);

			string paraVal = @"{""BoolValue"":""true"",""StringValue"":""test""}";
			WfServiceOperationParameter operationParam =
				new WfServiceOperationParameter() { Name = "composite", Type = WfSvcOperationParameterType.String, Value = paraVal };
			WfServiceOperationDefinition operationDef =
				new WfServiceOperationDefinition(addressKey, "PostContract", new WfServiceOperationParameterCollection() { operationParam }, "");
			WfServiceInvoker invoker = new WfServiceInvoker(operationDef);
			var result = invoker.Invoke();
			Console.WriteLine(result.ToString());
		}