The moose likes Web Services and the fly likes .net Webservice Integration with Java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Elasticsearch in Action this week in the Big Data forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark ".net Webservice Integration with Java" Watch ".net Webservice Integration with Java" New topic

.net Webservice Integration with Java

anubechara Gupta

Joined: Jul 05, 2006
Posts: 17
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");
rocket mass heater kickstarter
subject: .net Webservice Integration with Java