I created a Jersey client program to consume a REST web service that return XML.
Client client = Client.create();
WebResource webResource = client.resource("http://xyz:abc/myRestservice/getval");
I use the webResource get method to store the return value in a string variable:
String s = webResource.get(String.class);
I get no errors. But variable "s" shows null as output:
System.out.println("- "+s);
Output:
-
Process exited with exit code 0.
When I test the same web service locally (using the JDeveloper IDE without a client program), it returns value.
update:
I found that the variable "s" was showing null because of an exception (explained below) in the web service program.
The web service program uses an opaque (OracleTypes.OPAQUE) variable to store the XMLTYPE value retrieved from a stored function in ORACLE database. The opaque variable is then assigned to a new XMLType using a cast. This somehow works while testing in JDeveloper IDE internal weblogic server. But it doesn't work when I deploy this web service in a remote weblogic server and try to consume using a client program. I get an exception - "oracle.sql.OPAQUE cannot be cast to oracle.xdb.XMLType".
Most probably due to some missing Jar in the remote weblogic server I guess, but not sure which jar.