Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "Scout/Tutorial/3.8/webservices/Change WSDL file to return a list of companies"

< Scout‎ | Tutorial‎ | 3.8
 
(18 intermediate revisions by 3 users not shown)
Line 1: Line 1:
Open the WSDL file in the built-in [http://wiki.eclipse.org/index.php/Introduction_to_the_WSDL_Editor Eclipse WSDL editor]. This editor is part of the WTP project of Eclipse. If not available on your IDE, update your Eclise IDE accordingly.
+
{{ScoutPage|cat=Tutorial 3.8}}
The WSDL file should look as following:
+
Open the WSDL file in the built-in [http://wiki.eclipse.org/index.php/Introduction_to_the_WSDL_Editor Eclipse WSDL editor]. This editor is part of the WTP project of Eclipse. If not available on your IDE, update your Eclise IDE accordingly.<br/>The WSDL file should look as following:
  
 
[[Image:org.eclipse.scout.jaxws.tutorial.EditWsdl_10.png|400px]]
 
[[Image:org.eclipse.scout.jaxws.tutorial.EditWsdl_10.png|400px]]
  
 +
What you see is your webservice, that has one service included which is bound to your CompanyWebServicePortType. For more information on that topic, please refer to [http://www.w3.org/TR/wsdl [http://www.w3.org/TR/wsdl].
  
== Change return type ==
+
{{note|Please note if removing or adding operations|It is crucial to generate the binding content anew. Right-Click on the binding box [http://wiki.eclipse.org/Image:org.eclipse.scout.jaxws.tutorial.EditWsdl_200.png] and choose 'Generate binding content...' [http://wiki.eclipse.org/Image:org.eclipse.scout.jaxws.tutorial.EditWsdl_210.png]. Afterwards, check 'Overwrite existing binding information' and press OK [http://wiki.eclipse.org/Image:org.eclipse.scout.jaxws.tutorial.EditWsdl_220.png].}}
The WSDL file sho
+
[[Image:org.eclipse.scout.jaxws.tutorial.EditWsdl_10.png|thumb|width=300px;WSDL file in WSDL editor]]
+
  
  
On server node, go to the node <code>'Webservices (JAX-WS RI 2.1.6)' | 'Provider' | ''''Services''''</code>. Right-click on that node to create a new webservice provider [http://wiki.eclipse.org/Image:Org.eclipse.scout.jaxws.CreateWebServiceProvider_0.png]. In the first wizard step, choose the 1st option to create a webservice provider from scratch, meaning not based on an existing [http://en.wikipedia.org/wiki/Web_Services_Description_Language WSDL] file [http://wiki.eclipse.org/Image:Org.eclipse.scout.jaxws.CreateWebServiceProvider_10.png]. Click next to enter the WSDL name which is <code>CompanyWebService.wsdl</code>. Also, change the name for the service operation to <code>getCompanies</code> [http://wiki.eclipse.org/Image:Org.eclipse.scout.jaxws.CreateWebServiceProvider_20.png]. Click Finish to create the webservice provider. {{ScoutLink|SDK|JAXWS-SDK/Create webservice provider|name=Click here}} to learn more about webservice provider creation. In case you encounter problems to build the webservice stub, refer to the {{ScoutLink|Tutorials|Webservices with JAX-WS/Console Output for CompanyWebService|name=Console Output}} for more information.
+
== Change output parameter ==
Please find the created webservice provider <code>CompanyWebService</code> in Scout Explorer [http://wiki.eclipse.org/Image:Org.eclipse.scout.jaxws.provider_10.png]. In the Scout Property View of this provider, you can access the various files such as the WSDL file, implementation class or the JAX-WS service type. Also, there you find links to rebuild the webservice stub, to change build properties for stub generation process, to edit binding customization files and more. Also, the authentication mechanism can be changed in the section <code>Authentication and session context</code>. For more information on that Property View, please {{ScoutLink|SDK|JAXWS-SDK/Webservice provider Property View|name=click here}}.
+
To change the output parameter, click on the arrow-link on the very right side of the output parameter [http://wiki.eclipse.org/Image:org.eclipse.scout.jaxws.tutorial.EditWsdl_20.png]. That opens you the <code>getCompaniesResponse</code> element of that parameter [http://wiki.eclipse.org/Image:org.eclipse.scout.jaxws.tutorial.EditWsdl_30.png]. On the right side, you see the anonymous type <code>getCompaniesResponseType</code> associated with the response element. There you find the <code>out</code> element. Left-click on its datatype (string) and choose 'New' [http://wiki.eclipse.org/Image:org.eclipse.scout.jaxws.tutorial.EditWsdl_40.png]. Chose <code>Complex Type</code> and give it the name <code>Company</code> [http://wiki.eclipse.org/Image:org.eclipse.scout.jaxws.tutorial.EditWsdl_50.png]. Right-click on the <code>out</code> element and change the multiplicity to <code>0..*</code> [http://wiki.eclipse.org/Image:org.eclipse.scout.jaxws.tutorial.EditWsdl_60.png]. That allows you to return zero or more company objects [http://wiki.eclipse.org/Image:org.eclipse.scout.jaxws.tutorial.EditWsdl_70.png].
 +
Open the 'Schema Index View' by clicking on the schema link on the very top-left corner [http://wiki.eclipse.org/Image:org.eclipse.scout.jaxws.tutorial.EditWsdl_80.png]. In type 'Types'-section you find the <code>Company</code> type which we created before. Double-click on the <code>Company</code> type to open it [http://wiki.eclipse.org/Image:org.eclipse.scout.jaxws.tutorial.EditWsdl_90.png]. What you see is an empty complex type. Right-click on the element's name to add the two child elements <code>name</code> and <code>symbol</code>[http://wiki.eclipse.org/Image:org.eclipse.scout.jaxws.tutorial.EditWsdl_100.png]. The element <code>Name</code> will hold the company name and the element <code>symbol</code> its stock symbol. It should look like this: [http://wiki.eclipse.org/Image:org.eclipse.scout.jaxws.tutorial.EditWsdl_110.png]. Save the WSDL.
  
So far, our webservice consists of a single operation to return companies. To open the WSDL file in the WSDL editor, click on the link 'CompanyWebService.wsdl' in the Scout Property View [http://wiki.eclipse.org/Image:Org.eclipse.scout.jaxws.CreateWebServiceProvider_50.png], To open the implementing port type, double click the webservice node or click on the 'CompanyWebService' link in the PropertyView [http://wiki.eclipse.org/Image:Org.eclipse.scout.jaxws.CreateWebServiceProvider_60.png].
+
== Remove input parameter==
As you can see, this webservice consists of a single operation <code>getCompanies</code> with a <code>String</code> as its return value and a <code>String</code> as its parameter. We will change that to return a list of company objects with no input parameter. Because this webservice is a Contract-First webservice, meaning that we are designing the WSDL file by ourself rather than generating it based on Java classes, open the WSDL editor [http://wiki.eclipse.org/Image:Org.eclipse.scout.jaxws.CreateWebServiceProvider_50.png] to change the service. Click {{ScoutLink|Tutorials|Webservices with JAX-WS/Change WSDL file to return a list of companies|name=here}} to follow detailed instructions.
+
To remove the input parameter, click on the arrow-link on the very right side of the input parameter [http://wiki.eclipse.org/Image:org.eclipse.scout.jaxws.tutorial.EditWsdl_120.png]. There you see the anonymous <code>getCompaniesType</code> with <code>in</code> as its child element [http://wiki.eclipse.org/Image:org.eclipse.scout.jaxws.tutorial.EditWsdl_130.png]. To get rid of this, right-click on the <code>getCompanies</code> element and choose 'Set Type' | 'New' [http://wiki.eclipse.org/Image:org.eclipse.scout.jaxws.tutorial.EditWsdl_140.png]. A dialog will pop up to create the new type. Choose 'Create a local anonymous type' and click OK [http://wiki.eclipse.org/Image:org.eclipse.scout.jaxws.tutorial.EditWsdl_150.png]. As a result, the <code>getCompanies</code> element will look like this: [http://wiki.eclipse.org/Image:org.eclipse.scout.jaxws.tutorial.EditWsdl_160.png].
  
 
+
[[Image:org.eclipse.scout.jaxws.tutorial.EditWsdl_10.png|thumb]]
[[Image:org.eclipse.scout.jaxws.tutorial.EditWsdl_10.png|thumb|Create webservice consumer]]
+
[[Image:org.eclipse.scout.jaxws.tutorial.EditWsdl_20.png|thumb]]
[[Image:org.eclipse.scout.jaxws.tutorial.EditWsdl_20.png|thumb|Create webservice consumer]]
+
[[Image:org.eclipse.scout.jaxws.tutorial.EditWsdl_30.png|thumb]]
[[Image:org.eclipse.scout.jaxws.tutorial.EditWsdl_30.png|thumb|Create webservice consumer]]
+
[[Image:org.eclipse.scout.jaxws.tutorial.EditWsdl_40.png|thumb]]
[[Image:org.eclipse.scout.jaxws.tutorial.EditWsdl_40.png|thumb|Create webservice consumer]]
+
[[Image:org.eclipse.scout.jaxws.tutorial.EditWsdl_50.png|thumb]]
[[Image:org.eclipse.scout.jaxws.tutorial.EditWsdl_50.png|thumb|Create webservice consumer]]
+
[[Image:org.eclipse.scout.jaxws.tutorial.EditWsdl_60.png|thumb]]
[[Image:org.eclipse.scout.jaxws.tutorial.EditWsdl_60.png|thumb|Create webservice consumer]]
+
[[Image:org.eclipse.scout.jaxws.tutorial.EditWsdl_70.png|thumb]]
[[Image:org.eclipse.scout.jaxws.tutorial.EditWsdl_70.png|thumb|Create webservice consumer]]
+
[[Image:org.eclipse.scout.jaxws.tutorial.EditWsdl_80.png|thumb]]
[[Image:org.eclipse.scout.jaxws.tutorial.EditWsdl_80.png|thumb|Create webservice consumer]]
+
[[Image:org.eclipse.scout.jaxws.tutorial.EditWsdl_90.png|thumb]]
[[Image:org.eclipse.scout.jaxws.tutorial.EditWsdl_90.png|thumb|Create webservice consumer]]
+
[[Image:org.eclipse.scout.jaxws.tutorial.EditWsdl_100.png|thumb]]
[[Image:org.eclipse.scout.jaxws.tutorial.EditWsdl_100.png|thumb|Create webservice consumer]]
+
[[Image:org.eclipse.scout.jaxws.tutorial.EditWsdl_110.png|thumb]]
[[Image:org.eclipse.scout.jaxws.tutorial.EditWsdl_110.png|thumb|Create webservice consumer]]
+
[[Image:org.eclipse.scout.jaxws.tutorial.EditWsdl_120.png|thumb]]
[[Image:org.eclipse.scout.jaxws.tutorial.EditWsdl_120.png|thumb|Create webservice consumer]]
+
[[Image:org.eclipse.scout.jaxws.tutorial.EditWsdl_130.png|thumb]]
[[Image:org.eclipse.scout.jaxws.tutorial.EditWsdl_130.png|thumb|Create webservice consumer]]
+
[[Image:org.eclipse.scout.jaxws.tutorial.EditWsdl_140.png|thumb]]
[[Image:org.eclipse.scout.jaxws.tutorial.EditWsdl_140.png|thumb|Create webservice consumer]]
+
[[Image:org.eclipse.scout.jaxws.tutorial.EditWsdl_150.png|thumb]]
[[Image:org.eclipse.scout.jaxws.tutorial.EditWsdl_150.png|thumb|Create webservice consumer]]
+
[[Image:org.eclipse.scout.jaxws.tutorial.EditWsdl_160.png|thumb]]
[[Image:org.eclipse.scout.jaxws.tutorial.EditWsdl_160.png|thumb|Create webservice consumer]]
+
[[Image:org.eclipse.scout.jaxws.tutorial.EditWsdl_200.png|thumb]]
 +
[[Image:org.eclipse.scout.jaxws.tutorial.EditWsdl_210.png|thumb]]
 +
[[Image:org.eclipse.scout.jaxws.tutorial.EditWsdl_220.png|thumb]]

Latest revision as of 18:17, 27 April 2012

The Scout documentation has been moved to https://eclipsescout.github.io/. Open the WSDL file in the built-in Eclipse WSDL editor. This editor is part of the WTP project of Eclipse. If not available on your IDE, update your Eclise IDE accordingly.
The WSDL file should look as following:

Org.eclipse.scout.jaxws.tutorial.EditWsdl 10.png

What you see is your webservice, that has one service included which is bound to your CompanyWebServicePortType. For more information on that topic, please refer to [http://www.w3.org/TR/wsdl.

Note.png
Please note if removing or adding operations
It is crucial to generate the binding content anew. Right-Click on the binding box [1] and choose 'Generate binding content...' [2]. Afterwards, check 'Overwrite existing binding information' and press OK [3].


Change output parameter

To change the output parameter, click on the arrow-link on the very right side of the output parameter [4]. That opens you the getCompaniesResponse element of that parameter [5]. On the right side, you see the anonymous type getCompaniesResponseType associated with the response element. There you find the out element. Left-click on its datatype (string) and choose 'New' [6]. Chose Complex Type and give it the name Company [7]. Right-click on the out element and change the multiplicity to 0..* [8]. That allows you to return zero or more company objects [9]. Open the 'Schema Index View' by clicking on the schema link on the very top-left corner [10]. In type 'Types'-section you find the Company type which we created before. Double-click on the Company type to open it [11]. What you see is an empty complex type. Right-click on the element's name to add the two child elements name and symbol[12]. The element Name will hold the company name and the element symbol its stock symbol. It should look like this: [13]. Save the WSDL.

Remove input parameter

To remove the input parameter, click on the arrow-link on the very right side of the input parameter [14]. There you see the anonymous getCompaniesType with in as its child element [15]. To get rid of this, right-click on the getCompanies element and choose 'Set Type' | 'New' [16]. A dialog will pop up to create the new type. Choose 'Create a local anonymous type' and click OK [17]. As a result, the getCompanies element will look like this: [18].

Org.eclipse.scout.jaxws.tutorial.EditWsdl 10.png
Org.eclipse.scout.jaxws.tutorial.EditWsdl 20.png
Org.eclipse.scout.jaxws.tutorial.EditWsdl 30.png
Org.eclipse.scout.jaxws.tutorial.EditWsdl 40.png
Org.eclipse.scout.jaxws.tutorial.EditWsdl 50.png
Org.eclipse.scout.jaxws.tutorial.EditWsdl 60.png
Org.eclipse.scout.jaxws.tutorial.EditWsdl 70.png
Org.eclipse.scout.jaxws.tutorial.EditWsdl 80.png
Org.eclipse.scout.jaxws.tutorial.EditWsdl 90.png
Org.eclipse.scout.jaxws.tutorial.EditWsdl 100.png
Org.eclipse.scout.jaxws.tutorial.EditWsdl 110.png
Org.eclipse.scout.jaxws.tutorial.EditWsdl 120.png
Org.eclipse.scout.jaxws.tutorial.EditWsdl 130.png
Org.eclipse.scout.jaxws.tutorial.EditWsdl 140.png
Org.eclipse.scout.jaxws.tutorial.EditWsdl 150.png
Org.eclipse.scout.jaxws.tutorial.EditWsdl 160.png
Org.eclipse.scout.jaxws.tutorial.EditWsdl 200.png
Org.eclipse.scout.jaxws.tutorial.EditWsdl 210.png
Org.eclipse.scout.jaxws.tutorial.EditWsdl 220.png

Back to the top