Hi
I have done all the steps that you wrote. The result is very surprising. I deploy/run both Calculator and SecureCalculator application, both are giving the same error as before. But when i tried to make my own contract-first service and client from scratch, it works fine. My service takes two inputs, age and name and returns both as an object. The code of my web service is given below:
@WebService(serviceName = "simple_WSDLService", portName = "simple_WSDLPort", endpointInterface = "org.netbeans.j2ee.wsdl.simple_wsdl.SimpleWSDLPortType", targetNamespace = "http://j2ee.netbeans.org/wsdl/simple_WSDL", wsdlLocation = "WEB-INF/wsdl/simple_ws/simple_WSDL.wsdl")
public class simple_ws implements SimpleWSDLPortType{
public org.netbeans.xml.schema.simple_schema.StdentInfo simpleWSDLOperation(int age, java.lang.String name) {
//TODO implement this method
//throw new UnsupportedOperationException("Not implemented yet.");
StdentInfo s=new StdentInfo();
//s.setAge(28);
//s.setName("hello");
return s;
}}
Now i have some questions with you. Please answer these.
1. When you have run the SecureCalculator application, either body of the SOAP request and response message was in encrypted form or not? Because when i run my own service and client, body is not encrypted. I am sending you both SOAP request and Response messages given below for help.
INFO: ==== Received Message Start ====
<?xml version="1.0" encoding="UTF-8"?>
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Header>
<wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" S:mustUnderstand="1">
<wsu:Timestamp xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="XWSSGID-1274368650148-293348825">
<wsu:Created>2010-05-20T15:17:31Z</wsu:Created>
<wsu:Expires>2010-05-20T15:22:31Z</wsu:Expires>
</wsu:Timestamp>
<wsse:BinarySecurityToken xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary" ValueType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3" wsu:Id="XWSSGID-1274368650173-667410281">MIICkDCCAfmgAwIBAgIESxdtcDANBgkqhkiG9w0BAQUFADB7MQswCQYDVQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEUMBIGA1UEBxMLU2FudGEgQ2xhcmExGTAXBgNVBAoTEFN1biBNaWNyb3N5c3RlbXMxEjAQBgNVBAsTCUdsYXNzRmlzaDESMBAGA1UEAxMJbG9jYWxob3N0MB4XDTA5MTIwMzA3NDkwNFoXDTE5MTIwMTA3NDkwNFowezELMAkGA1UEBhMCVVMxEzARBgNVBAgTCkNhbGlmb3JuaWExFDASBgNVBAcTC1NhbnRhIENsYXJhMRkwFwYDVQQKExBTdW4gTWljcm9zeXN0ZW1zMRIwEAYDVQQLEwlHbGFzc0Zpc2gxEjAQBgNVBAMTCWxvY2FsaG9zdDCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAsQjbCMsiQXAAAdVU8o2mjATUAM89LBdS6YFQ89RHfM0ZeFwLhsLFN/yDdQv6M80V/2jiev4TTGMrBdRkw2K/wlPQDe5STFupaNVXu+1Ibm8ciuXsBziTh/LMj/EKZqPWT/9CRcYseqL1RxXhYOLgwAPzRlV/OsmasKm3KQGrbIMCAwEAAaMhMB8wHQYDVR0OBBYEFBuO9qJISbB4NeIdFGc/cXrZ2rh5MA0GCSqGSIb3DQEBBQUAA4GBAFs4T2Kqcg3ky7BipsoSrwQimG5XxXl6BoUuyzeWci4p30D4XJ97LN3pDqyKCHsBzi+9eJ102NmBhJnULNZ8oA6hLKg4lJSve3hCQ6NU1udtxGQbr6mHjcpJHEJvC60akSPrE/paTfU6sOBwuoAferkNkG2IN9c4R7y1elIQ5n6Z</wsse:BinarySecurityToken>
<ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#" Id="XWSSGID-1274368650173407781375">
<ds:SignedInfo>
<ds:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#">
<InclusiveNamespaces xmlns="http://www.w3.org/2001/10/xml-exc-c14n#" PrefixList="wsse S"/>
</ds:CanonicalizationMethod>
<ds:SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"/>
<ds:Reference URI="#XWSSGID-12743686517771373251115">
<ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>
<ds:DigestValue>WgUdoUInZPY0UVfCCS1cTTEC3fg=</ds:DigestValue>
</ds:Reference>
<ds:Reference URI="#XWSSGID-1274368650148-293348825">
<ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>
<ds:DigestValue>IR6suhdQDaA12PpbLmM3A3RBEXM=</ds:DigestValue>
</ds:Reference>
</ds:SignedInfo>
<ds:SignatureValue>BShxZgiLHWpnHhjl6DjAivh/ovu+95y8C0foTo2yk9YvnnEe6+nY4fdcskDtSEwAWNDv24dpT781
g0qNM3N/L+qhMbAac02EHjDoR7vEc8z9loxDGfRe8NYt4pxhWl1fi5lacUgKL5MCXln6rKTHCwQA
z6AnUYbSV9mvPAHT4FM=</ds:SignatureValue>
<ds:KeyInfo>
<wsse:SecurityTokenReference xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="XWSSGID-1274368651681577569689">
<wsse:Reference URI="#XWSSGID-1274368650173-667410281" ValueType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3"/>
</wsse:SecurityTokenReference>
</ds:KeyInfo>
</ds:Signature>
</wsse:Security>
<To xmlns="http://www.w3.org/2005/08/addressing">
http://localhost:8080/simple/simple_WSDLService</To>
<Action xmlns="http://www.w3.org/2005/08/addressing">
http://j2ee.netbeans.org/wsdl/simple_WSDL/simple_WSDLPortType/simple_WSDLOperationRequest</Action>
<ReplyTo xmlns="http://www.w3.org/2005/08/addressing">
<Address>
http://www.w3.org/2005/08/addressing/anonymous</Address>
</ReplyTo>
<MessageID xmlns="http://www.w3.org/2005/08/addressing">uuid:e7a3bcaf-5df5-47be-8b8c-a0a5ec306dce</MessageID>
</S:Header>
<S:Body xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="XWSSGID-12743686517771373251115">
<ns2:simple_WSDLOperation xmlns:ns2="http://j2ee.netbeans.org/wsdl/simple_WSDL" xmlns:ns3="http://xml.netbeans.org/schema/simple_schema">
<Age>23</Age>
<Name>jj</Name>
</ns2:simple_WSDLOperation>
</S:Body>
</S:Envelope>
==== Received Message End ====
INFO: ==== Sending Message Start ====
<?xml version="1.0" encoding="UTF-8"?>
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Header>
<wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" S:mustUnderstand="1">
<wsu:Timestamp xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="XWSSGID-1274368653061501120783">
<wsu:Created>2010-05-20T15:17:34Z</wsu:Created>
<wsu:Expires>2010-05-20T15:22:34Z</wsu:Expires>
</wsu:Timestamp>
<wsse:BinarySecurityToken xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary" ValueType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3" wsu:Id="XWSSGID-1274368653061-121652692">MIICkDCCAfmgAwIBAgIESxdtcDANBgkqhkiG9w0BAQUFADB7MQswCQYDVQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEUMBIGA1UEBxMLU2FudGEgQ2xhcmExGTAXBgNVBAoTEFN1biBNaWNyb3N5c3RlbXMxEjAQBgNVBAsTCUdsYXNzRmlzaDESMBAGA1UEAxMJbG9jYWxob3N0MB4XDTA5MTIwMzA3NDkwNFoXDTE5MTIwMTA3NDkwNFowezELMAkGA1UEBhMCVVMxEzARBgNVBAgTCkNhbGlmb3JuaWExFDASBgNVBAcTC1NhbnRhIENsYXJhMRkwFwYDVQQKExBTdW4gTWljcm9zeXN0ZW1zMRIwEAYDVQQLEwlHbGFzc0Zpc2gxEjAQBgNVBAMTCWxvY2FsaG9zdDCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAsQjbCMsiQXAAAdVU8o2mjATUAM89LBdS6YFQ89RHfM0ZeFwLhsLFN/yDdQv6M80V/2jiev4TTGMrBdRkw2K/wlPQDe5STFupaNVXu+1Ibm8ciuXsBziTh/LMj/EKZqPWT/9CRcYseqL1RxXhYOLgwAPzRlV/OsmasKm3KQGrbIMCAwEAAaMhMB8wHQYDVR0OBBYEFBuO9qJISbB4NeIdFGc/cXrZ2rh5MA0GCSqGSIb3DQEBBQUAA4GBAFs4T2Kqcg3ky7BipsoSrwQimG5XxXl6BoUuyzeWci4p30D4XJ97LN3pDqyKCHsBzi+9eJ102NmBhJnULNZ8oA6hLKg4lJSve3hCQ6NU1udtxGQbr6mHjcpJHEJvC60akSPrE/paTfU6sOBwuoAferkNkG2IN9c4R7y1elIQ5n6Z</wsse:BinarySecurityToken>
<ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#" Id="XWSSGID-1274368653061-850795818">
<ds:SignedInfo>
<ds:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#">
<InclusiveNamespaces xmlns="http://www.w3.org/2001/10/xml-exc-c14n#" PrefixList="wsse S"/>
</ds:CanonicalizationMethod>
<ds:SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"/>
<ds:Reference URI="#XWSSGID-12743686542051750876130">
<ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>
<ds:DigestValue>hMYQvuqEkE1WYgAZMc6WZE0QFWU=</ds:DigestValue>
</ds:Reference>
<ds:Reference URI="#XWSSGID-1274368653061501120783">
<ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>
<ds:DigestValue>a0BF9dtQSvnYAFga4xe/Xrzfxdw=</ds:DigestValue>
</ds:Reference>
</ds:SignedInfo>
<ds:SignatureValue>YGHaMkYXAluR67qxi/7r8TSf6dB+Ab9JFBUtPnljiCcGBxk2omffzIY013OXrArAWNeCHTp9ynwQ
R3TVH8cBhG1X/ADZj6HnjAfeKs0O2o9+gNMKNOeqfREaIoRy2870WNbH/UBrCex6BhysbeGF0Saq
bBravYxntHils3BYjOY=</ds:SignatureValue>
<ds:KeyInfo>
<wsse:SecurityTokenReference xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="XWSSGID-1274368654204-451426427">
<wsse:Reference URI="#XWSSGID-1274368653061-121652692" ValueType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3"/>
</wsse:SecurityTokenReference>
</ds:KeyInfo>
</ds:Signature>
</wsse:Security>
</S:Header>
<S:Body xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="XWSSGID-12743686542051750876130">
<ns2:simple_WSDLOperationResponse xmlns:ns2="http://j2ee.netbeans.org/wsdl/simple_WSDL" xmlns:ns3="http://xml.netbeans.org/schema/simple_schema">
<student_object>
<ns3:Age>0</ns3:Age>
</student_object>
</ns2:simple_WSDLOperationResponse>
</S:Body>
</S:Envelope>
==== Sending Message End ====
2. In first question, the client is also a web application. I have developed a java SE client for SecureCalculatorApp. In this the SOAP request message body is encrypted (as given in my earlier posts) but error in SOAP response message (as given in my earlier post i.e.
SEVERE: WSS0265: Primary Policy Violation occured
SEVERE: com.sun.xml.wss.XWSSecurityException: com.sun.xml.wss.impl.PolicyViolationException: Expected Signature Element as per receiver requirements, found )
Please guide me if you have any suggestion. Actually i have to encrypt the body of SOAP messages. Also different parts of SOAP body not all the body.
Waiting for your answer eagerly!!
Thanks a lot