You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by sc...@apache.org on 2008/07/09 20:46:14 UTC
svn commit: r675301 - in /webservices/axis2/trunk/java/modules:
jaxws-integration/ jaxws/src/org/apache/axis2/datasource/jaxb/
jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/
Author: scheu
Date: Wed Jul 9 11:46:13 2008
New Revision: 675301
URL: http://svn.apache.org/viewvc?rev=675301&view=rev
Log:
AXIS2-3854
Contributor: Rich Scheuerle
Changed the name of the method to setWebServiceNamespace and added comments indicating why we
are setting the default namespace to the web service namespace.
I also changed the pom.xml file to make sure the TypeSubstitutionTest is included.
Modified:
webservices/axis2/trunk/java/modules/jaxws-integration/pom.xml
webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/datasource/jaxb/JAXBDSContext.java
webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/DocLitWrappedMethodMarshaller.java
webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/DocLitWrappedPlusMethodMarshaller.java
Modified: webservices/axis2/trunk/java/modules/jaxws-integration/pom.xml
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws-integration/pom.xml?rev=675301&r1=675300&r2=675301&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws-integration/pom.xml (original)
+++ webservices/axis2/trunk/java/modules/jaxws-integration/pom.xml Wed Jul 9 11:46:13 2008
@@ -212,6 +212,12 @@
<classpath location="${compiled.classes.dir}"/>
<arg line="-d ${schema.generated.src.dir} -quiet ${schema.source.dir}/samplemtom.xsd"/>
</java>
+ <echo>Generating java from greeterTypes.xsd</echo>
+ <java classname="com.sun.tools.xjc.Driver" fork="true">
+ <classpath refid="maven.runtime.classpath"/>
+ <classpath location="${compiled.classes.dir}"/>
+ <arg line="-d ${schema.generated.src.dir} -quiet ${schema.source.dir}/greeterTypes.xsd"/>
+ </java>
<echo>Generating java from ProxyDocLitWrapped.wsdl</echo>
<java classname="com.sun.tools.xjc.Driver" fork="true">
<classpath refid="maven.runtime.classpath"/>
@@ -320,12 +326,7 @@
<classpath location="${compiled.classes.dir}"/>
<arg line="-d ${schema.generated.src.dir} -quiet -wsdl ${wsdl.source.dir}/doclitbare.wsdl"/>
</java>
- <echo>Generating java from greeterTypes.xsd</echo>
- <java classname="com.sun.tools.xjc.Driver" fork="true">
- <classpath refid="maven.runtime.classpath"/>
- <classpath location="${compiled.classes.dir}"/>
- <arg line="-d ${schema.generated.src.dir} -quiet ${schema.source.dir}/greeterTypes.xsd"/>
- </java>
+
<echo>Generating java from EchoMessage.wsdl for javabean endpoint
support
</echo>
@@ -334,6 +335,7 @@
<classpath location="${compiled.classes.dir}"/>
<arg line="-d ${schema.generated.src.dir} -quiet -wsdl ${wsdl.source.dir}/EchoMessage.wsdl"/>
</java>
+
<echo>Generating java from resourceinjection.wsdl for javabean
endpoint Resource Injection support
</echo>
@@ -883,6 +885,7 @@
/>
<delete dir="target/test-classes/servicejars/AddressBookService"/>
+
<copy toDir="target/test-classes/servicejars/AppleFinderService/">
<fileset dir="target/test-classes">
<include name="org/apache/axis2/jaxws/type_substitution/*"/>
Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/datasource/jaxb/JAXBDSContext.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/datasource/jaxb/JAXBDSContext.java?rev=675301&r1=675300&r2=675301&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/datasource/jaxb/JAXBDSContext.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/datasource/jaxb/JAXBDSContext.java Wed Jul 9 11:46:13 2008
@@ -86,7 +86,8 @@
// Please don't use "by java type" processing to get around errors.
private Class processType = null;
private boolean isxmlList =false;
- private String defaultNamespace;
+
+ private String webServiceNamespace;
/**
* Full Constructor JAXBDSContext (most performant)
@@ -162,12 +163,30 @@
Holder<JAXBUtils.CONSTRUCTION_TYPE> constructType =
new Holder<JAXBUtils.CONSTRUCTION_TYPE>();
Map<String, Object> properties = null;
- if (this.defaultNamespace != null) {
+
+ /*
+ * We set the default namespace to the web service namespace to fix an
+ * obscur bug.
+ *
+ * If the class representing a JAXB data object does not define a namespace
+ * (via an annotation like @XmlType or via ObjectFactory or schema gen information)
+ * then the namespace information is defaulted.
+ *
+ * The xjc tool defaults the namespace information to unqualified.
+ * However the wsimport tool defaults the namespace to the namespace of the
+ * webservice.
+ *
+ * To "workaround" this issue, a default namespace equal to the webservice
+ * namespace is set on the JAXB marshaller. This has the effect of changing the
+ * "unqualified namespaces" into the namespace used by the webservice.
+ *
+ */
+ if (this.webServiceNamespace != null) {
properties = new HashMap<String, Object>();
- properties.put("com.sun.xml.bind.defaultNamespaceRemap", this.defaultNamespace);
+ properties.put("com.sun.xml.bind.defaultNamespaceRemap", this.webServiceNamespace);
}
- jc =
- JAXBUtils.getJAXBContext(contextPackages, constructType, contextPackagesKey, cl, properties);
+ jc = JAXBUtils.getJAXBContext(contextPackages, constructType,
+ contextPackagesKey, cl, properties);
constructionType = constructType.value;
autoJAXBContext = new WeakReference<JAXBContext>(jc);
} else {
@@ -178,12 +197,8 @@
return jc;
}
- public void setDefaultNamespace(String namespace) {
- this.defaultNamespace = namespace;
- }
-
- public String getDefaultNamespace() {
- return this.defaultNamespace;
+ public void setWebServiceNamespace(String namespace) {
+ this.webServiceNamespace = namespace;
}
/** @return RPC Declared Type */
Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/DocLitWrappedMethodMarshaller.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/DocLitWrappedMethodMarshaller.java?rev=675301&r1=675300&r2=675301&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/DocLitWrappedMethodMarshaller.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/DocLitWrappedMethodMarshaller.java Wed Jul 9 11:46:13 2008
@@ -108,7 +108,7 @@
// In usage=WRAPPED, there will be a single JAXB block inside the body.
// Get this block
JAXBBlockContext blockContext = new JAXBBlockContext(packages, packagesKey);
- blockContext.setDefaultNamespace(ed.getTargetNamespace());
+ blockContext.setWebServiceNamespace(ed.getTargetNamespace());
JAXBBlockFactory factory =
(JAXBBlockFactory)FactoryRegistry.getFactory(JAXBBlockFactory.class);
Block block = message.getBodyBlock(blockContext, factory);
@@ -227,7 +227,7 @@
// In usage=WRAPPED, there will be a single JAXB block inside the body.
// Get this block
JAXBBlockContext blockContext = new JAXBBlockContext(packages, packagesKey);
- blockContext.setDefaultNamespace(ed.getTargetNamespace());
+ blockContext.setWebServiceNamespace(ed.getTargetNamespace());
JAXBBlockFactory factory =
(JAXBBlockFactory)FactoryRegistry.getFactory(JAXBBlockFactory.class);
Block block = message.getBodyBlock(blockContext, factory);
@@ -392,7 +392,7 @@
JAXBBlockFactory factory =
(JAXBBlockFactory)FactoryRegistry.getFactory(JAXBBlockFactory.class);
JAXBBlockContext blockContext = new JAXBBlockContext(packages, packagesKey);
- blockContext.setDefaultNamespace(ed.getTargetNamespace());
+ blockContext.setWebServiceNamespace(ed.getTargetNamespace());
Block block = factory.createFrom(object,
blockContext,
wrapperQName);
@@ -493,7 +493,7 @@
JAXBBlockFactory factory =
(JAXBBlockFactory)FactoryRegistry.getFactory(JAXBBlockFactory.class);
JAXBBlockContext blockContext = new JAXBBlockContext(packages, packagesKey);
- blockContext.setDefaultNamespace(ed.getTargetNamespace());
+ blockContext.setWebServiceNamespace(ed.getTargetNamespace());
Block block = factory.createFrom(object,
blockContext,
wrapperQName);
Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/DocLitWrappedPlusMethodMarshaller.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/DocLitWrappedPlusMethodMarshaller.java?rev=675301&r1=675300&r2=675301&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/DocLitWrappedPlusMethodMarshaller.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/DocLitWrappedPlusMethodMarshaller.java Wed Jul 9 11:46:13 2008
@@ -149,7 +149,7 @@
// In usage=WRAPPED, there will be a single JAXB block inside the body.
// Get this block
JAXBBlockContext blockContext = new JAXBBlockContext(packages, packagesKey);
- blockContext.setDefaultNamespace(ed.getTargetNamespace());
+ blockContext.setWebServiceNamespace(ed.getTargetNamespace());
JAXBBlockFactory factory =
(JAXBBlockFactory)FactoryRegistry.getFactory(JAXBBlockFactory.class);
Block block = message.getBodyBlock(blockContext, factory);
@@ -312,7 +312,7 @@
// In usage=WRAPPED, there will be a single JAXB block inside the body.
// Get this block
JAXBBlockContext blockContext = new JAXBBlockContext(packages, packagesKey);
- blockContext.setDefaultNamespace(ed.getTargetNamespace());
+ blockContext.setWebServiceNamespace(ed.getTargetNamespace());
JAXBBlockFactory factory =
(JAXBBlockFactory)FactoryRegistry.getFactory(JAXBBlockFactory.class);
Block block = message.getBodyBlock(blockContext, factory);
@@ -548,7 +548,7 @@
JAXBBlockFactory factory =
(JAXBBlockFactory)FactoryRegistry.getFactory(JAXBBlockFactory.class);
JAXBBlockContext blockContext = new JAXBBlockContext(packages, packagesKey);
- blockContext.setDefaultNamespace(ed.getTargetNamespace());
+ blockContext.setWebServiceNamespace(ed.getTargetNamespace());
Block block = factory.createFrom(object,
blockContext,
wrapperQName); // The factory will get the qname from the value
@@ -677,7 +677,7 @@
JAXBBlockFactory factory =
(JAXBBlockFactory)FactoryRegistry.getFactory(JAXBBlockFactory.class);
JAXBBlockContext blockContext = new JAXBBlockContext(packages, packagesKey);
- blockContext.setDefaultNamespace(ed.getTargetNamespace());
+ blockContext.setWebServiceNamespace(ed.getTargetNamespace());
Block block = factory.createFrom(object,
blockContext,
wrapperQName); // The factory will get the qname from the value