Java Reference
In-Depth Information
<wsdl:binding name="StockQuoteHttpPost" type="tns:StockQuoteHttpPost">
<http:binding verb="POST"/>
<wsdl:operation name="GetQuote">
<http:operation location="/GetQuote"/>
<wsdl:input>
<mime:content type="application/x-www-form-urlencoded"/>
</wsdl:input>
<wsdl:output>
<mime:mimeXml part="Body"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="StockQuote">
<wsdl:port name="StockQuoteSoap" binding="tns:StockQuoteSoap">
<soap:address location=" http://www.webservicex.net/stockquote.asmx"/>
</wsdl:port>
<wsdl:port name="StockQuoteSoap12" binding="tns:StockQuoteSoap12">
<soap12:address location=" http://www.webservicex.net/stockquote.asmx"/>
</wsdl:port>
<wsdl:port name="StockQuoteHttpGet" binding="tns:StockQuoteHttpGet">
<http:address location=" http://www.webservicex.net/stockquote.asmx"/>
</wsdl:port>
<wsdl:port name="StockQuoteHttpPost" binding="tns:StockQuoteHttpPost">
<http:address location=" http://www.webservicex.net/stockquote.asmx"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
Certainly, this is a pretty hefty WSDL descriptor, but it does provide a good general overview on
how they are defined. First, the WSDL document lists a number of types that are used throughout
the service. Note the symbol and GetQuoteResult types. By looking at GetQuoteResult , there's no
doubt that this type provides a single string that you will need to parse. Next, the WSDL document
lists a number of messages to define the various messages that will be interchanged. These are used
in the definition of WSDL “ports.” For example, StockQuoteHttpPost indicates that it's possible
to interchange messages by an HTTP POST request to perform the GetQuote operation, and it will
use the GetQuoteHttpPostIn and GetQuoteHttpPostOut messages to do so (which is exactly what
you're doing when trying out the service using your browser, as seen earlier). Finally, to make ports
available for public access, they need to be “bound” to endpoints. You can see, for example, that a
binding named StockQuoteSoap has been defined for the GetQuote operation, which is bound to
the endpoint http://www.webserviceX.NET/GetQuote .
While WSDL files are certainly not meant for human reading, they do provide a means to easily
construct clients to consume the web services defined therein.
Here you will see how to use the wsimport tool provided by JAX‐WS. Contrary to what we've seen
thus far, you'll now need to have the Java Development Kit (JDK) installed. The tool itself is located
in the bin folder of your JDK installation.
Next, open a command prompt and navigate to the location of the wsimport executable (using
the cd command, as shown in Figure 10-10). Most likely, you will get the error message shown in
Figure 10-10.
Search WWH ::




Custom Search