Amal Mathlouthi

Greenhorn
+ Follow
since May 15, 2012
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Amal Mathlouthi

Jesper de Jong wrote:So, your program prints a SOAP message (in XML format) to the console? Can't you just select the text in the console and copy and paste it? Or modify your program so that it writes the SOAP message to a file instead of to the console?



I m doing now a copyy and paste but i m trying to find other solution better than doing copy past !!
12 years ago
I m runnig my code from the Eclipse tool (run as application)..... and I need a part of the console in which I receive in a soap envelope ( xml format) from a web service ... is that it is feasible..
thanks
12 years ago
I had a problem at the display and it was just a problem of eclipse I use the "Project -> clean" and it works !!! thank you
but do you know how can I redirect the contents of the console to an external file
thank you
12 years ago
Hi
I m working on a project in which I put to test displays and now when I want to change these messages or add others there is no change on console knowing that I run as java application
Can someone help me please
Thanks
12 years ago
now i progress it work in console but not on Web i don'n know why
Thank you veryyyy much i m veru gratful for your help
12 years ago

William Brogden wrote:So you are not getting authenticated for some reason.

Have you looked at the example code provided by the service? This page appears to link to examples.

Bill



Yes and I m using the same example !!!
12 years ago

William Brogden wrote:I didn't ask for an unreadable code dump, I asked:

what does your URL look like and what happens when you try the corrected code?



Bill



the Url which i work with is : http://search.isiknowledge.com/esti/wokmws/ws/WOKMWSAuthenticate and when i execute it give me this :
<soap:Envelope> <soap:Body> <soap:Fault> <faultcode>soap:Server</faultcode> <faultstring>Session ID cookie value cannot be null or empty string - It is required that the high level Web service client program participate in the session initialized by the server.</faultstring> <detail> <ns2:SessionException/> </detail> </soap:Fault> </soap:Body> </soap:Envelope>


and the correct URL must be launched is : url=http://search.isiknowledge.com/esti/wokmws/ws/WokSearch&sid=2WnbbEcMI76CnAHoI2K&folder=soap&product=&saved_folder=soap&call=WokSearch/search.xml&expanded=----++&xml=1&request=<soap:Envelope
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">;


