Hi All,
We are working on SAP EP 7.31 and Adaptive Web Service Model.
The requirement is to develop a SSO application by passing portal user-id to external webservice which will grant the access to third party system. But to access that external webservice, authentication is required thru SOAP header. As shown in attached image, the parameters are <web:User> and <web:Pwd> that needs to be set for authentication.
I understand, I need to use interface 'IWDWSInvocationModifier' and method 'doModifyInvocation' to set the SOAP header. But not able to understand how to set the parameters programatically.
Please help, how do I need to authenticate using SOAP header in webdynpro java.
Thanks,
Amol.
Hi Daniel,
I have already gone thru the document, also I checked FAQ - Models - Adaptive Web Service - Web Dynpro Java - SCN Wiki and blog . Below is the code, I used for setting header. But not sure, if it is correct or not. I am waiting for my VPN connection, to test the below code. Once done, will get back with result.
public void doModifyInvocation(Object port) { // TODO Auto-generated method stub // Creating the SOAP Header node. DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance(); docBuilderFactory.setNamespaceAware(true); DocumentBuilder docBuilder; try { docBuilder = docBuilderFactory.newDocumentBuilder(); } catch (ParserConfigurationException e) { // TODO Log the Exception return; } Document soapDoc = docBuilder.newDocument(); Element soapEnv = soapDoc.createElementNS("http://schemas.xmlsoap.org/soap/envelop","soapenv:Envelope"); Element soapHeader = soapDoc.createElement("soapenv:Header"); Element webAuthHeader = soapDoc.createElement("web:AuthHeader"); Element webUser = soapDoc.createElement("web:User"); webUser.setTextContent("User_Code from FS"); Element webPwd = soapDoc.createElement("web:Pwd"); webPwd.setTextContent("Pwd_code from FS"); webAuthHeader.appendChild(webUser); webAuthHeader.appendChild(webPwd); soapHeader.appendChild(webAuthHeader); soapEnv.appendChild(soapHeader); // soapDoc.appendChild(soapEnv); SOAPHeaderInterface headerInterface = SOAPHeaderIFactory.getInterface(port); // Adds the output SOAP Header to the next proxy request. try { headerInterface.setOutputHeader(null, soapEnv); // headerInterface.setOutputHeader(null, soapHeader); } catch (MarshalException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
Thanks,
Amol.
hi anmol ,
go through this
http://help.sap.com/saphelp_nw73/helpdata/en/fa/9b078eacf24887a8af46c45d09a7fb/content.htm
here in 7.4 you have to create service groups and and configure a connection ,
i.e http://host:port/nwa/ --> the choose SOA -->system connections -- choose new then follow the above link which clearly expalins step wise and here you can define the username and password
Regards
Govardan
hi Amol,
you are looking into something like this:
MDL[ModelInstance] modelInstance = getModelInstance(MODEL_INSTANCE_KEY); Request_[Operation] request_Operation = new Request_[Operation](modelInstance); .... request_Operation.wdSetInvocationModifier( new IWDWSInvocationModifier() { public void doModifyInvocation(Object port) { SOAPHeaderInterface soapHeaderInterface = SOAPHeaderIFactory.getInterface(port); soapHeaderInterface.setOutputHeader([QName], [AuthHeader]); } public void doModifyAfterInvocation() { }
} );
I found something in SDN, this may help you too.. http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/900bbf94-a7a8-2910-e298-a651b4706c1e?QuickLink=index&overridelayout=true&12124692685423
Hope this info helps you somehow,
D.
Add a comment