I am new to web service programming. I have created one JAX-WS SOAP web service and deployed it locally. I am writing client in java to invoke the service. Basically, this service takes two integers and returns the sum of them. I have written the following JAX-WS client in java.
public class WebserviceClient {
public static void main(String[] args) throws Exception {
URL url = new URL
("http://localhost:9999/ws/additionService?wsdl");
QName qname = new QName("http://test/",
"AdditionServiceImplService");
Service service = Service.create(url, qname);
AdditionService additionService = service
.getPort(AdditionService.class);
System.out.println(additionService.add(1, 2));
The above code is working fine. But, in this code I need to create QName
by passing the targetNamespace and name of the service. I want to know whether constructing QName
is mandatory? Since, I am already passing the WSDL URL, no point creating QName
with the WSDL targetnamespace
string. Is there any alternative approach available?