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 2006/07/15 16:01:49 UTC

svn commit: r422221 - in /webservices/axis2/trunk/java/modules/jaxws: ./ src/org/apache/axis2/jaxws/wrapper/impl/ test-resources/xsd/ test/org/apache/axis2/jaxws/jaxb/mfquote/ test/org/apache/axis2/jaxws/jaxb/stockquote/ test/org/apache/axis2/jaxws/jax...

Author: scheu
Date: Sat Jul 15 07:01:49 2006
New Revision: 422221

URL: http://svn.apache.org/viewvc?rev=422221&view=rev
Log:
JIRA ISSUE AXIS2-898
Contributor: Rich Scheuerle

Added:
    webservices/axis2/trunk/java/modules/jaxws/test-resources/xsd/stock1.xsd
    webservices/axis2/trunk/java/modules/jaxws/test-resources/xsd/stock2.xsd
Removed:
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/jaxb/mfquote/GetPrice.java
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/jaxb/mfquote/ObjectFactory.java
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/jaxb/mfquote/StockPrice.java
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/jaxb/mfquote/package-info.java
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/jaxb/stockquote/GetPrice.java
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/jaxb/stockquote/ObjectFactory.java
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/jaxb/stockquote/StockPrice.java
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/jaxb/stockquote/package-info.java
Modified:
    webservices/axis2/trunk/java/modules/jaxws/maven.xml
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/wrapper/impl/JAXBWrapperToolImpl.java
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/jaxb/mfquote/StockQuoteIF.java
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/jaxb/stockquote/StockQuoteIF.java
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/jaxb/wrapper/WrapperToolTest.java

Modified: webservices/axis2/trunk/java/modules/jaxws/maven.xml
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/maven.xml?rev=422221&r1=422220&r2=422221&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/maven.xml (original)
+++ webservices/axis2/trunk/java/modules/jaxws/maven.xml Sat Jul 15 07:01:49 2006
@@ -42,7 +42,23 @@
         	<classpath location="${compiled.classes.dir}"/>
             <arg line="-d ${schema.generated.src.dir} -quiet ${schema.source.dir}/echo.xsd"/>
         </java>
+        <ant:echo>Generating java from stock1.xsd</ant:echo>
+        <java classname="com.sun.tools.xjc.Driver" fork="true"> 
+        	<jvmarg line="${maven.junit.jvmargs}"/>
+        	<classpath refid="maven.dependency.classpath"/>
+        	<classpath location="${compiled.classes.dir}"/>
+            <arg line="-d ${schema.generated.src.dir} -quiet ${schema.source.dir}/stock1.xsd"/>
+        </java>
+        <ant:echo>Generating java from stock2.xsd</ant:echo>
+        <java classname="com.sun.tools.xjc.Driver" fork="true"> 
+        	<jvmarg line="${maven.junit.jvmargs}"/>
+        	<classpath refid="maven.dependency.classpath"/>
+        	<classpath location="${compiled.classes.dir}"/>
+            <arg line="-d ${schema.generated.src.dir} -quiet ${schema.source.dir}/stock2.xsd"/>
+        </java>
+    	
 
+    	
        <!-- Compile the generated classes -->
     	<ant:echo>Compiling generated schema</ant:echo>
         <javac destdir="${schema.generated.classes.dir}" srcdir="${schema.generated.src.dir}">

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/wrapper/impl/JAXBWrapperToolImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/wrapper/impl/JAXBWrapperToolImpl.java?rev=422221&r1=422220&r2=422221&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/wrapper/impl/JAXBWrapperToolImpl.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/wrapper/impl/JAXBWrapperToolImpl.java Sat Jul 15 07:01:49 2006
@@ -201,9 +201,21 @@
 		return filteredPds;
 	}
 	
+	/**
+	 * Get the name of the xml element by looking at the XmlElement annotation.
+	 * @param jaxbClass
+	 * @param fieldName
+	 * @return
+	 * @throws NoSuchFieldException
+	 */
 	private String getXmlElementName(Class jaxbClass, String fieldName)throws NoSuchFieldException{
 		Field field = jaxbClass.getDeclaredField(fieldName);
 		XmlElement xmlElement =field.getAnnotation(XmlElement.class);
+		
+		// If XmlElement does not exist, default to using the field name
+		if (xmlElement == null) {
+			return fieldName;
+		}
 		return xmlElement.name();
 		
 	}

