|
|
(One intermediate revision by one other user not shown) |
Line 1: |
Line 1: |
− | {{ScoutPage|cat=Tutorial 3.7}}
| + | The Scout documentation has been moved to https://eclipsescout.github.io/. |
− | | + | |
− | =Access Web Services with Scout Eclipse=
| + | |
− | | + | |
− | {{warning|Axis webservice support is discontinued in favor of the new JAX-WS Integration. Please consider using the {{ScoutLink|Tutorial|Webservices with JAX-WS|name=JAX-WS tutorial}} instead }}
| + | |
− | | + | |
− | ==Generate Web Service Classes==
| + | |
− | In Eclipse Scout it is also pretty easy to access web services. We will use Bing as an example web service. See http://www.bing.com/developers/ for more information.
| + | |
− | | + | |
− | To create the Bing webservice consumer work throught the following steps
| + | |
− | # Go to the ''server'' node of your Scout Project
| + | |
− | # Expand the tree until you see the node ''Axis Web Service Consumers''
| + | |
− | # Select ''New Webservice consumer'' from the context menu.
| + | |
− | # Paste the following API key into the WSDL URL field http://api.search.live.net/search.wsdl?AppID=F1DFAE1859C73D8B105D99A78F0B027B62C64814 and click Ok. An overview will pop-up which you acknowledge.
| + | |
− | | + | |
− | ==Consume the Web Service==
| + | |
− | In order to consume the web service add a new service operation to your ''StandardOutlineService'' with the following signature: <source lang="java">Object[][] getBingTableData(String query) throws ProcessingException</source><br/>
| + | |
− | <source lang="java">
| + | |
− | public Object[][] getBingTableData(String query) throws ProcessingException{
| + | |
− | String appId = "BE75364456DF97D980FFDC1420E46B941E7D01CB";
| + | |
− | BingServiceLocator soapClient = new BingServiceLocator();
| + | |
− | SearchRequest request = new SearchRequest();
| + | |
− | request.setAppId(appId);
| + | |
− | request.setQuery(query);
| + | |
− | SourceType[] sources = {SourceType.Web};
| + | |
− | request.setSources(sources);
| + | |
− | SearchResponse response;
| + | |
− | try {
| + | |
− | response = soapClient.getBingPort().search(new SearchRequestType1(request)).getParameters();
| + | |
− | }
| + | |
− | catch (Exception e) {
| + | |
− | throw new ProcessingException(e.getMessage(), e);
| + | |
− | }
| + | |
− | WebResult[] result = response.getWeb().getResults();
| + | |
− | Object[][] data = new Object[result.length][3];
| + | |
− | for (int row = 0; row < data.length; row++) {
| + | |
− | data[row][0] = result[row].getUrl();
| + | |
− | data[row][1] = result[row].getTitle();
| + | |
− | data[row][2] = result[row].getDescription();
| + | |
− | }
| + | |
− | return data;
| + | |
− | }
| + | |
− | </source>
| + | |
− | | + | |
− | ==Create the Client Table==
| + | |
− | Below your ''CompanyNodePage'' add a new ''BingTablePage'', extending ''AbstractPageWithTable''. In order to do that, you have to add a new variable to the ''CompanyNodePage'' containing the name of the company, which is used for calling the Bing-Service.
| + | |