===>>> et là j'ai réussi à mettre la cookie en entête et je poste ça comme requete
Address: http://search.isiknowledge.com/esti/wokmws/ws/WokSearchLite
Encoding: UTF-8
Content-Type: text/xml
Headers: {Accept=[*/*], Cookie=[SID=W6HEj3NB27j4kiFMo3C], SOAPAction=[""]}
Payload: <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns2:search xmlns:ns2="http://woksearchlite.cxf.wokmws.thomsonreuters.com"><queryParameters><databaseID>WOS</databaseID><editions><collection>WOS</collection><edition>SCI</edition></editions><editions><collection>WOS</collection><edition>SSCI</edition></editions><editions><collection>WOS</collection><edition>AHCI</edition></editions><editions><collection>WOS</collection><edition>IC</edition></editions><editions><collection>WOS</collection><edition>CCR</edition></editions><editions><collection>WOS</collection><edition>ISTP</edition></editions><editions><collection>WOS</collection><edition>SSCI</edition></editions><queryLanguage>en</queryLanguage><timeSpan><begin>1900-01-01</begin><end>2009-12-31</end></timeSpan><userQuery>AD=(NATL TAIWAN UNIV SAME CHILUNG)</userQuery></queryParameters><retrieveParameters><count>100</count><firstRecord>1</firstRecord></retrieveParameters></ns2:search></soap:Body></soap:Envelope>

===>>> Et je reçoit sa comme réponse :
ID: 2
Response-Code: 500
Encoding: UTF-8
Content-Type: text/xml;charset=UTF-8
Headers: {Content-Length=[352], content-type=[text/xml;charset=UTF-8], Date=[Thu, 21 Jun 2012 12:00:48 GMT], Server=[Apache-Coyote/1.1], X-Cnection=[close]}
Payload: <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><soap:Fault><faultcode>soap:Server</faultcode><faultstring>Not authorized to edition SSCI in collection WOS</faultstring><detail><ns2:InvalidInputException xmlns:ns2="http://woksearchlite.cxf.wokmws.thomsonreuters.com" /></detail></soap:Fault></soap:Body></soap:Envelope>


it must contain "sid" (cookie)
12 years ago

William Brogden wrote:After you have corrected your code to POST the SOAP message, what does your URL look like and what happens when you try the corrected code?

thank you for reply :i don't see exactly about which code you are talking but in my code java i put the cookie in this way :
this is my java code :

package clt;

import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Map;
import com.thomsonreuters.wokmws.cxf.auth.*;
import com.thomsonreuters.wokmws.cxf.woksearchlite.WokSearchLite;

import javax.servlet.ServletException;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.xml.namespace.QName;
import javax.xml.ws.BindingProvider;
import org.apache.cxf.endpoint.Client;
import org.apache.cxf.frontend.ClientProxy;
import org.apache.cxf.interceptor.LoggingInInterceptor;
import org.apache.cxf.interceptor.LoggingOutInterceptor;
import org.apache.cxf.transport.http.HTTPConduit;
import org.apache.cxf.transports.http.configuration.HTTPClientPolicy;
public class Authentificate {
private String log_;
public static String REMOTE_WSDL_URL =
"http://search.isiknowledge.com/esti/wokmws/ws/WOKMWSAuthenticate?wsdl";
public static URL LOCAL_WSDL_URL =
WOKMWSAuthenticateService.WSDL_LOCATION;
private static QName SERVICE_NAME = new QName(
"http://auth.cxf.wokmws.thomsonreuters.com",
"WOKMWSAuthenticateService"
);
WOKMWSAuthenticateService service;
WOKMWSAuthenticate port;
String session_identifier;
public String getSessionIdentifier() throws Exception
{
try {
/*
* comment start:
* now we have not an authentication account,
* so comment out the following to use IP authentication
*/
BindingProvider bp=(BindingProvider) port;
Map<String, Object> context = bp.getRequestContext();
/*
* comment start:
* the next line of code has already been done for this port in createPort()
* otherwise the SESSION_MAINTAIN_PROPERTY needs to be set to Boolean.TRUE
*/
context.put(
javax.xml.ws.BindingProvider.SESSION_MAINTAIN_PROPERTY,
Boolean.valueOf(true)
);
/* comment end */
//

/*
* comment start:
* make the call to the authenticate operation
*/
session_identifier = null;
session_identifier = port.authenticate();
} catch (Exception e) {
// Unexpected error while calling the authenticate operation.
// ¡- finish your exception handling,
// we are simply printing the stack trace and rethrowing the exception
e.printStackTrace();
throw e;
}
return session_identifier;
}
/**
* Close the session: make a call to the closeSession operation.
*
*


* The session identifier is sent as an HTTP cookie with name "SID".
* The value of the cookie is the
* session identifier. This cookie is already set in the requestContext
* for this binding provider/port
* within the {@link #setSessionCookie()} method.
*
*@throws Exception
*
*@see #setSessionCookie()
*/ public void closeSession() throws Exception {
try {
/*
* comment start:
* the next three lines of code have already been done for this port
* in createPort()
* otherwise the SESSION_MAINTAIN_PROPERTY needs to be set to Boolean.TRUE
*/
BindingProvider bp = (BindingProvider)port;
Map<String, Object> context = bp.getRequestContext();
context.put(
javax.xml.ws.BindingProvider.SESSION_MAINTAIN_PROPERTY,
Boolean.valueOf(true)
);
/* comment end */
/*
* comment start:
* Create the SID cookie
*/
Cookie cookie = new Cookie("SID", session_identifier);
Client client = ClientProxy.getClient(port);
HTTPConduit http = (HTTPConduit) client.getConduit();
HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy();
httpClientPolicy.setCookie(cookie.getName()+"="+cookie.getValue());
cookie.setValue(session_identifier);

/* comment end */
http.setClient(httpClientPolicy);
port.closeSession();
} catch( Exception e) {
// Unexpected error
// ¡- finish your exception handling,
// we are simply printing the stack trace and rethrowing the exception
e.printStackTrace();
throw e;
}
}
/**
* Put the session cookie into the request context for the binding provider/port
*
*


* Once this is done the session cookie will be set for all
* outgoing requests from this port.
*
*@throws Exception
*/
public void setSessionCookie() throws Exception {
try {
/*
* comment start:
* the next three lines of code have already been done for
* this port in createPort()
* otherwise the SESSION_MAINTAIN_PROPERTY needs to be set to Boolean.TRUE
*/

BindingProvider bp = (BindingProvider)port;
Map<String, Object> context = bp.getRequestContext();
context.put(
javax.xml.ws.BindingProvider.SESSION_MAINTAIN_PROPERTY,
Boolean.valueOf(true)
);

/* comment end */
/*
* comment start:
* create the cookie
*/

Cookie cookie = new Cookie("SID", session_identifier);
Client client = ClientProxy.getClient(port);
HTTPConduit http = (HTTPConduit) client.getConduit();
HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy();
httpClientPolicy.setCookie(cookie.getName() + "=" + cookie.getValue());
http.setClient(httpClientPolicy);
cookie.setValue(session_identifier);

} catch (Exception e) {
// Unexpected error while calling the authenticate service.
// ¡- finish your exception handling,
// we are simply printing the stack trace and rethrowing the exception
e.printStackTrace();
throw e;
}}
/*
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {

Cookie[] cookies = request.getCookies();

for(int i=0; i<cookies.length; i++) {
Cookie cookie = cookies[i];
String nomCookie = cookie.getName();
if (nomCookie.equals( "utilisateur"))
session_identifier = cookie.getValue();
}

response.setContentType("text/html");
PrintWriter out = response.getWriter();

out.println( "<BODY><P>Bonjour Mr" + session_identifier + "!</P></BODY></HTML>");

}

* comment start:
* * pattern of cookie is incorrect.*/



