Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

.net Webservice Integration with Java  RSS feed

anubechara Gupta
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Ranchers
I am trying to consume .net Webservice by making java client. The service is using WSSE security standards. We have to encrypt the body contents of Soap message with the help og User Name Security token.I am using WSS4J for doing this but the .net is not able to decrypt the data. Seeems like our keys are different, The AES256 algorithm has to be used for encryption of messages and key should be combination of password+nonce+createdtimestamp. I am attaching the java code which I am using to encrypt the message. Please suggest what mistake I am making. I will be very thankful.

public static void addEncryption(WSSecHeader wsSecHeader, WSSecUsernameToken token, Document soapDoc, SecretKey key)
throws Exception
Reference reference;
reference = new Reference(soapDoc);
reference.setURI("#" + token.getId());

SecurityTokenReference securityTokenReference = new SecurityTokenReference(soapDoc);


WSSecurityUtil.setNamespace(securityTokenReference.getElement(), "", "wsse");

WSSecEncrypt secEncrypt = new WSSecEncrypt();




SOAPConstants soapConstants = WSSecurityUtil.getSOAPConstants(soapDoc.getDocumentElement());

Vector parts = new Vector();
WSEncryptionPart encP = new WSEncryptionPart(soapConstants.getBodyQName().getLocalPart(), soapConstants.getEnvelopeURI(), "Content");


//secEncrypt.setParts(parts);, null, wsSecHeader);
catch (WSSecurityException wsEx) {
throw new Exception("Unable to encrypt the message parts");
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!