How do I programmatically retrieve the service name and target namespace from a WSDL?
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.