HI Experts
Can anyone give me some guidance on more RM-CWS resource/guide link in OT?
I'm on tomcat and manage to find n install RM-CWS WAR file, but the question i'm facing is:
Do we need to reauthenticate while using RM functions? (some Java example if you have?)
Please comment if i need to provide more information.
Thank you.
Christopher
Hi Christopher,
Yes, you need to reauthenticate, using Authentication Token, e.g. for user/password token:
----------
private static final String ECM_API_NAMESPACE = "urn:api.ecm.opentext.com";
private static final String cwsServiceUrl = "http://localhost:8080/cws/services/Authentication?wsdl"; private static final String rmServiceUrl = "http://localhost:8080/cws-rm/services/RecordsManagement?wsdl";.....
Authentication_Service auth_service = new Authentication_Service( new URL(cwsServiceUrl), new QName("urn:Core.service.livelink.opentext.com", "Authentication")); //Authentication_Service auth_service = new Authentication_Service(); Authentication auth = auth_service.getBasicHttpBindingAuthentication();
String authToken = getAuthenticationToken(auth, username, password); OTAuthentication otAuth = new OTAuthentication();
otAuth.setAuthenticationToken( authToken ); RecordsManagement_Service recman_service = new RecordsManagement_Service(new URL(rmServiceUrl), new QName("urn:RecMan.service.livelink.opentext.com", "RecordsManagement")); //RecordsManagement_Service recman_service = new RecordsManagement_Service(); RecordsManagement recman = recman_service.getBasicHttpBindingRecordsManagement(); setSoapHeader( (WSBindingProvider) recman, otAuth );
public static String getAuthenticationToken(Authentication auth, String username, String password ) throws Exception { String token; //Authentication token = auth.authenticateUser(username, password);
return token; }
public static void setSoapHeader( WSBindingProvider bindingProvider, OTAuthentication otAuth ) throws Exception { List<Header> headers = new ArrayList<Header>(); SOAPMessage message = MessageFactory.newInstance().createMessage(); SOAPPart part = message.getSOAPPart(); SOAPEnvelope envelope = part.getEnvelope(); SOAPHeader header = envelope.getHeader();
headers.add( getOTAuthenticationHeader( header, otAuth ) );
bindingProvider.setOutboundHeaders( headers ); }
public static Header getOTAuthenticationHeader( SOAPHeader header, OTAuthentication otAuth ) throws Exception { SOAPHeaderElement otAuthElement; SOAPElement authTokenElement;
SOAPMessage soapMessage = MessageFactory.newInstance().createMessage(); SOAPPart soapPart = soapMessage.getSOAPPart(); SOAPEnvelope soapEnvelope = soapPart.getEnvelope(); otAuthElement = header.addHeaderElement(new QName( ECM_API_NAMESPACE, "OTAuthentication" )); otAuthElement.setPrefix( "" );
authTokenElement = otAuthElement.addChildElement(new QName( ECM_API_NAMESPACE, "AuthenticationToken" )); authTokenElement.setPrefix( "" );
authTokenElement.addTextNode( otAuth.getAuthenticationToken() );
return Headers.create( otAuthElement ); }---------------
Hope, this helps.
Regards,
Alex