Using JAX-WS and JAXB with WebLogic Server 10: JAX-WS Customization Bindingby Mike Wooten AbstractUsing JAX-WS and JAXB with WebLogic Server 10 introduces the JAX-WS Web service stack and the JAXB Java/XML binding technology available in BEA WebLogic Server 10. These implementations are based on JAR files from the Glassfish JAX-WS 2.0 and Glassfish JAXB 2.0 projects. This article provides a set of tutorials devoted to JAX-WS customization binding—the part of the JAX-WS specification that covers WSDL-to-Java mappings. Some mention of JAXB customization binding appears here and there. Table of TutorialsAfter introducing JAX-WS customization bindings, this article presents a set of tutorials showing how to carry out various customization tasks:
Afterwards, I'll take a look at some code samples that use the results of applying JAX-WS and JAXB customization bindings. Customization bindings apply to both the service consumer and service provider, so this will be reflected in these code samples:
Introduction to JAX-WS Customization BindingJAX-WS customization binding is the part of the JAX-WS specification that covers WSDL-to-Java mappings. The JAXB specification includes a similar section that covers XSD-to-Java mappings. This is all well and good, but why would you want to control WSDL-to-Java (or XSD-to-Java) mapping, anyway? I'll answer that question by using some situations you may have faced recently.
These are just a few situations where you would want (or need) to use a customization binding. I'll be talking about how to do this throughout this article, so I'll return to defining what it is for now. Customization binding is frequently referred to as binding declaration, so I'll switch to using that term for the remainder of this article. Binding declarations essentially are "instructions" expressed in XML, which can either be embedded in a WSDL or XML Schema file, or placed in an external XML file. With the latter, XPath expressions are used to select the target section in the WSDL or XML Schema file. The XML file-based approach is the one preferred by SOA architects and developers because it offers flexibility without sacrificing maintainability or governance. Binding declarations are XML elements that are processed by Sun's
<target name="run-wsdlc" depends="clean">
<taskdef name="wsdlc" classname="weblogic.wsee.tools.anttasks.WsdlcTask" classpathref="compile.classpath" />
<mkdir dir="${src.dir}"/>
<property name="binding.declaration.files" value="server-jaxws.xbd,shared-jaxb.xbd"/>
<wsdlc
type="JAXWS"
srcWsdl="etc/${wsdl.file.name}.wsdl"
destJwsDir="WebContent/WEB-INF/lib"
destImplDir="${src.dir}"
explode="false"
verbose="${verbose}"
debug="${debug}"
failonerror="true"
>
<binding dir="etc" includes="${binding.declaration.files}"/>
<classpath>
<path refid="compile.classpath"/>
</classpath>
</wsdlc>
</target>
The The What can you do with a JAX-WS binding declaration?The simple answer is that you can specify how the information in the WSDL maps to Java code generated for a JAX-WS Web service and a JAX-WS Web service consumer. This Java code includes:
*Accomplished using a JAXB binding customization file The next section of the article describes the JAX-WS binding declarations that allow you to do the non-asterisk items above. Usage of JAX-WS Binding DeclarationsNow I'll take a look at some of the ways you can use JAX-WS binding declarations. Using a JAX-WS binding declaration to specify Java package namesThis binding declaration is probably more valuable with JAXB than with JAX-WS, but it's an important one nonetheless. I covered the JAX-WS aspect of this binding declaration in the first article, but this one is from the JAXB aspect. The purpose for using it is the same: to control the Java package name for the classes that are generated. Here are the contents of the
<jxb:bindings
version="1.0"
xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
>
<jxb:bindings
xmlns:xs="http://www.w3.org/2001/XMLSchema"
schemaLocation="datastaging_exceptions.xsd"
node="/xs:schema"
>
<jxb:schemaBindings>
<jxb:package name="services.datastaging.exceptions"/>
</jxb:schemaBindings>
</jxb:bindings>
</jxb:bindings>
Using this Note: Don't use the If your XML schema file uses
<jxb:bindings
version="1.0"
xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
>
<jxb:bindings
xmlns:xs="http://www.w3.org/2001/XMLSchema"
schemaLocation="schemas/oasis-wsn13.xsd"
node="/xs:schema"
>
<jxb:bindings
xmlns:xs="http://www.w3.org/2001/XMLSchema"
node="//xs:schema/xs:import[@namespace='http://docs.oasis-open.org/wsn/b-2']"
>
<jxb:schemaBindings>
<jxb:package name="org.oasis_open.docs.wsn.b_2"/>
</jxb:schemaBindings>
</jxb:bindings>
<jxb:bindings
xmlns:xs="http://www.w3.org/2001/XMLSchema"
node="//xs:schema/xs:import[@namespace='http://docs.oasis-open.org/wsn/br-2']"
>
<jxb:schemaBindings>
<jxb:package name="org.oasis_open.docs.wsn.br_2"/>
</jxb:schemaBindings>
</jxb:bindings>
<jxb:bindings
xmlns:xs="http://www.w3.org/2001/XMLSchema"
node="//xs:schema/xs:import[@namespace='http://docs.oasis-open.org/wsn/t-1']"
>
<jxb:schemaBindings>
<jxb:package name="org.oasis_open.docs.wsn.t_1"/>
</jxb:schemaBindings>
</jxb:bindings>
...
</jxb:bindings>
</jxb:bindings>
The bold typeface sections highlight the fact that the XPath expression in the You can have more than one nested |
Article Tools Related Products Check out the products mentioned in this article:Related Technologies Related Articles Bookmark Article
|