WSDL2Java Pass header in the request
Hi' Guys,
First thing I am new to this forum so please excuse me if I have posted this to the wrong place.
My query is for WSDL2Java API,
I have a security header which needs to be passed to the service, I have generated the classes and writing a client which will pass the input to the web service, the service is secured so I need to pass the security header,
<soapenv:Header>
<wsse:Security soapenv:mustUnderstand="1" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<wsse:UsernameToken wsu:Id="UsernameToken-2" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<wsse:Username>weblogic</wsse:Username>
<wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">welcome1</wsse:Password>
</wsse:UsernameToken>
</wsse:Security>
<v1:GMWSHeader>
<v1:SourceId>String</v1:SourceId>
<v1:TransactionId>String</v1:TransactionId>
<v1:TransactionTimeStamp>1967-08-13</v1:TransactionTimeStamp>
<v1:ServiceVersion>LATEST</v1:ServiceVersion>
</v1:GMWSHeader>
</soapenv:Header>
I have coded this to some extend however when I did a sysout, I found out that the XML which it is passing is not 100% same, I am also getting exception the error logs are as below, alo the java code which I have written to pass this header,
Java code:
/*Set Security Header*/
SOAPHeaderElement securityHeader = new SOAPHeaderElement(namespace1, "Security");
SOAPElement usernametoken = securityHeader.addChildElement("UsernameToken");
usernametoken.setAttributeNS(namespace3, "Id", "UsernameToken-2");
SOAPElement username = usernametoken.addChildElement("Username");
SOAPElement password = usernametoken.addChildElement("Password");
password.setAttribute("Type", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText");
username.addTextNode("weblogic");
password.addTextNode("welcome1");
((Stub)port).setHeader(securityHeader);
System.out.println("securityHeader :"+securityHeader);
SOAPHeaderElement gmwsheader = new SOAPHeaderElement(namespace2, "GMWSHeader");
SOAPElement SourceId = gmwsheader.addChildElement("SourceId");
SOAPElement TransactionId = gmwsheader.addChildElement("TransactionId");
SOAPElement TransactionTimeStamp = gmwsheader.addChildElement("TransactionTimeStamp") ;
SOAPElement ServiceVersion = gmwsheader.addChildElement("ServiceVersion");
SourceId.addTextNode("String");
TransactionId.addTextNode("String");
TransactionTimeStamp.addTextNode("1967-08-13");
ServiceVersion.addTextNode("LATEST");
((Stub)port).setHeader(gmwsheader);
error log:
[2011-04-14T18:21:40.881+05:30] [OSBServer] [ERROR] [WSM-00006] [oracle.wsm.resources.security] [tid: [ACTIVE].ExecuteThread: '22' for queue: 'weblogic.kernel.Default (self-tuning)'] [userId: <anonymous>] [ecid: 0000IxK4IQm1baURM6XBhA1DdcAP00001K,0] [APP: XBus Kernel] [dcid: 7e8d956afafee9bd:5c0a5e76:12f526e310e:-8000-00000000000000f7] [arg: oracle.wsm.security.SecurityException: WSM-00069 : The security header is missing.] Error in receiving the request: oracle.wsm.security.SecurityException: WSM-00069 : The security header is missing..
[2011-04-14T18:21:40.881+05:30] [OSBServer] [ERROR] [WSM-07607] [oracle.wsm.resources.enforcement] [tid: [ACTIVE].ExecuteThread: '22' for queue: 'weblogic.kernel.Default (self-tuning)'] [userId: <anonymous>] [ecid: 0000IxK4IQm1baURM6XBhA1DdcAP00001K,0] [APP: XBus Kernel] [dcid: 7e8d956afafee9bd:5c0a5e76:12f526e310e:-8000-00000000000000f7] [arg: {http://schemas.oracle.com/ws/2006/01/securitypolicy}wss-username-token] [arg: oracle.wsm.security.policy.scenario.executor.WssUs ernameTokenScenarioExecutor] Failure in execution of assertion {http://schemas.oracle.com/ws/2006/01/securitypolicy}wss-username-token executor class oracle.wsm.security.policy.scenario.executor.WssUs ernameTokenScenarioExecutor.
[2011-04-14T18:21:40.881+05:30] [OSBServer] [ERROR] [WSM-07602] [oracle.wsm.resources.enforcement] [tid: [ACTIVE].ExecuteThread: '22' for queue: 'weblogic.kernel.Default (self-tuning)'] [userId: <anonymous>] [ecid: 0000IxK4IQm1baURM6XBhA1DdcAP00001K,0] [APP: XBus Kernel] [dcid: 7e8d956afafee9bd:5c0a5e76:12f526e310e:-8000-00000000000000f7] Failure in WS-Policy Execution due to exception.
[2011-04-14T18:21:40.881+05:30] [OSBServer] [ERROR] [WSM-07501] [oracle.wsm.resources.enforcement] [tid: [ACTIVE].ExecuteThread: '22' for queue: 'weblogic.kernel.Default (self-tuning)'] [userId: <anonymous>] [ecid: 0000IxK4IQm1baURM6XBhA1DdcAP00001K,0] [APP: XBus Kernel] [dcid: 7e8d956afafee9bd:5c0a5e76:12f526e310e:-8000-00000000000000f7] [arg: security] [arg: agent.function.service] [arg: OSBKernel] [arg: null] [arg: CustomerContractEntityService] [arg: oracle/wss_username_token_service_policy] [arg: 1] [arg: {http://schemas.oracle.com/ws/2006/01/securitypolicy}wss-username-token] Failure in Oracle WSM Agent processRequest, category=security, function=agent.function.service, application=OSBKernel, composite=null, modelObj=CustomerContractEntityService, policy=oracle/wss_username_token_service_policy, policyVersion=1, assertionName={http://schemas.oracle.com/ws/2006/01/securitypolicy}wss-username-token.
sysout:
<ns1:Security soapenv:mustUnderstand="0" soapenv:actor="http://schemas.xmlsoap.org/soap/actor/next"
xmlns:ns1="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<ns1:UsernameToken Id="UsernameToken-2">
<ns1:Username>weblogic</ns1:Username>
<ns1:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">welcome1</ns1:Password>
</ns1:UsernameToken>
</ns1:Security>