Hi
I am doing application for signing of soap message with digital certificate . I am using WSE 2.0
I worte the the simple webservice & deployed it on in our server machine . To make it secured i added the certificate to IIS .
My web service code like this.
[WebMethod]
public int Add (int Num1 ,int Num2 )
{
int total=0;
SoapContext soapCntxt = RequestSoapContext.Current;
if (soapCntxt==null)
throw new Exception("Only SOAP requests are permitted.");
foreach(SecurityToken token in soapCntxt.Security.Tokens)
{
if(token is X509SecurityToken )
{
X509SecurityToken objSecurityToken = (X509SecurityToken)token;
if(objSecurityToken.Certificate.FriendlyDisplayNam e == "www.capsilon.com" )
{
total= Num1+Num2;
}
}
}
return total;
}//End Of WebMethod Add
when i am accessing the web service on client machine it show's the certificate in the browser. I deployed that certificate on my m/c in personal store & corresponding certificate in Trust store to make handshake proper.
I have done all the configuration with my client code.I make my proxy class inheritaed from Microsoft.Web.Services2.WebServicesClientProtocol
My client code looks like this.
WebReference.Service1 objProxy = new WebReference.Service1();
X509SecurityToken token = null;
token = AppBase.GetClientToken(true);
if (token == null)
throw new ApplicationException("Unable to obtain security token.");
objProxy.RequestSoapContext.Security.Tokens.Add(to ken); //Old Changes
objProxy.RequestSoapContext.Security.Elements.Add( new MessageSignature(token));
objProxy.Timeout = 2250000;
objProxy.Destination = new Microsoft.Web.Services2.Addressing.EndpointReferen ce(new Uri("http://192.168.42.23/SSLWebService/Service1.asmx"));
int strReturn = objProxy.Add(5, 10);
MessageBox.Show(strReturn.ToString());
When I make a call to webservice method , I am checking the RequestSoapContext.current it is getting null so i am throwing my own exception
also in my client program i am viewign the content of requesstSoapContext , i am getting Enevelop as null .
but at the call of method i am getting following Exception.
System.Web.Services.Protocols.SoapException: Server was unable to process request. --> Only SOAP requests are permitted.
at System.Web.Services.Protocols.SoapHttpClientProtoc ol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall)
at System.Web.Services.Protocols.SoapHttpClientProtoc ol.Invoke(String methodName, Object[] parameters)
at SMARTDocUploadClient.WebReference.Service1.Add(Int 32 Num1, Int32 Num2) in D:\DDTClient\SMARTDocUploadClient\Web References\WebReference\Reference.cs:line 79
at SMARTDocUploadClient.Form1.button1_Click(Object sender, EventArgs e) in D:\DDTClient\SMARTDocUploadClient\Form1.cs:line 340
Can any One help me Out as early as possible
Plese Provide Me the Solution
If any one need more details please send me mail to get details or If you are not getting the problem
Thanks & Regards
Vaibhav Chavan.