Added: webservices/axis2/trunk/java/modules/jaxws/test-resources/xsd/stock1.xsd
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/test-resources/xsd/stock1.xsd?rev=422221&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/test-resources/xsd/stock1.xsd (added)
+++ webservices/axis2/trunk/java/modules/jaxws/test-resources/xsd/stock1.xsd Sat Jul 15 07:01:49 2006
@@ -0,0 +1,28 @@
+<!-- This schema is used to generate the JAX-B artifacts for the JAXBWrapperTests -->
+<s:schema xmlns:s="http://www.w3.org/2001/XMLSchema"
+	targetNamespace="urn://stock1.test.org"
+	xmlns:tns="urn://stock1.test.org" >
+	<s:element name="getPrice" type="tns:getPrice" />
+	<s:complexType name="getPrice">
+      <s:complexContent>
+        <s:restriction base="s:anyType">
+          <s:sequence>
+            <s:element name="fund" type="s:string"/>
+            <s:element name="holdings." type="s:string"/>
+            <s:element name="nav" type="s:string"/>
+          </s:sequence>
+        </s:restriction>
+      </s:complexContent>
+    </s:complexType>
+    
+    <s:element name="getPriceResponse" type="tns:StockPrice" />
+	<s:complexType name="StockPrice">
+      <s:complexContent>
+        <s:restriction base="s:anyType">
+          <s:sequence>
+            <s:element name="price" type="s:string"/>
+          </s:sequence>
+        </s:restriction>
+      </s:complexContent>
+    </s:complexType>
+</s:schema>
\ No newline at end of file

Added: webservices/axis2/trunk/java/modules/jaxws/test-resources/xsd/stock2.xsd
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/test-resources/xsd/stock2.xsd?rev=422221&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/test-resources/xsd/stock2.xsd (added)
+++ webservices/axis2/trunk/java/modules/jaxws/test-resources/xsd/stock2.xsd Sat Jul 15 07:01:49 2006
@@ -0,0 +1,26 @@
+<!-- This schema is used to generate the JAX-B artifacts for the JAXBWrapperTests-->
+<s:schema xmlns:s="http://www.w3.org/2001/XMLSchema"
+	targetNamespace="urn://stock2.test.org"
+	xmlns:tns="urn://stock2.test.org" >
+	<s:element name="getPrice" type="tns:getPrice" />
+	<s:complexType name="getPrice">
+      <s:complexContent>
+        <s:restriction base="s:anyType">
+          <s:sequence>
+            <s:element name="symbol" type="s:string"/>
+          </s:sequence>
+        </s:restriction>
+      </s:complexContent>
+    </s:complexType>
+    
+    <s:element name="getPriceResponse" type="tns:StockPrice"/>
+	<s:complexType name="StockPrice">
+      <s:complexContent>
+        <s:restriction base="s:anyType">
+          <s:sequence>
+            <s:element name="price" type="s:string"/>
+          </s:sequence>
+        </s:restriction>
+      </s:complexContent>
+    </s:complexType>
+</s:schema>
\ No newline at end of file

Modified: webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/jaxb/mfquote/StockQuoteIF.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/jaxb/mfquote/StockQuoteIF.java?rev=422221&r1=422220&r2=422221&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/jaxb/mfquote/StockQuoteIF.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/jaxb/mfquote/StockQuoteIF.java Sat Jul 15 07:01:49 2006
@@ -29,8 +29,8 @@
      */
     @WebMethod(action = "http://tempuri.org/StockQuote/getPrice")
     @WebResult(name = "price", targetNamespace = "")