public void createPort( URL wsdlURL ) throws Exception {
// default to the WSDL used by WSDL2Java
if (wsdlURL == null) {
wsdlURL = WOKMWSAuthenticateService.WSDL_LOCATION;
}
try {
service = new WOKMWSAuthenticateService(
wsdlURL ,
SERVICE_NAME
);
port = service.getWOKMWSAuthenticatePort();
/*
* comment start:
* output HTTP message.
*/
Client client = ClientProxy.getClient(port);
client.getInInterceptors().add(new LoggingInInterceptor());
client.getOutInterceptors().add(new LoggingOutInterceptor());
/* comment end */
/*
* Must set the SESSION_MAINTAIN_PROPERTY to Boolean.TRUE
*/
BindingProvider bp = (BindingProvider)port;
Map<String, Object> context = bp.getRequestContext();
context.put(
javax.xml.ws.BindingProvider.SESSION_MAINTAIN_PROPERTY,
Boolean.valueOf(true)
);
} catch (Exception e) {
// Unexpected error while calling the authenticate service.
// ¡- finish your exception handling,
// we are simply printing the stack trace and rethrowing the exception
e.printStackTrace();
throw e;
}
}
public static void main(String[] args) throws Exception
{
/*
* comment start:
* Select a WSDL: Each WSDL may define the save service(s) but
* have a different service endpoint address
*
* We will default to the local one used by WSDL2Java
*/
// use the local WSDL used by WSDL2Java to generate the client code
URL wsdlURL = LOCAL_WSDL_URL;
// use the remote WSDL
wsdlURL = new URL(REMOTE_WSDL_URL);
// or pass in your own local WSDL:
if (args.length > 0) {
File wsdlFile = new File(args[0]);
try{
if (wsdlFile.exists()) {
wsdlURL = wsdlFile.toURI().toURL();
} else {
wsdlURL = new URL(args[0]);
}
} catch (MalformedURLException e) {
// Unexpected error
// ¡- finish your exception handling,
// we are simply printing the stack trace and rethrowing the exception
e.printStackTrace();
throw e;
}

Authentificate auth = new Authentificate();
// create the service and port
auth.createPort( wsdlURL );
/*
* call the authenticate operation:
* get the session identifier that all other operations need
* */
String identifier = auth.getSessionIdentifier();
System.out.println("Identifier cookie : " + identifier);
/*
* create the session cookie:
* make the session identifier available to all other Web service
* operations within
* this service port
*/
auth.setSessionCookie();
/*
* call the other operation in this Web service: close the session
*/
auth.closeSession();
System.exit(0);
}
}

}


