4

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?

Pshemo
  • 122,468
  • 25
  • 185
  • 269
Cris
  • 4,947
  • 6
  • 44
  • 73

1 Answers1

4

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.

Richard Sitze
  • 8,262
  • 3
  • 36
  • 48
  • I know the best practices...and how to reference a local wsdl rather then doing a round trip...(so to have a portable client) BUT why is needed ? – Cris Jul 29 '12 at 19:54
  • So my client already uses always produced artefacts , but the service require the wsdllocation in all contructors – Cris Jul 29 '12 at 19:56
  • I use java...will try to do some more experiments debug to see where is used – Cris Jul 29 '12 at 20:16
  • I was planning to get Metro code and to do the debug for this...but your explanation was very good.Thanks – Cris Aug 06 '12 at 17:48