This week's book giveaway is in the Server-Side JavaScript and NodeJS forum.
We're giving away four copies of Modern JavaScript for the Impatient and have Cay Horstmann on-line!
See this thread for details.
Win a copy of Modern JavaScript for the Impatient this week in the Server-Side JavaScript and NodeJS forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

JAX-WS Service invocation fails after service discovery with JAXR

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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:

javax.xml.ws.WebServiceException: Failed to access the WSDL at: http://xxx.yyy.zzz.com:7070/sampleGateway?WSDL. It failed with:
http://xxx.yyy.zzz.com:7070/sampleGateway?WSDL.
at com.sun.xml.ws.wsdl.parser.RuntimeWSDLParser.tryWithMex(RuntimeWSDLParser.java:160)
at com.sun.xml.ws.wsdl.parser.RuntimeWSDLParser.parse(RuntimeWSDLParser.java:142)
at com.sun.xml.ws.client.WSServiceDelegate.parseWSDL(WSServiceDelegate.java:240)
at com.sun.xml.ws.client.WSServiceDelegate.<init>(WSServiceDelegate.java:203)
at com.sun.xml.ws.client.WSServiceDelegate.<init>(WSServiceDelegate.java:160)
at com.sun.xml.ws.spi.ProviderImpl.createServiceDelegate(ProviderImpl.java:81)
at javax.xml.ws.Service.<init>(Service.java:56)
at test.artifacts.SampleService.<init>(SampleService.java:45)
at test.TestStaticSOAPMsgClient.testStaticInvocationClient(TestStaticSOAPMsgClient.java:28)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at junit.framework.TestCase.runTest(TestCase.java:154)
at junit.framework.TestCase.runBare(TestCase.java:127)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:478)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:344)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
Caused by: java.io.FileNotFoundException: http://xxx.yyy.zzz.com:7070/sampleGateway?WSDL
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1172)
at java.net.URL.openStream(URL.java:1007)
at com.sun.xml.ws.wsdl.parser.RuntimeWSDLParser.createReader(RuntimeWSDLParser.java:809)
at com.sun.xml.ws.wsdl.parser.RuntimeWSDLParser.resolveWSDL(RuntimeWSDLParser.java:259)
at com.sun.xml.ws.wsdl.parser.RuntimeWSDLParser.parse(RuntimeWSDLParser.java:127)
... 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){
connection.close();
}
}

//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
makeNewConnection();
Collection<String> wsdlAddresses = new ArrayList<String>();

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


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

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

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

//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;
}

@SuppressWarnings("unchecked")
private Collection getOrganizations(String organizationName) {

Collection<String> organizations = null;
try {

Collection<String> names = new ArrayList<String>();
names.add(organizationName);

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);


connFactory.setProperties(props);
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!!!

Regards,
 
ciro rezende
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey guys, anyone could help me with this issue?! Tks!
 
Consider Paul's rocket mass heater.
    Bookmark Topic Watch Topic
  • New Topic