private void btnCallWebservice_Click(object sender, System.EventArgs e)
{
try
{
string username = Environment.UserName ;
byte[] passwordBytes = System.Text.Encoding.UTF8.GetBytes( username ) ;
Array.Reverse( passwordBytes ) ;
string passwordEquivalent = Convert.ToBase64String( passwordBytes ) ;
UsernameToken userToken = new UsernameToken( username, passwordEquivalent, PasswordOption.SendHashed ) ;
SignSOAPSvc.SignSOAPWebServices Svc = new SignSOAPSvc.SignSOAPWebServices() ;
Svc.RequestSoapContext.Timestamp.Ttl = 60000 ;
Svc.RequestSoapContext.Security.Tokens.Add( userToken ) ;
Svc.RequestSoapContext.Security.Elements.Add( new Signature( userToken ) ) ;
lblCallRet.Text = Svc.HelloWorld() ;
}
catch ( System.Web.Services.Protocols.SoapException soapex )
{
MessageBox.Show ( soapex.ToString() ) ;
}
catch ( Exception ex )
{
MessageBox.Show( ex.ToString() ) ;
}
} |