package clt;

import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Map;
import com.thomsonreuters.wokmws.cxf.woksearchlite.*;

import javax.servlet.http.Cookie;
import javax.xml.namespace.QName;
import javax.xml.ws.BindingProvider;
import org.apache.cxf.endpoint.Client;
import org.apache.cxf.frontend.ClientProxy;
import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
import org.apache.cxf.interceptor.LoggingInInterceptor;
import org.apache.cxf.interceptor.LoggingOutInterceptor;
import org.apache.cxf.transport.http.HTTPConduit;
import org.apache.cxf.transports.http.configuration.HTTPClientPolicy;


public class Interrog {
/*
* comment start:
* add constant WSDL_URL.
*/
private String log_;
public static String SERVICE_ENDPOINT_URL
= "http://search.isiknowledge.com/esti/wokmws/ws/WokSearchLite";
public static String REMOTE_WSDL_URL = SERVICE_ENDPOINT_URL + "?wsdl";
public static URL LOCAL_WSDL_URL = WokSearchLiteService.WSDL_LOCATION;
/* comment end */
private static final QName SERVICE_NAME
= new QName(
"http://woksearchlite.cxf.wokmws.thomsonreuters.com",
"WokSearchLiteService"
);
private Interrog()
{
}
/**
* Create the port for WokSearchLite Web service
* using the WokSearchLiteService class.
*
*@param wsdlURL the url of the WSDL
*
*@return the port (e.g. instance of the WokSearchLite interface) for the
* WokSearchLite Web service
*
*@throws Exception
*/
public static WokSearchLite createPort( URL wsdlURL ) throws Exception {
try {
WokSearchLiteService ss = new WokSearchLiteService(wsdlURL, SERVICE_NAME);
WokSearchLite port = ss.getWokSearchLitePort();
return port;
} catch( Exception e) {
// do error handling. Here we just print stack trace and rethrow execption
e.printStackTrace();
throw e;
}
}
/**
* Create the port for WokSearchLite Web service using a JAX-WS factory class and
* the
* service endpoint url.
*
*


* Also, set the logging interceptors
*
*@return the port (e.g. instance of the WokSearchLite interface) for the
* WokSearchLite Web service
*
*@throws Exception
*/

public static WokSearchLite createPortUsingFactory( ) throws Exception {
try {
/*
* comment start:
* CXF Factory for creating JAX-WS Proxies. This class provides access to
* internal
* properties used to setup proxies. Using it provides more control than the
* standard JAX-WS APIs.
///*/
JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
factory.getInInterceptors().add(new LoggingInInterceptor());
factory.getOutInterceptors().add(new LoggingOutInterceptor());
factory.setServiceClass(WokSearchLite.class);
factory.setAddress( SERVICE_ENDPOINT_URL );
WokSearchLite port = (WokSearchLite) factory.create();
return port;
} catch( Exception e) {
// do error handling. Here we just print stack trace and rethrow execption
e.printStackTrace();
throw e;
}
}

public static void setSessionCookie( WokSearchLite port, String sid )
throws Exception {
Client client = ClientProxy.getClient(port);
/*
* comment start:
* * output HTTP message.
*
* if you are using createPort() method then uncomment the following two
* lines.
* if you are using createPortUsingFactory() method then leave these
* two lines commented out.
*/
client.getInInterceptors().add(new LoggingInInterceptor());
client.getOutInterceptors().add(new LoggingOutInterceptor());
/* comment end */
BindingProvider bindingProvider = (BindingProvider)port;
Map<String, Object> requestContext = bindingProvider.getRequestContext();
requestContext.put(BindingProvider.SESSION_MAINTAIN_PROPERTY, true);
Cookie cookie = new Cookie("SID", sid);
HTTPConduit http = (HTTPConduit) client.getConduit();
HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy();
http.setClient(httpClientPolicy);
}

public static void main(String args[]) throws Exception {
/*
* comment start:
* Select a WSDL: Each WSDL may define the save service(s) but
* have a different service endpoint address
*
* We will default to the local one used by WSDL2Java
*/
// use the local WSDL used by WSDL2Java to generate the client code
URL wsdlURL = LOCAL_WSDL_URL;
// use the remote WSDL
wsdlURL = new URL(REMOTE_WSDL_URL);


// or pass in your own local WSDL:
if (args.length > 0) {
File wsdlFile = new File(args[0]);
try {
if (wsdlFile.exists()) {
wsdlURL = wsdlFile.toURI().toURL();
} else {
wsdlURL = new URL(args[0]);
}
} catch (MalformedURLException e) {
// do error handling. Here we just print stack trace and rethrow
// execption
e.printStackTrace();
throw e;
}
}
/* comment end */
/*
* comment start:
* use one of the following two methods to create the Web service port
*/
//WokSearchLite port = createPort( wsdlURL );
WokSearchLite port = createPortUsingFactory();
/*
* comment start:
* Get the session identifier using the Authentication client
*/
Authentificate auth = new Authentificate();
// use remote WSDL
auth.createPort( new URL( Authentificate.REMOTE_WSDL_URL ) );
// use local WSDL
auth.createPort( Authentificate.LOCAL_WSDL_URL );
String sid = auth.getSessionIdentifier();
auth.setSessionCookie();
/* end comment */
/*
* Set up the request context properly, including setting the SID cookie
* This setup is required for all operations to work.
*/
setSessionCookie(port, sid);
System.out.println("Invoking search...");
com.thomsonreuters.wokmws.cxf.woksearchlite.QueryParameters _search_queryParameters = new QueryParameters();
com.thomsonreuters.wokmws.cxf.woksearchlite.RetrieveParameters _search_retrieveParameters = new RetrieveParameters();
/*
* comment start:
* initialize QueryParameters & RetrieveParameters
*/

_search_queryParameters.setDatabaseID("WOS");
EditionDesc desc_sci = new EditionDesc();
desc_sci.setCollection("WOS");
desc_sci.setEdition("SCI");
EditionDesc desc_ssci = new EditionDesc();
desc_ssci.setCollection("WOS");
desc_ssci.setEdition("SSCI");
EditionDesc desc_ahci = new EditionDesc();
desc_ahci.setCollection("WOS");
desc_ahci.setEdition("AHCI");
EditionDesc desc_ic = new EditionDesc();
desc_ic.setCollection("WOS");
desc_ic.setEdition("IC");
EditionDesc desc_ccr = new EditionDesc();
desc_ccr.setCollection("WOS");
desc_ccr.setEdition("CCR");
EditionDesc desc_istp = new EditionDesc();
desc_istp.setCollection("WOS");
desc_istp.setEdition("ISTP");
EditionDesc desc_isshp = new EditionDesc();
desc_isshp.setCollection("WOS");
desc_isshp.setEdition("ISSHP");
_search_queryParameters.getEditions().add(desc_sci);
_search_queryParameters.getEditions().add(desc_ssci);
_search_queryParameters.getEditions().add(desc_ahci);
_search_queryParameters.getEditions().add(desc_ic);
_search_queryParameters.getEditions().add(desc_ccr);
_search_queryParameters.getEditions().add(desc_istp);
_search_queryParameters.getEditions().add(desc_ssci);
_search_queryParameters.setQueryLanguage("en");
_search_queryParameters.setUserQuery("AD=(NATL TAIWAN UNIV SAME CHILUNG)");
TimeSpan timeSpan = new TimeSpan();
timeSpan.setBegin("1900-01-01");
timeSpan.setEnd("2009-12-31");
_search_queryParameters.setTimeSpan(timeSpan);
_search_retrieveParameters.setFirstRecord(1);
_search_retrieveParameters.setCount(100);
/* comment end */
try {
com.thomsonreuters.wokmws.cxf.woksearchlite.SearchResults
_search__return = port.search
(
_search_queryParameters,
_search_retrieveParameters
);
System.out.println(
"search.result.getRecordsFound()=" + _search__return.getRecordsFound() );
} catch (Exception e) {
e.printStackTrace();
}
auth.closeSession();
System.exit(0);
}

}


