After generating the artifacts for a Java WS client,
- why is the wsdllocation reference required?
- why is the WSDL needed at runtime?
I might see a reason for some validation, but shouldn't that be optional?
After generating the artifacts for a Java WS client,
I might see a reason for some validation, but shouldn't that be optional?
Summary: While from a design perspective the WSDL is not necessary for a web service client, the implementation effected by Sun for a web service client has a hard dependency on the WSDL. The apparent purpose is to generate some of the runtime dependencies dynamically.
First: it is considered a good practice to package your WSDL, and reference it, if you expect to produce a portable client.
Now, with that aside, the WSDL would not be required if the implementation generated all required runtime artifacts.
For Java, the wsimport tool generates some static artifacts (interfaces and possibly support code to meet performance targets) and leaves other elements to be dynamically created at runtime. From the start, we see the WSDL document takes a primary position in the Service constructor:
protected Service(java.net.URL wsdlDocumentLocation, QName serviceName)
delegate = Provider.provider().createServiceDelegate(wsdlDocumentLocation,
serviceName,
this.getClass());
}
The WSDL document is resolved to a source
data stream; if not provided, it defaults to (liberties taken to extract the core essence):
source = new StreamSource( ... webserviceclient.wsdlLocation() ... );
and digging deeper, to a WSServiceDelegate:
WSDLModelImpl wsdlmodelimpl = parseWSDL(url, source);
wsdlserviceimpl = wsdlmodelimpl.getService(serviceName);
It's creating at least some portion of the underlying service support dynamically.
The wsdlLocation is integral to the Java implementation.