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.

370 <strong>Getting</strong> <strong>Started</strong> <strong>with</strong> <strong>IBM</strong> <strong>Data</strong> <strong>Studio</strong> <strong>for</strong> <strong>DB2</strong><br />

To start theRankEmployee operation of theSimpleService example, your endpoint<br />

URL looks like this:<br />

http://server:8080/WebServicesSimpleService/rest/SimpleService/Rank<br />

Employee<br />

Note:<br />

The REST endpoint URL is used <strong>for</strong> all HTTP RPC bindings:<br />

- HTTP POST (XML)<br />

- HTTP POST (application/x-www-<strong>for</strong>m-urlencoded)<br />

- HTTP POST (JSON)<br />

- HTTP GET<br />

You can enable or disable all HTTP Bindings <strong>for</strong> a web service by selecting or deselecting<br />

the REST (web access) option in the Deploy Web Service window described in Chapter<br />

10.<br />

The cURL command to send the request to the web service should look like this:<br />

curl.exe -d @ SimpleService.RankEmployee.default.xml<br />

-H "Content-Type:text/xml;charset=utf-8"<br />

-v<br />

http://localhost:8080/WebServicesSimpleService/rest/SimpleService/RankEmpl<br />

oyee<br />

E.1.4 HTTP POST (application/x-www-<strong>for</strong>m-urlencoded) Binding<br />

This binding can be used <strong>with</strong> HTML <strong>for</strong>ms using the POST action. In this case, the<br />

parameters are sent as key/value pairs, where each pair is separated by an ampersand<br />

(‘&”).<br />

You can also use cURL to test this binding. Create a new text file called<br />

RankEmployeeUrlEncoded.txt. The content of your file should look like this:<br />

EMPLOYEE_CODE=10004&RANKING=Excellent<br />

The cURL command to send the request to the web service should look like this:<br />

curl.exe -d @"RankEmployeeUrlEncoded.txt"<br />

-H "Content-Type:application/x-www-<strong>for</strong>m-urlencoded"<br />

-v<br />

http://localhost:8080/WebServicesSimpleService/rest/SimpleService/RankEmpl<br />

oyee<br />

The response message is the same as <strong>for</strong> the HTTP POST (XML) binding.

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

Saved successfully!

Ooh no, something went wrong!