17.10.2015 Views

Getting Started with IBM Data Studio for DB2

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 10 – Developing data web services 311<br />

4. Change the SQL statement that represents theGetBestSellingProductsByMonth<br />

operation to allow a user to provide the month name instead of the month number.<br />

Hint: You can use the following expression to find the month name <strong>for</strong> the<br />

GOSALES.INVENTORY_LEVELS.INVENTORY_MONTH column:<br />

MONTHNAME('2009-' || TRIM(CHAR(INVENTORY_MONTH)) || '-01-<br />

00.00.00')<br />

5. Check out the behavior <strong>for</strong> binary data types. Create a new web service operation<br />

calledcheckBinary <strong>with</strong> the following statement:<br />

SELECT BLOB(CAST(:input AS VARCHAR(255)) FROM SYS<strong>IBM</strong>.SYSDUMMY1<br />

Deploy the web service <strong>with</strong> the new operation. Run the operation by providing any<br />

string value as input. Observe the result. Try to find out the XML data type and explain<br />

why binary data is represented in this <strong>for</strong>m. Hint: You can find the XML data type by<br />

examining the XML schema section in the WSDL document of the web service.<br />

10.11 Summary<br />

In this chapter, you’ve learned about the architecture of data web services, which provides<br />

the ability to wrap web services around business logic that is provided by SQL statements,<br />

XQuery statements, or stored procedures. The services can be bound to either SOAP or<br />

REST style bindings, providing the flexibility <strong>for</strong> a variety of clients to start and consume the<br />

services. This chapter walked you through the process of creating a data web service that<br />

includes two stored procedures and two SQL statements and binding them to both SOAP<br />

and simple HTTP protocols. The SOAP binding can easily be tested using the Web<br />

Services Explorer. For in<strong>for</strong>mation about testing other bindings, see Appendix E.<br />

10.12 Review questions<br />

1. What are the three bindings supported <strong>for</strong> testing by the <strong>Data</strong> <strong>Studio</strong> Web Services<br />

Explorer?<br />

2. What does it mean when the data web service name in the <strong>Data</strong> Project Explorer has<br />

an asterisk by it?<br />

3. To see the SOAP request and response messages, which view do you need to open<br />

from the Web Services Explorer?<br />

4. As a best practice, is it better to use named parameter markers or question mark <strong>for</strong><br />

the SQL used in data web services?<br />

5. The approach of creating a data web service based on existing database logic is called<br />

________________ development.<br />

6. You create a new data web service in:<br />

A. A data design project<br />

B. A data development project

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!