-    @RequestWrapper(localName = "getPrice", targetNamespace = "http://org/apache/axis2/jaxws/test", className = "org.apache.axis2.jaxws.jaxb.mfquote.GetPrice")
-    @ResponseWrapper(localName = "getPriceResponse", targetNamespace = "http://org/apache/axis2/jaxws/test", className = "org.apache.axis2.jaxws.jaxb.mfquote.StockPrice")
+    @RequestWrapper(localName = "getPrice", targetNamespace = "urn://stock1.test.org", className = "org.test.stock1.GetPrice")
+    @ResponseWrapper(localName = "getPriceResponse", targetNamespace = "urn://stock1.test.org", className = "org.test.stock1.StockPrice")
     public String getPrice(
         @WebParam(name = "fund", targetNamespace = "")
         String fund,

Modified: webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/jaxb/stockquote/StockQuoteIF.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/jaxb/stockquote/StockQuoteIF.java?rev=422221&r1=422220&r2=422221&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/jaxb/stockquote/StockQuoteIF.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/jaxb/stockquote/StockQuoteIF.java Sat Jul 15 07:01:49 2006
@@ -27,8 +27,8 @@
      */
     @WebMethod(action = "http://tempuri.org/StockQuote/getPrice")
     @WebResult(name = "price", targetNamespace = "")
-    @RequestWrapper(localName = "getPrice", targetNamespace = "http://org/apache/axis2/jaxws/test", className = "org.apache.axis2.jaxws.jaxb.stockquote.GetPrice")
-    @ResponseWrapper(localName = "getPriceResponse", targetNamespace = "http://org/apache/axis2/jaxws/test", className = "org.apache.axis2.jaxws.jaxb.stockquote.StockPrice")
+    @RequestWrapper(localName = "getPrice", targetNamespace = "urn://stock2.test.org", className = "org.test.stock2.GetPrice")
+    @ResponseWrapper(localName = "getPriceResponse", targetNamespace = "urn://stock2.test.org", className = "org.test.stock2.StockPrice")
     public String getPrice(
         @WebParam(name = "symbol", targetNamespace = "")
         String symbol);

Modified: webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/jaxb/wrapper/WrapperToolTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/jaxb/wrapper/WrapperToolTest.java?rev=422221&r1=422220&r2=422221&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/jaxb/wrapper/WrapperToolTest.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/jaxb/wrapper/WrapperToolTest.java Sat Jul 15 07:01:49 2006
@@ -21,7 +21,6 @@
 import java.util.Map;
 import java.util.WeakHashMap;
 
-import org.apache.axis2.jaxws.jaxb.stockquote.GetPrice;
 import org.apache.axis2.jaxws.wrapper.JAXBWrapperTool;
 import org.apache.axis2.jaxws.wrapper.impl.JAXBWrapperException;
 import org.apache.axis2.jaxws.wrapper.impl.JAXBWrapperToolImpl;
@@ -34,7 +33,7 @@
 		try{
 			JAXBWrapperTool wrapper = new JAXBWrapperToolImpl();
 			
-			String jaxbClassName = "org.apache.axis2.jaxws.jaxb.stockquote.GetPrice";
+			String jaxbClassName = "org.test.stock2.GetPrice";
 			Class jaxbClass = Class.forName(jaxbClassName, false, ClassLoader.getSystemClassLoader());
 			ArrayList<String> childNames = new ArrayList<String>();
 			String childName = "symbol";
@@ -43,7 +42,7 @@
 			Map<String, Object> childObjects= new WeakHashMap<String, Object>();
 			childObjects.put(childName, symbolObj);
 			Object jaxbObject = wrapper.wrap(jaxbClass, jaxbClassName,childNames, childObjects);
-			GetPrice getPrice = (GetPrice)jaxbObject;
+			org.test.stock2.GetPrice getPrice = (org.test.stock2.GetPrice)jaxbObject;
 			
 		}catch(JAXBWrapperException e){
 			e.printStackTrace();
@@ -55,7 +54,7 @@
 	public void testUnwrapStockQuote(){
 		try{
 			JAXBWrapperTool wrapper = new JAXBWrapperToolImpl();
-			GetPrice price = new GetPrice();
+			org.test.stock2.GetPrice price = new org.test.stock2.GetPrice();
 			price.setSymbol("IBM");
 			
 			ArrayList<String> childNames = new ArrayList<String>();
@@ -73,12 +72,12 @@
 		try{
 			JAXBWrapperTool wrapper = new JAXBWrapperToolImpl();
 			
-			String jaxbClassName = "org.apache.axis2.jaxws.jaxb.mfquote.GetPrice";
+			String jaxbClassName = "org.test.stock1.GetPrice";
 			Class jaxbClass = Class.forName(jaxbClassName, false, ClassLoader.getSystemClassLoader());
 			ArrayList<String> childNames = new ArrayList<String>();
 			String fund ="fund";
 			String fundName = new String("PRGFX");
-			String holding = "_10Holdings";
+			String holding = "holdings.";
 			String topHolding = new String("GE");
 			String nav ="nav";
 			String navInMillion = new String("700");
@@ -94,7 +93,7 @@
 			childObjects.put(nav, navInMillion);
 			
 			Object jaxbObject = wrapper.wrap(jaxbClass, jaxbClassName,childNames, childObjects);
-			org.apache.axis2.jaxws.jaxb.mfquote.GetPrice getPrice = (org.apache.axis2.jaxws.jaxb.mfquote.GetPrice)jaxbObject;
+			org.test.stock1.GetPrice getPrice = (org.test.stock1.GetPrice)jaxbObject;
 			
 		}catch(JAXBWrapperException e){
 			e.printStackTrace();
@@ -106,15 +105,15 @@
 	public void testUnwrapMFQuote(){
 		try{
 			JAXBWrapperTool wrapper = new JAXBWrapperToolImpl();
-			org.apache.axis2.jaxws.jaxb.mfquote.GetPrice price = new org.apache.axis2.jaxws.jaxb.mfquote.GetPrice();
+			org.test.stock1.GetPrice price = new org.test.stock1.GetPrice();
 			price.setFund("PRGFX");
-			price.set10Holdings("GE");
+			price.setHoldings("GE");
 			price.setNav("700");
 			
 			ArrayList<String> childNames = new ArrayList<String>();
 			String fund ="fund";
 			childNames.add(fund);
-			String holding = "_10Holdings";
+			String holding = "holdings.";
 			childNames.add(holding);
 			String nav ="nav";
 			childNames.add(nav);



---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org