To see the code generated for the WeatherSummary.wsdl, ensure that your environment is set up as discussed in Chapter 2, "Setup," in the Introduction to HydraExpress, open a command prompt, and navigate to the directory <installdir>\tutorials\webservicesug\WeatherSummary.
The command
prompt> rwsfgen example-project.xml
generates code into a code generation directory WeatherSummaryExample. Because the HydraExpress project file example-project.xml points to a WSDL that contains a schema, the generated project structure will include data subdirectories as well as a relevant namespace directory, as illustrated in Table 3.
In order to simplify this discussion, this table does not list the generated client and server classes, but only the datatype classes.
Directory | Files | Description |
WeatherSummaryExample/ |
WeatherSummaryExample.xml | Project file defining all project elements. See Section 21.3. |
makefile | Project-level makefiles. Calls all makefiles in subdirectories. Overwrite protected. | |
makefile.include | Include makefile. Contains all makefile compiler and linker options. Edits to this file cascade down to all makefiles. Overwrite-protected. | |
app/ |
makefile | Makefiles for app directory. Overwrite protected. |
/data |
WeatherSummary_1_main.cpp | Sample application file. Overwrite protected. |
codegen/ |
makefile | Makefiles for codegen directory. Overwrite protected. |
/data/ |
makefile | Makefiles for data directory. |
/wsx |
WeatherSummary.cpp | Source files for the datatype classes sorted into separate namespace directories |
docs/ |
index.html | HTML documentation files |
include/ | ||
/WeatherSummaryExample | subdirectory projectname | |
WeatherSummary_typesConverter.h | Conversion utility class header file (to convert the simple types defined in the datamap to and from the underlying string class, string) | |
|
WeatherSummary.h | Header files for the datatype classes |
The docs directory contains HTML documentation. Single-click access is provided through the index.html file in the docs directory.
The generator creates one data type class named WeatherSummary, based on the complexType's name attribute. The source file for class WeatherSummary is placed into the codegen\data\wsx directory, where wsx is the namespace. The data type header file is placed into the include\WeatherSummary\wsx directory where WeatherSummary is the project name.
Class WeatherSummary provides accessors to work with the data, and also includes unmarshal() methods that populate an instance of the class from a serialized WeatherSummary type element, and marshal() methods for converting an instance of the class to a serialized format. These methods pass the marshaling and unmarshaling logic to the generated external marshaling class, WeatherSummaryMarshal. This class contains the logic to unmarshal and marshal the data and is called by WeatherSummary's unmarshal() and marshal() methods. Unless you are customizing the marshaling and unmarshaling process in some way, you do not need to explicitly use the marshaling class.
The directory app\data contains the sample application, and the directory include contains relevant include and header files.
Source code other than that in the app directory is not overwrite protected. You should never add business logic or make any other changes to the generated source code, as these changes will be lost the next time the code is generated.
To use the sample application WeatherSummary_1_main.cpp located in the directory WeatherSummaryExample\apps\data, add your application logic to it. This file is generated to help you quickly create an application main that uses the generated API to marshal and unmarshal your code. Edit this file to replace the TODO items with your application logic.
int main() { // TODO: Instantiation of generated object here // Use a C++ try block to handle errors that can occur when unmarshalling XML try { // TODO: invoke unmarshal method on generated object } catch (const rwsf::XmlParseException &e) { std::cerr << "Error unmashaling : " << e.what() << std::endl; return 1; } catch (const rwsf::Exception &e) { std::cerr << "Error : " << e.what() << std::endl; return 1; } catch (...) { std::cerr << "Unexpected Error" << std::endl; return 1; } // TODO: manipulate tree here // TODO: invoke marshal method on generated object to create XML from tree } return 0; }
The example WeatherSummary does not ship with an implemented sample main application, as its primary focus is to illustrate various aspects of developing Web services.
For examples that do include implemented main applications, see any example in the <installdir>\tutorials\xmlbinding directory.
© Copyright Rogue Wave Software, Inc. All Rights Reserved. All Rights Reserved. Rogue Wave is a registered trademark of Rogue Wave Software, Inc. in the United States and other countries. HydraExpress is a trademark of Rogue Wave Software, Inc. All other trademarks are the property of their respective owners.
Contact Rogue Wave about documentation or support issues.