File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Web Services and the fly likes JAX-WS Service invocation fails after service discovery with JAXR Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Web Services
Bookmark "JAX-WS Service invocation fails after service discovery with JAXR" Watch "JAX-WS Service invocation fails after service discovery with JAXR" New topic

JAX-WS Service invocation fails after service discovery with JAXR

ciro rezende

Joined: Aug 17, 2007
Posts: 2
Hi folks!

I�m experiencing a problem that I tried fix for a bir amount of time, but I can't make it work.

Here�s the problem:

I developed a JAXR Client to perform service discovery against a Service Registry (Weblogic Aqualogic Service Registry - ALSR).
Then I make a JAX WS client that gets every WSDL of this list and invokes it.

The work completes well in the service discovery. I get the WSDL list of the available services.

But when I try to invoke the service using JAX-WS (port or dispatch) it fails with the message: Failed to access the WSDL at: It failed with:
at test.artifacts.SampleService.<init>(
at test.TestStaticSOAPMsgClient.testStaticInvocationClient(
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(
at sun.reflect.DelegatingMethodAccessorImpl.invoke(
at java.lang.reflect.Method.invoke(
at junit.framework.TestCase.runTest(
at junit.framework.TestCase.runBare(
at junit.framework.TestResult$1.protect(
at junit.framework.TestResult.runProtected(
at junit.framework.TestSuite.runTest(
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(
Caused by:
... 22 more

I thought it could be an error in the WSDL of the service, but it's not, cos' I�m able to consume the web service if I perform the invocation without performing the JAXRClient service discover.

Here�s the code of the test case that uses the JAXRClient and then tries the web service invocation:

public void testStaticInvocationClient() throws JAXRException, MalformedURLException{

final QName SERVICE_QNAME = new QName("http://com/acme/soa", "SampleService");
URL baseUrl = SampleService.class.getResource(".");

Collection<String> wsdlAddresses = new JAXRClient().findServicesWsdlURIs("sample%");
for (String wsdlAddress : wsdlAddresses) {
System.err.println("-> " + wsdlAddress);
SampleService service = new SampleService(new URL(baseUrl, wsdlAddress), SERVICE_QNAME);
Sample servicePort = service.getSampleSoapPort();

System.err.println("Starting Static Service Invocation...");

/*call "execute" method in the sevice port to invoke remote web service
*as long as we have a Handler registered in JAX-WS runtime,
*the 'handleMessage' method in that handler will web called before the
*remote invocation occurs.

String returnedString = servicePort.execute("Test Message");
//output results from server
System.err.println("Response from srv: " + returnedString);


System.err.println("test finished!");


Here�s the code for the JAXRClient client (hope this can be useful to someone too... ;-) )

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.Properties;

import javax.xml.registry.BulkResponse;
import javax.xml.registry.BusinessLifeCycleManager;
import javax.xml.registry.BusinessQueryManager;
import javax.xml.registry.Connection;
import javax.xml.registry.ConnectionFactory;
import javax.xml.registry.JAXRException;
import javax.xml.registry.RegistryService;
import javax.xml.registry.infomodel.Organization;
import javax.xml.registry.infomodel.Service;
import javax.xml.registry.infomodel.ServiceBinding;

import junit.framework.TestCase;

public class JAXRClient extends TestCase {

String httpProxyHost = "10.x.y.z";
String httpProxyPort = "7070";
String httpsProxyHost = "10.x.y.z";
String httpsProxyPort = "7072";

Connection connection;
ConnectionFactory connFactory;
BusinessQueryManager businessQueryManager;
BusinessLifeCycleManager businessLifeCycleManager;

* Test Case for retrieving wsdl location of services given a keyword
* this is achieved by using JAXR API for communicating with an UDDI Service Registry
* Recovered wsdl locations are printed to console

public void testServiceDiscover() throws Exception{

System.err.println("Starting Service Discovery in UDDI Registry...");

//defines search keyword
String queryString = "sample%";

//starts service lookup
Collection<String> wsdlAddresses = findServicesWsdlURIs(queryString);

//output results to console
System.err.println("Results of service discovery in registry for the keyword(s) '" + queryString + "':\n" );
for (String wsdlAddress : wsdlAddresses) {
System.err.println("-> " + wsdlAddress);
if(connection != null){

//performs service discovery given a keyword and returns WSDL locations of these services
public Collection<String> findServicesWsdlURIs(String serviceName) throws JAXRException {

//sets needed connection factory & business references
Collection<String> wsdlAddresses = new ArrayList<String>();

//retrieves Organizations from UDDI
Collection collection = getOrganizations("%"+ serviceName +"%");

Iterator iter = collection.iterator();
while (iter.hasNext()){
Organization org = (Organization);

//retrieves Services of each Organization
Iterator it = org.getServices().iterator();
while (it.hasNext()){
Service service = (Service);

//gets ServiceBindings for each retrieved Service
Iterator iterator = service.getServiceBindings().iterator();
while (iterator.hasNext()) {
ServiceBinding binding = (ServiceBinding);

//retrieves Access URI from Binding & appends wsdl suffix
//(binding does not provide wsdl suffix information)
//adds retrieved uri to return list
wsdlAddresses.add( binding.getAccessURI() + "?WSDL" );


//returns addresses found
return wsdlAddresses;

private Collection getOrganizations(String organizationName) {

Collection<String> organizations = null;
try {

Collection<String> names = new ArrayList<String>();

BulkResponse response = businessQueryManager.findOrganizations(null, names, null, null, null, null);
organizations = response.getCollection();
} catch (JAXRException e) {
organizations = new ArrayList<String>();
return organizations;

//creates new connection
private void makeNewConnection() throws JAXRException {

this.connFactory = ConnectionFactory.newInstance();

Properties props = new Properties();
props.setProperty("javax.xml.registry.queryManagerURL", "http://"+httpProxyHost+":"+httpProxyPort+"/registry/uddi/inquiry");
props.setProperty("javax.xml.registry.lifeCycleManagerURL", "http://"+httpProxyHost+":"+httpProxyPort+"/registry/uddi/inquiry");

props.setProperty("com.sun.xml.registry.http.proxyHost", httpProxyHost);
props.setProperty("com.sun.xml.registry.http.proxyPort", httpProxyPort);
props.setProperty("com.sun.xml.registry.https.proxyHost", httpsProxyHost);
props.setProperty("com.sun.xml.registry.https.proxyPort", httpsProxyPort);

connection = connFactory.createConnection();

RegistryService service = connection.getRegistryService();
businessQueryManager = service.getBusinessQueryManager();
businessLifeCycleManager = service.getBusinessLifeCycleManager();



It�s very strange: I can make the things work each one isolated, but together, looks like the JAXRClient "locks" the JAX-WS (or JAXB) runtime, and makes impossible to use it to invoke the service.

I�d appreciate any help to solve this problem!!!

Thanks in advance!!!

ciro rezende

Joined: Aug 17, 2007
Posts: 2
Hey guys, anyone could help me with this issue?! Tks!
I agree. Here's the link:
subject: JAX-WS Service invocation fails after service discovery with JAXR
It's not a secret anymore!