How do I programmatically retrieve the service name and target namespace from a WSDL?

Solution Verified - Updated -

Issue

I want to retrive the target namespace and service name from a WSDL so I don't have to hard code them in my web service client. How can I do this?

For example, a simple call to a web service looks like this:

QName qname = new QName("http://ws.examples.jboss.com/", "HelloWorldImplService");
URL wsdl = new URL("http://localhost:8080/helloWorld/Simple?wsdl");

Service service = Service.create(wsdl, qname);
port = service.getPort(HelloWorldPortType.class);

Map<String,Object> context = ((BindingProvider)port).getRequestContext();

Notice the hard-coded values in QName. This is what is to be avoided.

Environment

  • JBoss Enterprise Application Platform (EAP) 5.x
  • JBossWS / JAX-WS

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase of over 48,000 articles and solutions.

Current Customers and Partners

Log in for full access

Log In
Close

Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.