Click here to Skip to main content
16,016,180 members
Please Sign up or sign in to vote.
3.50/5 (2 votes)
Hi all,

In one of my application I need to invoke a web service.The web service uses OASIS standard. The conditions are as follows:

A ) The request has to be digitally signed using the private key of the user.Signature
include key info element that contains X.509 certificate details.This is needed for
server to validate the signer.The below elements in the SOAP request has to be signed

Timestamp
UsernameToken
Body

B) After signing, the request has to be encrypted using the e-Filing’s public key
Use the URI https://incometaxindiaefiling.gov.in/eFiling/Portal/WebServiceIncomeTaxPublicKey.cer to download the public key.
The below contents are encrypted using the public key
UsernameToken
Body

BulkPanService Servicee = new BulkPanService();


           // Create the UsernameToken we use to sign the message
           UsernameToken userToken;
           userToken = new UsernameToken("XXXXXX", "XXXXX", PasswordOption.SendHashed);
           Servicee.SetClientCredential(userToken);

           // Adds the token to the SOAP header.
           SoapContext context = Servicee.RequestSoapContext;
           context.Security.Timestamp.TtlInSeconds = 60000;
           context.Security.Tokens.Add(userToken);


           MessageSignature sig = new MessageSignature(signatureToken);
           sig.SignatureOptions = SignatureOptions.IncludeTimestamp | SignatureOptions.IncludeSoapBody;
           context.Security.Elements.Add(sig);

           BulkPanRequest request = new BulkPanRequest();
           request.uniqueRequestId = "XXXXXXXX";

           FileStream stream = File.OpenRead(@"path");
           byte[] fileBytes = new byte[stream.Length];
           stream.Read(fileBytes, 0, fileBytes.Length);
           stream.Close();
           request.dataHandler = fileBytes;

           //  First of all create an encrypting token
           X509SecurityToken encryptingToken = GetServerToken();


           // Encrypt the UsernameToken element in the SOAP header
           Servicee.RequestSoapContext.Security.Elements.Add(new EncryptedData(encryptingToken));

           BulkPanResponse response = new BulkPanResponse();
           response = Servicee.uploadBulkPan(request);


But when
C#
Servicee.RequestSoapContext.Security.Elements.Add(new EncryptedData(encryptingToken));

line executes It is throwing error
C#
WSE527: The SecurityToken does not support data encryption.
.

Please anyone who knows how to invoke the webservice with the above condition, help me to sort this issue.

Thank You
Posted
Updated 12-Aug-18 21:58pm
Comments
rahulmane811 31-Jan-18 5:22am    
i am also having same problem have you got any solution?

1 solution

Hello, do you find any solution. If yes, Please guide me.
 
Share this answer
 
Comments
Shiji lKailas 31-May-19 1:21am    
Hello

Have you find any solution? I am facing same issue.

Thanks

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900