==> the first code is for authentification and close session (which need also an ID) and the second for interrogation

really i m loosing my mind thank you for help

12 years ago
thank you for your response ...
so how can i add this url with the session id because i m trying to retirve data from a data base and it need an ID on a cookie .... can you help me :/
thank you veru much for your help
12 years ago
hi

Please I try to retrieve data from web services (soap) and must pass an ID in cookie http header I tried with java code (eclipse) but I can not I tried also with other tools tjrs but its not happening ...
I am beginner I really need a helping hand to find the error and the tool to be used

Thank you in advance

The XML that I want to apply is the following:

==> My prob is in the URL: I can not add it and how to add the "sid"on url (sid: is the username (cookie))

///////////////////////////////////////////////////////////////

url=http://search.isiknowledge.com/esti/wokmws/ws/WokSearch&sid=2WnbbEcMI76CnAHoI2K&folder=soap&product=&saved_folder=soap&call=WokSearch/search.xml&expanded=----++&xml=1&request=<soap:Envelope

xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">

<soap:Body>

<woksearch:search

xmlns:woksearch="http://woksearch.cxf.wokmws.thomsonreuters.com">

<!-- this request has the minimum required elements -->

<queryParameters>

<databaseID>WOS</databaseID>

<editions>

<collection>WOS</collection>

