uCosminexus Application Server, Web Service Development Guide
![[Contents]](FIGURE/CONTENT.GIF)
![[Glossary]](FIGURE/GLOSS.GIF)
![[Index]](FIGURE/INDEX.GIF)
![[Back]](FIGURE/FRONT.GIF)
For the wrapper style, the name of the method of SEI and a request bean with the same name as the name of the method of SEI will be generated. A response bean with the suffix 'Response' added to it will also be generated. The request and response beans can either be generated automatically by using the apt command or cjwsgen command, or you can dynamically generate them when starting Web Services. When dynamically generating the request and response beans, for a preliminary error check, you can execute the cjwsgen command for the compiled Web Services Implementation Class to avoid the occurrence of an error while starting Web Services. For details, see 10.23(1) Using the cjwsgen command for checking errors.
The following figure shows an example of mapping the method parameters to the message parts.
Figure 16-4 Example of mapping the method parameters to the message parts (Wrapper style)
![[Figure]](FIGURE/ZU120400.GIF)
The following figure shows an example of mapping the method return values to the message parts:
Figure 16-5 Example of mapping the method return values to the message parts (Wrapper style)
![[Figure]](FIGURE/ZU120500.GIF)
The following are the rules for mapping the method parameters and return values to the message parts:
- The parameters and return values are mapped using an empty name space ("") as the child element of the wrapper element. The wrapper element is mapped with a name space same as that for SEI.
- The in parameter and the inout parameter are mapped as a request bean property using the name argN#.
- The out parameter and the inout parameter are mapped as a response bean property using the name argN#.
Furthermore, the return value is mapped as a response bean property using the name "return". At this time, an underscore (_) is prefixed to the field name such that the name does not become a reserved word.
- The javax.xml.bind.annotation.XmlElement annotation is annotated in the properties of the mapped request bean and the response bean.
- In the annotated javax.xml.bind.annotation.XmlElement annotation, in the request bean properties, a name called argN# is set for the name element and a blank name space ("") is set for the namespace element. In the response bean properties, a name called return is set for the name element and a blank name space ("") is set for the namespace element.
- When mapping from a parameter to a WSDL part, the mapping to a part name of the input message is done with the fixed value parameters.
- When mapping from a return value to a WSDL part, the mapping to a name of the output message is done with the fixed value parameters.
- #
- N in argN indicates 0 or a higher integer that depends on the order of the parameters.
For details on the javax.xml.bind.annotation.XmlElement annotation, see 16.2.10 javax.xml.bind.annotation.XmlElement annotation.
This point describes the conditions and precautions for specifying a Java type other than the Holder(javax.xml.ws.Holder) type and Holder type.
(a) Java type other than Holder type
- The Java types other than the Holder type are mapped to the WSDL schema types in accordance with the JAXB 2.2 specifications. The precautions for specifying the Java types other than the Holder type are as follows:
- The Java primitive type cannot be specified in the out and inout parameters. If specified, an error message is output to the standard error output and log (KDJW61035-E).
- Also, the Java primitive type cannot be specified as the type parameter of the javax.xml.ws.Holder class. If specified, an error occurs when executing the apt command and the processing ends.
- You can specify a Java type in the out and inout parameter as the type parameter of the javax.xml.ws.Holder class. If the Java type is specified using any other method, an error message is output to the standard error output and logs (KDJW61035-E).
(b) javax.xml.ws.Holder type
The precautions for specifying the javax.xml.ws.Holder type are as follows:
- When you specify the javax.jws.WebParam annotation in the type parameter of the javax.xml.ws.Holder class, you must specify Mode.OUT or Mode.INOUT in the mode element. If the mode element is not specified or if Mode.IN is specified in the mode element, an error message is output to the standard error output and logs (KDJW61031-E). Also, if the javax.jws.WebParam annotation is not specified, the type parameter of javax.xml.ws.Holder is interpreted as the inout parameter.
- The operations might not function properly in the following cases:
- If the javax.xml.ws.Holder class is specified anywhere except in the method argument
- If the array of the javax.xml.ws.Holder class is used
- If the type is not specified in the type parameter of the javax.xml.ws.Holder class
- If the javax.xml.ws.Holder class or a class inheriting is specified in the type parameter of the javax.xml.ws.Holder class
- If a multi-dimensional array of a type other than the byte type and three or more dimensional array of the byte type are specified in the type parameter of the javax.xml.ws.Holder class when dynamically generating the request and response beans during the Web Services startup
(c) Java type mapping
The precautions for mapping the Java types are as follows:
- If Java types are not customized in the mode element of the javax.jws.WebParam annotation, the arguments other than the type parameter of the javax.xml.ws.Holder class are mapped as the in parameter and the type parameter of the javax.xml.ws.Holder class is mapped as the inout parameter. For details about the mapping as the out parameter, see 16.2.7(4) mode element (javax.jws.WebParam).
- The input message name is mapped using the operation name. The output message name is mapped using a value with 'Response' suffixed to the operation name.
- You can define up to 254 parameters of the method of SEI according to the Java language specifications. If 255 or more parameters are defined, a compilation error occurs during the execution of the apt command and the processing ends.
The parameter names of the Java methods are not mapped to WSDL; therefore, code the Java method parameters in accordance with the Java identifier naming rules provided in the Java language specifications.
You can combine and code the in parameter, inout parameter, out parameter, and the return value that you want.
This point describes the rules about the wrapper bean class name and global element name and the operations for a name conflict.
- Wrapper bean class name
The wrapper bean class name that is generated must be a unique name in the package. However, the differences in uppercase and lower case are ignored. If the request bean or response bean have a name conflict with another JavaBean class generated in the package concurrently, an error message is output to the standard error output and logs (KDJW61083-E).
If the name is duplicated with an existing class, the name is overwritten. However, if that class is included in the apt command argument, the error is checked when the apt command is executed.
- Global element (local name and name space)
The global element (local name and name space) must be unique in WSDL. If the name is not unique, the operations might not function properly.
When you use the java.util.Map class in the SEI argument or return value, the following operations must be performed for the argument or return value of the java.util.Map type of SEI:
- Create a value type.
Create the value type (a JavaBean class that can be marshaled or un-marshalled) for java.util.Map(bound type) in accordance with the JAXB 2.2 specifications.
- Create an adapter.
Create an adapter that interconverts the java.util.Map(bound type) that inherits javax.xml.bind.annotation.adapters.XmlAdapter and the value type, and implement the unmarshal method and marshal method.
- Annotate with the javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter annotation.
Annotate the argument or return value of the java.util.Map type with the XmlJavaTypeAdapter annotation that has the adapter created in 2 as the value.
- Execute the apt command.
Interpret the annotated SEI with the apt command.
The following is an example of the relationship and implementation of the request bean class and response bean class in which the xmlJavaTypeAdapter annotation is applied through the value type, adapter, and the apt command:
Figure 16-6 Example of using java.util.Map
![[Figure]](FIGURE/ZU120600.GIF)
All Rights Reserved. Copyright (C) 2013, Hitachi, Ltd.