Create a web service using PowerDesigner 9.5
Sybase Company PowerDesigner General Designer XIAO WAN Written
Web services allow you to provide existing or new features in standard formats, and allow users and applications to access them from any location.
PowerDesigner 9.5 also introduces a complete web service design and build mechanism for Microsoft .NET and Java. Using PowerDesigner 9.5, you can focus on the design of the web service, and give all the required buildings and implement the tasks to PowerDesigner.
Web service overview
The web service is an interface that describes the set of operations that can be accessed through the SOAP message on the network.
The interface and deployment position of the web service (optional) is illustrated by the WSDL. WSDL is an XML document that declares data types, messages, port types, and port (optional). With WSDL, users can know which format should be sent to call the web service and the format that returns the message.
In order to enable users to find the desired Web service, the service provider may publish the WSDL document in the UDDI registration service. In this way, users can use UDDI registration services to search for web services.
To call the web service, the user can send SOAP messages to the access point URL where the Web service is deployed, or use the proxy class that can simplify this call. SOAP messages are also an XML document.
PowerDesigner's web service function
PowerDesigner 9.5 allows you to create a new web service component, create a web service component, browse UDDI, search for WSDL, generate WSDL, generate .NET (C # and VB .NET) server side from the definition of Web service components. Code, generate .NET client agent, generate server-side code for Java (JAX-RPC and JAXM), and generating Java client agent.
To design web service components, PowerDesigner uses UML class diagrams, component graphs, and deployment diagrams. The web service is represented by the components of the component map, and the deployed web service is represented by the component instance of the deployment diagram.
Create a web service component
There are five steps to create a Web service component. The first is to create an object-oriented model (OOM). You can use any of the following languages: C #, Visual Basic .NET or Java. The extension model definition (XEM) for WSDL is automatically attached to this model. XEM defines the generation template and extension attribute of WSDL.
The second step is to create a class. It is best to create a program group (package) and then create a class under this program group.
The third step is to convert the class of the created class into a web service component using the Web Service Wizard. To do this, you can right-click this class and select the Create Web Service Component command, or select the Tool> Create Web Service Component command after selecting the class. Figure 1 shows an example of a web service wizard. The Web service type can be an interface or implementation. If you select "Interface", you only want to define this web component and generate the corresponding WSDL. For .NET, this component type is "standard", and its web service will be implemented by .asmx files. For Java, this component type may be "standard", "service" or "stateless session bean". These Java component type implementation methods are: "Standard" Types Using JAX-RPC, "Sergers" types use JAXM, and "Status Session Bean" type will use J2EE (JSR109) Web service specification. A component and class will be created when the wizard ends. Figure 2 shows an example of the component symbol in the component map.
Figure 1 Web Service Wizard
Figure 2 Component symbol
The fourth step is to add a web method. You need to create a new action (Operation), open the property page of this action, click the "Web method" checkbox, define the parameters and return types, and write the implementation code of the operation. Figure 3 shows an example of implementation of the Web method getStockQuote. Figure 3 Implementation of GetStockQuote for Web Method
The final step is to customize the WSDL generation. You can customize the WSDL data type of the parameter and the return value, the operational extension attribute, and component's properties and extension properties. To verify the generated WSDL, you can open the WSDL tab of the component property page. The task that generates WSDL can be handed over to PowerDesigner, or you can define yourself (user-defined). If the web service component comes from the reverse engineering of WSDL, the original WSDL will be reserved. Figure 4 shows an example of a generated WSDL.
Example of the WSDL generated by Figure 4
You can preview the generated implementation code in the Preview tab of the class properties page.
You can use deployment diagrams, nodes, and component instances to simulate the deployed Web service components. In addition, the URL of the server can be defined in "Node" and the URL defined in "Component Instance".
Reverse engineering for WSDL
WSDL can only define a web service interface, or simultaneously define the URL of the interface and access point. The Web service interface may be used by multiple service providers to provide the same services, of course, these services will have different implementations and access points. If you have a file path or URL with a WSDL document, you can create a web service component by reverse it, you can define your own implementation method or save the Web service component saved in the library to use it again. You can use the UDDI browser to search in the UDDI registration service when you find the WSDL of interest.
In order to reverse WSDL, you need to create OOM with any language in C #, VB .NET or Java. Then select the "Language> Import WSDL" command and enter the path or URL of the WSDL file. After performing reverse engineering, a component is created in the component diagram while creating a class in the class diagram. The class created will only contain the operation signal of the web service. If you want to implement the web service, you also need to define the implementation code for these operations.
Search for WSDL in UDDI Registration Services
If you want to search for WSDL registered in the UDDI registration service, open the Import WSDL window and click the "Browse UDDI" button. By "browse UDDI" window (see Figure 5), you can choose UDDI operators, search criteria, and search types, and search by entity name, service name, or WSDL name. In addition, you can preview the found WSDL.
Figure 5 "Browse UDDI" Window
Generate .NET type web services
For .NET server-side code, PowerDesigner generates a .asmx file. The implementation class of this web service can be generated in the above .asmx file, or it can be generated outside. The language used herein can be C # or VB .NET. In the Preview tab of the Class Properties page, you can preview the .asmx file and the corresponding class code. Figure 6 shows an example of a .asmx file in a C # language.
Figure 6 C # language. Examplemx file example
PowerDesigner can also generate client proxy classes to simplify the call of Web services. To generate a client agent class, PowerDesigner uses the WSDL.exe program that comes with Visual Studio .NET.
To generate a WSDL, server-side code, and / or client agent, select "Language> Generate C # Code" or "Language> Generate VB .NET Code" command. If you want to generate a client agent, you can select the Generate Web Service Client Agent option in the Task tab. Figure 7 shows the available generated tasks. If this class is not generated inside the .asmx file, you will be able to compile these C # code or VB .NET code. However, when compiling C # or VB .NET files, you must define the CSC or VBC variable to indicate the location of the CSC.exe or vbc.exe command. When deploying a Web service, you only need to copy the .asmx files and corresponding class files under the IIS directory: C: / inetpub / wwwroot /
Figure 7 Generation task for web services
Generate a Java type web service
If the implementation type of the web service is "standard", PowerDesigner will use JAX-RPC to implement. If you implement the type "Server", PowerDesigner will use JAXM to implement. If the type is "stateless session bean, PowerDesigner will use the J2EE (JSR109) Web service specification. JSR109 has not officially promulgated.
JAX-RPC defines the Web service call for the RPC type. Although it is easy to develop and use, in order to avoid complex object / XML mapping, it can only be limited to a simple message format. JAXM-based Web service components clearly more superiority, which allows you to flexibly handle complex message structures.
To use JAX-RPC or JAXM, you need to install Java Web Services Developer Pack (JWSDP). This package can be downloaded from Sun's website. When deploying a JAX-RPC or JAXM type web service component, you need to support servers that support JAX-RPC or JAXM. Apache Tomcat supported by JAX-RPC or JAXM provides JWSDP.
As for a JAX-RPC-based web service component, you only need to implement the code of its web method. To generate a WSDL, server-side code, and / or client agent, select "Language> Generate Java Code", then select "Generate WSDL (Server)" and / or "Use XRPCC tool to generate web services using XRPCC tools Code "command (see Figure 8). The XRPCC command is a tool for jwsdp. It generates a JAX-RPC type server-side code or client agent. When deploying the generated web service, you need to create a .war file containing all generated files, and deploy this .war file on a server that supports JAX-RPC, such as Apache Tomcat.
Figure 8 JAX-RPC generation task
For JAXM-based Web service components, you need to implement its OnMessage operation. OnMessage Operation will receive and process the input SOAP messages in WSDL and build return messages, and return this message. To generate a WSDL and JAXM type web services, select the language> Generate Java Code command, then select "Build a web component, create a web application war" command (see Figure 9). This command compiles and creates a WAR file for JAXM service code. To deploy this JAXM service, you can deploy the above WAR files on a servers that support JAXM, such as Apache Tomcat. Figure 9 JAXM generation task
As for the Web service component based on stateless session beans, since the JSR109 specification has not yet formally promulgated, it is currently not available.
Next step to enhance the function
J2EE (JSR109) Web service specification will not be available for people to use. With it, you can use the stateless session bean as a weapon implemented by the web service. It allows existing features to appear in a new look of web services, and can also create a new web service. PowerDesigner 9.5 The included version based on the early JSR109 specification, which is still allowed to be further certified. After the specification is officially promulgated, we will provide maintenance versions to implement fully supported.
The new version of PowerDesigner will also support comprehensive standards for Web services.
in conclusion
PowerDesigner 9.5 simplifies the design and generation of web services. Just know how to create classes and methods, you can know how to create a web service! You can use PowerDesigner design, create web services, and reverse engineering and create documents for it. If you want to reuse these web components, you can create a Web service component library and use the repository to manage different versions of Web components.