<edition>SCI</edition>

</editions>

<userQuery>AU=Arce, G*</userQuery>

<queryLanguage>en</queryLanguage>

</queryParameters>

<retrieveParameters>

<!-- 0 < firstRecord <= recordsSearched -->

<firstRecord>1</firstRecord>

<!-- count = 0 (summary only), 1 <= count <= 100 returns records -->

<count>5</count>

</retrieveParameters>

</woksearch:search>

</soap:Body>

</soap:Envelope>
12 years ago
Hi .......
please i m trying to interrogate a data base Web of knowladge but it need an identifier i get the ID from the first WSDl but i can't connect to get data
please any body can help me

thanks

WSDlL1 : search.isiknowledge.com/esti/wokmws/ws/WOKMWSAuthenticate?wsdl

WSDlL 2 search.isiknowledge.com/esti/wokmws/ws/WokSearchLite?wsdl
i tried with Eclipse Indigo et Soapui but it doesn't work


12 years ago

William P O'Sullivan wrote:download and install SOAPUI for ANY web services project!

After you clean up and format your code, I can help you.

What is the public WSDL location?

WP



the public WSDL iare:
http://search.isiknowledge.com/esti/wokmws/ws/WOKMWSAuthenticate?wsdl // pour authentification
http://search.isiknowledge.com/esti/wokmws/ws/WokSearchLite?wsdl // for request (pour établir les requêtes)

Thanks
12 years ago
Hi
Please I really need help, I need to query a remote database which is the Web of knowledge via Web services to have indetifiants in return code first but it doesn't work .... there are some constraint :

- Web of Knowledge Web Services are Web Services Definition Language (WSDL) based services using Simple Object Access Protocol (SOAP) messages using the Hypertext Transfer Protocol (HTTP). Web of Knowledge Web Services conform to the JSR224: Java API for XML-based Web Services 2.0 (JAX-WS) specification
- Web of Knowledge Web Services, version L1.02, consist of two JAX-WS Web services
 WOKMWSAuthenticate
 WokSearchLite

- I have an example and they they said that : The following sample client programs assume that you have downloaded the WSDL file for each service and have run the WSDL2Java found in the Apache CXF runtime to create the client side code for each service in the following Java packages:
com.thomsonreuters.wokmws.cxf.auth
com.thomsonreuters.wokmws.cxf.woksearchlite

P.S : I use as tools :
* Eclipse Indigo
* Apache Tomcat 7.0
* Apache CXF
* Environement : Ubuntu 10.04 LTS

===> I think that this "com.thomsonreuters.wokmws" are two library but i couldn't found it anywhere
here is the code:

* import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Map;
import com.thomsonreuters.wokmws.cxf.auth.*;
import javax.servlet.http.Cookie;
import javax.xml.namespace.QName;
import javax.xml.ws.BindingProvider;
import org.apache.cxf.endpoint.Client;
import org.apache.cxf.frontend.ClientProxy;
import org.apache.cxf.interceptor.LoggingInInterceptor;
import org.apache.cxf.interceptor.LoggingOutInterceptor;
import org.apache.cxf.transport.http.HTTPConduit;
import org.apache.cxf.transports.http.configuration.HTTPClientPolicy;
public class AuthenticationClient {
public static String REMOTE_WSDL_URL =
"http://search.isiknowledge.com/esti/wokmws/ws/WOKMWSAuthenticate?wsdl";
public static URL LOCAL_WSDL_URL =
WOKMWSAuthenticateService.WSDL_LOCATION;
private static QName SERVICE_NAME = new QName(
"http://auth.cxf.wokmws.thomsonreuters.com",
"WOKMWSAuthenticateService"
);
WOKMWSAuthenticateService service;
WOKMWSAuthenticate port;
String session_identifier;
/**
* Make a call to the authenticate operation to get a session identifier.
* Return the session identifier
* and also store it in the member variable (session_identifier).
*
*<p/>
* The SESSION_MAINTAIN_PROPERTY of the requestContext of the binding
* provider/port must set to Boolean.TRUE in order to send, receive and store
* cookies. This only needs to be done once for
* the lifetime of the binding provider/port.
*
*@return the session identifier
* @throws Exception
*/ public String getSessionIdentifier() throws Exception
{
try {
/*
* comment start:
* now we have not an authentication account,
* so comment out the following to use IP authentication
*/
//BindingProvider bp = (BindingProvider)port;
//Map<String, Object> context = bp.getRequestContext();
/*
* comment start:
* the next line of code has already been done for this port in createPort()
* otherwise the SESSION_MAINTAIN_PROPERTY needs to be set to Boolean.TRUE
*/
//context.put(
// javax.xml.ws.BindingProvider.SESSION_MAINTAIN_PROPERTY,
// Boolean.valueOf(true)
// );
/* comment end */
//
// String username = "training";
// String password = "lapis";
// context.put(javax.xml.ws.BindingProvider.USERNAME_PROPERTY, username);
// context.put(javax.xml.ws.BindingProvider.PASSWORD_PROPERTY, password);
/*
* comment start:
* make the call to the authenticate operation
*/
session_identifier = null;
session_identifier = port.authenticate();
} catch (Exception e) {
// Unexpected error while calling the authenticate operation.
// ¡- finish your exception handling,
// we are simply printing the stack trace and rethrowing the exception
e.printStackTrace();
throw e;
}
return session_identifier;
}
/**
* Close the session: make a call to the closeSession operation.
*
*<p/>
* The session identifier is sent as an HTTP cookie with name "SID".
* The value of the cookie is the
* session identifier. This cookie is already set in the requestContext
* for this binding provider/port
* within the {@link #setSessionCookie()} method.
*
*@throws Exception
*
*@see #setSessionCookie()
*/ public void closeSession() throws Exception {
try {
/*
* comment start:
* the next three lines of code have already been done for this port
* in createPort()
* otherwise the SESSION_MAINTAIN_PROPERTY needs to be set to Boolean.TRUE
*/
//BindingProvider bp = (BindingProvider)port;
//Map<String, Object> context = bp.getRequestContext();
//context.put(
// javax.xml.ws.BindingProvider.SESSION_MAINTAIN_PROPERTY,
// Boolean.valueOf(true)
// );
/* comment end */
/*
* comment start:
* Create the SID cookie
*/
Cookie cookie = new Cookie("SID", session_identifier);
Client client = ClientProxy.getClient(port);
HTTPConduit http = (HTTPConduit) client.getConduit();
HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy();
httpClientPolicy.setCookie(cookie.getName()+"="+cookie.getValue());
/* comment end */
http.setClient(httpClientPolicy);
closeSession();
port. } catch( Exception e) {
// Unexpected error
// ¡- finish your exception handling,
// we are simply printing the stack trace and rethrowing the exception
e.printStackTrace();
throw e;
}
}
/**
* Put the session cookie into the request context for the binding provider/port
*
*<p/>
* Once this is done the session cookie will be set for all
* outgoing requests from this port.
*
*@throws Exception
*/
public void setSessionCookie() throws Exception {
try {
/*
* comment start:
* the next three lines of code have already been done for
* this port in createPort()
* otherwise the SESSION_MAINTAIN_PROPERTY needs to be set to Boolean.TRUE
*/
//BindingProvider bp = (BindingProvider)port;
//Map<String, Object> context = bp.getRequestContext();
//context.put(
// javax.xml.ws.BindingProvider.SESSION_MAINTAIN_PROPERTY,
// Boolean.valueOf(true)
// );
/* comment end */
/*
* comment start:
* create the cookie
*/
Client client = ClientProxy.getClient(port);
HTTPConduit http = (HTTPConduit) client.getConduit();
HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy();
/* comment end */
/*
* comment start:
* pattern of cookie is incorrect.
*/
Cookie cookie = new Cookie("SID", session_identifier);
httpClientPolicy.setCookie(cookie.getName()+"="+cookie.getValue());
http.setClient(httpClientPolicy);
} catch (Exception e) {
// Unexpected error while calling the authenticate service.
// ¡- finish your exception handling,
// we are simply printing the stack trace and rethrowing the exception
e.printStackTrace();
throw e;
}
}
public void createPort( URL wsdlURL ) throws Exception {
// default to the WSDL used by WSDL2Java
if (wsdlURL == null) {
wsdlURL = WOKMWSAuthenticateService.WSDL_LOCATION;
}
try {
service = new WOKMWSAuthenticateService(
wsdlURL ,
SERVICE_NAME
);
port = service.getWOKMWSAuthenticatePort();
/*
* comment start:
* output HTTP message.
*/
Client client = ClientProxy.getClient(port);
client.getInInterceptors().add(new LoggingInInterceptor());
client.getOutInterceptors().add(new LoggingOutInterceptor());
/* comment end */
/*
* Must set the SESSION_MAINTAIN_PROPERTY to Boolean.TRUE
*/
BindingProvider bp = (BindingProvider)port;
Map<String, Object> context = bp.getRequestContext();
context.put(
javax.xml.ws.BindingProvider.SESSION_MAINTAIN_PROPERTY,
Boolean.valueOf(true)
);
} catch (Exception e) {
// Unexpected error while calling the authenticate service.
// ¡- finish your exception handling,
// we are simply printing the stack trace and rethrowing the exception
e.printStackTrace();
throw e;
}
}
public static void main(String[] args) throws Exception
{
/*
* comment start:
* Select a WSDL: Each WSDL may define the save service(s) but
* have a different service endpoint address
*
* We will default to the local one used by WSDL2Java
*/
// use the local WSDL used by WSDL2Java to generate the client code
URL wsdlURL = LOCAL_WSDL_URL;
// use the remote WSDL
//wsdlURL = new URL(REMOTE_WSDL_URL);
// or pass in your own local WSDL:
if (args.length > 0) {
File wsdlFile = new File(args[0]);
try{
if (wsdlFile.exists()) {
wsdlURL = wsdlFile.toURI().toURL();
} else {
wsdlURL = new URL(args[0]);
}
} catch (MalformedURLException e) {
// Unexpected error
// ¡- finish your exception handling,
// we are simply printing the stack trace and rethrowing the exception
e.printStackTrace();
throw e;
}
}
AuthenticationClient auth = new AuthenticationClient();
// create the service and port
auth.createPort( wsdlURL );
/*
* call the authenticate operation:
* get the session identifier that all other operations need
*/
String identifier = auth.getSessionIdentifier();
System.out.println("Identifier: " + identifier);
/*
* create the session cookie:
* make the session identifier available to all other Web service
* operations within
* this service port
*/
auth.setSessionCookie();
/*
* call the other operation in this Web service: close the session
*/
auth.closeSession();
System.exit(0);
}
}



==> realy I'll be very grateful if you can help me, I'm beginner and hope that i can succeed in this project...
Thank you
13 years ago