I have client code written in C#.net2003 to access secure web service. Im using the proxy class which is generated using "Add Web Reference" option. The code generates the signature which is to be sent as part of soap request to the web service. Can anyone guide me ,why im getting the below error.and how to track to the outgoing request.
please refer the code below and im getting error like"The underlying connection was closed:Could not establish trust relationship with remote server."
SoapContext requestContext = testObj.RequestSoapContext;
UsernameToken unt =
testObj.RequestSoapContext.Security.Tokens.Add(unt);
testObj.RequestSoapContext.Security.MustUnderstand =
testObj.RequestSoapContext.Path.MustUnderstand =
X509CertificateStore myStore= X509CertificateStore.LocalMachineStore(X509CertificateStore.MyStore);
myStore.OpenRead();
X509Certificate cert = (X509Certificate)myStore.Certificates[0];
X509SecurityToken x509certToken =
SecurityToken certToken = (SecurityToken)x509certToken;
testObj.RequestSoapContext.Security.Tokens.Add(certToken);
XmlDocument soapDoc=
soapDoc.LoadXml(inputXml);
Signature sign =
SignedXml signedXml =
Reference reference =
reference.Uri = "#Body";
signedXml.AddReference(reference);
SYSSE.RSA key = SYSSE.RSA.Create();
XmlDocument keyPairDoc=
SYSSE.RSA priKey = SYSSE.RSA.Create();
priKey.FromXmlString(pKey);
signedXml.SigningKey =priKey;
signedXml.SignedInfo.CanonicalizationMethod = SignedXml.XmlDsigCanonicalizationUrl;
signedXml.ComputeSignature();
sign.LoadXml(signedXml.GetXml());
testObj.RequestSoapContext.Security.Elements.Add(sign);