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, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content