users@jax-rpc.java.net

Dynamic code from a WSDL

From: Pierre Maris <pierre.maris_at_CGEY.COM>
Date: Thu, 31 Oct 2002 13:12:33 +0100

I work on a small piece of code for calling a WebService with only the WSDL file.
I get the different needed parameters by parsing the WSDL document.

URL url = new URL(url_wsdl);
Document doc = null;
DOMParser parser = new DOMParser();
parser.parse(url_wsdl);
doc = parser.getDocument();
Element root = doc.getDocumentElement();
String namespace = root.getAttribute("targetNamespace");
Element s = (Element) root.getElementsByTagName("service").item(0);
String serviceName = s.getAttribute("name");
Element p = (Element) s.getElementsByTagName("port").item(0); //assumes there is only one port
String namePort = p.getAttribute("name");


System.out.println("namespace="+namespace);
System.out.println("serviceName="+serviceName);
System.out.println("namePort="+namePort);

ServiceFactory factory = ServiceFactory.newInstance();
Service service = factory.createService(url,new QName(namespace, serviceName));
QName port = new QName(namespace, namePort);


Call[] calls = service.getCalls(port);
Call c0 = calls[0]; //assumes that I need the first operation
Object[] params = new Object[1];
params[0] = "LFLY";
System.out.println((String)c0.invoke( params));

....





With the hello (http://localhost/hello-jaxrpc/hello?WSDL) and some other WSDL and services, it works fine.

But with a CapeConnect service, for example (http://live.capescience.com/wsdl/AirportWeather.wsdl), I get this message
Cannot work out call uri to determine application name from SOAPAction=[] method name=[getHumidity] namespace=[http://www.capeclear.com/AirportWeather.wsdl]

In the WSDL coming from CapeConnect, I see that a SoapAction is defined. When I try to get the SoapAction_URI from c0; I got 'null'?

Why?

Regards