Creating a Web Service Model

Before you can use the e-mail Web service provided by an external provider within this Web Dynpro example application, you need to create the appropriate model. You will do this in the next step. At runtime, this model performs the data exchange between a Web Dynpro component and the Web service end point.

Within a Web Dynpro component, business data is stored in separate context structures (consisting of context nodes, context node elements and context attributes). In this example, Subject, E-mail Text, Sender Address and Recipient Address are the context attributes for context node WebServiceEmail. To transfer the e-mail information entered by the user to the Web service, and to receive the response, you need a model that provides the necessary auxiliary classes and communication classes.

You can use the Web Dynpro tools to generate a model of this kind for a particular Web service description. The model consists mainly of Java proxies (client stubs for communication with the Web service), as well as special model classes to which you can bind model nodes and model attributes of a controller context (model binding).  

The following is a description of how to generate a Web Dynpro model from the WSDL description of the e-mail Web service. (WSDL is an XML format used to describe network services.) This WSDL description is provided by the service provider.  If your HTTP connection is linked using a proxy host, you need to make some additional settings.

SAP AG does not accept any responsibility regarding the availability and quality of the external e-mail service used in this tutorial.

Prerequisites

The service provider can load the WSDL description of the e-mail Web service. The Web service described functions correctly.

The structure of your WebDynpro_EmailWS project is currently displayed in the Web Dynpro Explorer.

The valid proxy settings for your developer work station have been configured in SAP NetWeaver Developer Studio (see Window ® Preferences ®  Workbench ®  Proxy Settings).

 

Procedure

To create a model based on a certain Web service, you first require the URL address through which the corresponding WSDL description can be accessed. If the address is known, you can create the Web Dynpro model in a few simple steps.

Generating a Model from a WSDL Description and Using it in the Component

...

       1.      In the project structure, choose Web Dynpro ® Web Dynpro Components ® EmailWSComponent.

       2.      To start the Data Modeler, open the context menu and choose Open Data Modeler. Alternatively, you can double-click the node.

       3.      In the Data Modeler toolbar, choose  Create a model.

       4.      Place the cursor on  Used Models and left-click.

       5.      Choose Import Web Service Model, followed by Next.

       6.      Enter EmailModel as the name of the model and com.sap.tc.webdynpro.tutorial.emailws.model as the name of the package.

       7.      Under Select WSDL Source, select the radio button UDDI or URL, followed by Next.

       8.      Enter the following WSDL description for the email Web service in the WSDL field: http://www.abysal.com/soap/AbysalEmail.wsdl

       9.      You do not need to make any entries in the next step, Proxy Definition / URI Package Mappings. Close the input dialog by choosing Finish.

You can only import a Web Service model based on an external WSDL description if the valid proxy settings for your developer work station have been defined in SAP NetWeaver Developer Studio. If errors occur during the model import process, you should therefore check the defined proxy settings – and correct as necessary - under Window ®Preferences ®  Workbench ®  Proxy Settings.

The corresponding Java proxies are then generated as client stubs, and the model classes are generated for the subsequent binding of context elements.

Note that a new model is initially imported at the project level, regardless of the components that these projects contain. If a model is to be used in a component, you have to define a corresponding model usage. This usage-relation is automatically defined by the data modeler when carrying out the procedure mentioned above.

Making HTTP Proxy Settings

If your HTTP connection to the e-mail Web service uses an HTTP proxy, you also need to make the following settings:

...

       1.      In Web Dynpro Explorer, choose Web Dynpro ® Models ® EmailModel ® Logical Ports ® SendEmailPort and then choose Open in the context menu.

       2.      After selecting the Use HTTP Proxy checkbox, make the appropriate entries in the Proxy Host and Proxy Port fields:

The Proxy Host field represents the host name or the IP address of the proxy server; Proxy Port is the port to which the proxy server listens.

       3.      Save your settings by choosing (Save Editor Contents) in the toolbar below the menu bar.

Result

After the Web service model has been imported, the corresponding entries are inserted under the EmailModel node in Web Dynpro Explorer.

The nodes in the EmailModel represent the Model Classes (, executable model classes ) and their relations (), which are visible to you as the application developer. At a later time, you can bind the appropriate context elements to these classes and relations (model binding). This structure description is independent of the concrete model implementation (RFC, XML, Web Service) of the imported data model. Within a Web Dynpro component, Web Dynpro contexts serve as storage locations for structured data (for example, table data, form entries). The Data Binding function between UI elements and context elements allows you with a simple way of displaying this data in the Web Browser. 

Next Step:

Creating a Component Controller Context and Binding It to the Model