Dieser Inhalt ist in der von Ihnen ausgewählten Sprache nicht verfügbar.
Chapter 36. Customizing How Types are Generated
Abstract
36.1. Basics of Customizing Type Mappings Link kopierenLink in die Zwischenablage kopiert!
Overview Link kopierenLink in die Zwischenablage kopiert!
Namespace Link kopierenLink in die Zwischenablage kopiert!
http://java.sun.com/xml/ns/jaxb. You must add a namespace declaration similar to the one shown in Example 36.1, “JAXB Customization Namespace”. This is added to the root element of all XML documents defining JAXB customizations.
Example 36.1. JAXB Customization Namespace
xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
Version declaration Link kopierenLink in die Zwischenablage kopiert!
jaxb:version attribute to the root element of the external binding declaration. If you are using in-line customization, you must include the jaxb:version attribute in the schema element containing the customizations. The value of the attribute is always 2.0.
jaxb:version attribute used in a schema element.
Example 36.2. Specifying the JAXB Customization Version
< schema ...
jaxb:version="2.0">
Using in-line customization Link kopierenLink in die Zwischenablage kopiert!
xsd:appinfo element of the XML schema construct that is being modified.
Example 36.3. Customized XML Schema
<schema targetNamespace="http://widget.com/types/widgetTypes"
xmlns="http://www.w3.org/2001/XMLSchema"
xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
jaxb:version="2.0">
<complexType name="size">
<annotation>
<appinfo>
<jaxb:class name="widgetSize" />
</appinfo>
</annotation>
<sequence>
<element name="longSize" type="xsd:string" />
<element name="numberSize" type="xsd:int" />
</sequence>
</complexType>
<schema>
Using an external binding declaration Link kopierenLink in die Zwischenablage kopiert!
jaxb:bindings elements. Example 36.4, “JAXB External Binding Declaration Syntax” shows the syntax of an external binding declaration.
Example 36.4. JAXB External Binding Declaration Syntax
<jaxb:bindings xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
jaxb:version="2.0">
<jaxb:bindings [schemaLocation="schemaUri" | wsdlLocation="wsdlUri">
<jaxb:bindings node="nodeXPath">
binding declaration
</jaxb:bindings>
...
</jaxb:bindings>
<jaxb:bindings>
schemaLocation attribute and the wsdlLocation attribute are used to identify the schema document to which the modifications are applied. Use the schemaLocation attribute if you are generating code from a schema document. Use the wsdlLocation attribute if you are generating code from a WSDL document.
node attribute is used to identify the specific XML schema construct that is to be modified. It is an XPath statement that resolves to an XML Schema element.
widgetSchema.xsd, shown in Example 36.5, “XML Schema File”, the external binding declaration shown in Example 36.6, “External Binding Declaration” modifies the generation of the complex type size.
Example 36.5. XML Schema File
<schema targetNamespace="http://widget.com/types/widgetTypes"
xmlns="http://www.w3.org/2001/XMLSchema"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
version="1.0">
<complexType name="size">
<sequence>
<element name="longSize" type="xsd:string" />
<element name="numberSize" type="xsd:int" />
</sequence>
</complexType>
<schema>
Example 36.6. External Binding Declaration
<jaxb:bindings xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
jaxb:version="2.0">
<jaxb:bindings schemaLocation="wsdlSchema.xsd">
<jaxb:bindings node="xsd:complexType[@name='size']">
<jaxb:class name="widgetSize" />
</jaxb:bindings>
</jaxb:bindings>
<jaxb:bindings>
-b binding-file option, as shown below:
wsdl2java -b widgetBinding.xml widget.wsdl