예제 #1
0
        public void Run(string input)
        {
            string var;

            // Create an instance of the Web service proxy
            echoWse serviceProxy = new echoWse();

            X509SecurityToken token = GetClientToken();

            if (token == null)
            {
                throw new ApplicationException("Unable to obtain security token.");
            }

            // Add an EncryptedData element to the security collection
            // to encrypt the request.
            serviceProxy.RequestSoapContext.Security.Elements.Add(new EncryptedData(token));

            // Add the signature element to a security section on the request
            // to sign the request
            token = GetServerToken();
            if (token == null)
            {
                throw new ApplicationException("Unable to obtain security token.");
            }

            serviceProxy.RequestSoapContext.Security.Tokens.Add(token);
            serviceProxy.RequestSoapContext.Security.Elements.Add(new MessageSignature(token));

            // Call the service
            serviceProxy.Url = this.url;
            Console.WriteLine("Calling {0}", serviceProxy.Url);

            var = input;
            serviceProxy.echo(ref var);

            Console.WriteLine("Web Service called successfully.\n" + var);
        }
      public void Run (string input) 
	{

	  string var;

	  // Create an instance of the Web service proxy
	  echoWse serviceProxy = new echoWse ();

	  X509SecurityToken token = GetClientToken ();
	  if (token == null)
	    throw new ApplicationException ("Unable to obtain security token.");

	  // Add an EncryptedData element to the security collection
	  // to encrypt the request.
	  serviceProxy.RequestSoapContext.Security.Elements.Add (new EncryptedData (token));

	  // Add the signature element to a security section on the request
	  // to sign the request
	  token = GetServerToken ();
	  if (token == null)
	    throw new ApplicationException ("Unable to obtain security token.");

	  serviceProxy.RequestSoapContext.Security.Tokens.Add (token);
	  serviceProxy.RequestSoapContext.Security.Elements.Add (new MessageSignature (token));

	  // Call the service
	  serviceProxy.Url = this.url;
	  Console.WriteLine ("Calling {0}", serviceProxy.Url);

	  var = input;
	  serviceProxy.echo (ref var);

	  Console.WriteLine ("Web Service called successfully.\n" + var);
	}