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 2007/01/27 14:58:11 UTC
svn commit: r500532 [2/2] - in /webservices/axis2/trunk/java/modules:
jaxws/src/org/apache/axis2/jaxws/
jaxws/src/org/apache/axis2/jaxws/marshaller/factory/
jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/
jaxws/src/org/apache/axis2/jaxws/message/...
Modified: webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/sample/ParallelAsyncTests.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/sample/ParallelAsyncTests.java?view=diff&rev=500532&r1=500531&r2=500532
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/sample/ParallelAsyncTests.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/sample/ParallelAsyncTests.java Sat Jan 27 05:58:08 2007
@@ -12,6 +12,7 @@
import junit.framework.TestSuite;
import org.apache.axis2.jaxws.sample.parallelasync.server.AsyncPort;
import org.apache.axis2.jaxws.sample.parallelasync.server.AsyncService;
+import org.apache.log4j.BasicConfigurator;
import org.test.parallelasync.CustomAsyncResponse;
import org.test.parallelasync.SleepResponse;
@@ -26,6 +27,7 @@
private static final String DOCLITWR_ASYNC_ENDPOINT =
"http://localhost:8080/axis2/services/AsyncService";
+
public ParallelAsyncTests(String str) {
super(str);
}
@@ -47,7 +49,7 @@
* @wsdl async.wsdl + async.xml
* @target AsyncPortImpl
*/
- public void _testService_isAlive() throws Exception {
+ public void testService_isAlive() throws Exception {
final String MESSAGE = "testServiceAlive";
AsyncPort port = getPort(null);
@@ -56,6 +58,7 @@
String req2 = "remappedAsync";
for (int i = 0; i < 10; i++) {
+
Response<SleepResponse> resp1 = port.sleepAsync(req1);
Response<CustomAsyncResponse> resp2 = port.remappedAsync(req2);
@@ -64,16 +67,28 @@
waitBlocking(resp1);
+ String req1_result = null;
+ String req2_result = null;
try {
- String req1_result = resp1.get().getMessage();
- String req2_result = resp2.get().getResponse();
+ req1_result = resp1.get().getMessage();
+ req2_result = resp2.get().getResponse();
} catch (Exception e) {
e.printStackTrace();
fail(e.toString());
}
- assertEquals("sleepAsync did not return expected response ", req1, resp1.get().getMessage());
- assertEquals("remappedAsync did not return expected response", req2, resp2.get().getResponse());
+ assertEquals("sleepAsync did not return expected response ", req1, req1_result);
+ assertEquals("remappedAsync did not return expected response", req2, req2_result);
+
+ // TODO The following two asserts fail because calling get() a second time causes the an attempt to consume a message a second time.
+ // Since the message has already been read, this fails.
+ // Shouldn't the AsyncResponse cache the object until the messageContext changes
+ //assertEquals("sleepAsync did not return expected response ", req1, resp1.get().getMessage());
+ //assertEquals("remappedAsync did not return expected response", req2, resp2.get().getResponse());
+
+ // Change the request for the next time through the loop
+ req1 = req1+"!";
+ req2 = req2+"!";
}
}
Modified: webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/sample/WrapTests.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/sample/WrapTests.java?view=diff&rev=500532&r1=500531&r2=500532
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/sample/WrapTests.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/sample/WrapTests.java Sat Jan 27 05:58:08 2007
@@ -126,4 +126,50 @@
fail();
}
}
+
+ /**
+ * This is a test of a doc/lit method that passes the
+ * request in a header. This can only be reproduced via
+ * annotations and WSGEN. WSImport will not allow this.
+ */
+ public void testEchoStringWSGEN1() {
+ System.out.println("------------------------------");
+ System.out.println("Test : "+getName());
+ try{
+ String request = "hello world";
+
+ DocLitWrapService service = new DocLitWrapService();
+ DocLitWrap proxy = service.getDocLitWrapPort();
+ String response = proxy.echoStringWSGEN1(request);
+ assertTrue(response.equals(request));
+ System.out.println("------------------------------");
+ }catch(Exception e){
+ e.printStackTrace();
+ fail();
+ }
+ }
+
+ /**
+ * This is a test of a doc/lit method that passes the
+ * response in a header. This can only be reproduced via
+ * annotations and WSGEN. WSImport will not allow this.
+ */
+
+ public void testEchoStringWSGEN2() {
+ System.out.println("------------------------------");
+ System.out.println("Test : "+getName());
+ try{
+ String request = "hello world 2";
+
+ DocLitWrapService service = new DocLitWrapService();
+ DocLitWrap proxy = service.getDocLitWrapPort();
+ String response = proxy.echoStringWSGEN2(request);
+ assertTrue(response.equals(request));
+ System.out.println("------------------------------");
+ }catch(Exception e){
+ e.printStackTrace();
+ fail();
+ }
+ }
+
}
Modified: webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/sample/wrap/DocLitWrapImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/sample/wrap/DocLitWrapImpl.java?view=diff&rev=500532&r1=500531&r2=500532
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/sample/wrap/DocLitWrapImpl.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/sample/wrap/DocLitWrapImpl.java Sat Jan 27 05:58:08 2007
@@ -84,4 +84,12 @@
return response;
}
+ public String echoStringWSGEN1(String headerValue) {
+ return headerValue;
+ }
+
+ public String echoStringWSGEN2(String data) {
+ return data;
+ }
+
}
Modified: webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/sample/wrap/META-INF/doclitwrap.wsdl
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/sample/wrap/META-INF/doclitwrap.wsdl?view=diff&rev=500532&r1=500531&r2=500532
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/sample/wrap/META-INF/doclitwrap.wsdl (original)
+++ webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/sample/wrap/META-INF/doclitwrap.wsdl Sat Jan 27 05:58:08 2007
@@ -12,6 +12,7 @@
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="MyFault" type="xsd:string" />
+ <xsd:element name="headerValue" type="xsd:string" />
<xsd:element name="oneWayVoid">
<xsd:complexType>
@@ -159,6 +160,31 @@
</xsd:sequence>
</xsd:complexType>
</xsd:element>
+
+ <xsd:element name="echoStringWSGEN1">
+ <xsd:complexType />
+ </xsd:element>
+
+ <xsd:element name="echoStringWSGEN1Response">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="return" type="xsd:string" />
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="echoStringWSGEN2">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="data" type="xsd:string" />
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="echoStringWSGEN2Response">
+ <xsd:complexType />
+ </xsd:element>
+
</xsd:schema>
</wsdl:types>
@@ -212,6 +238,26 @@
<wsdl:part name="payload" element="tns:headerResponse" />
<wsdl:part name="header0" element="tns:headerPart0" />
</wsdl:message>
+
+ <wsdl:message name="echoStringWSGEN1Request">
+ <wsdl:part name="bodyPart" element="tns:echoStringWSGEN1" />
+ <wsdl:part name="headerPart" element="tns:headerValue" />
+ </wsdl:message>
+
+ <wsdl:message name="echoStringWSGEN1Response">
+ <wsdl:part name="bodyPart" element="tns:echoStringWSGEN1Response" />
+ </wsdl:message>
+
+ <wsdl:message name="echoStringWSGEN2Request">
+ <wsdl:part name="bodyPart" element="tns:echoStringWSGEN2" />
+ </wsdl:message>
+
+ <wsdl:message name="echoStringWSGEN2Response">
+ <wsdl:part name="bodyPart" element="tns:echoStringWSGEN2Response" />
+ <wsdl:part name="headerPart" element="tns:headerValue" />
+ </wsdl:message>
+
+
<wsdl:portType name="DocLitWrap">
<wsdl:operation name="oneWayVoid">
@@ -245,6 +291,16 @@
<wsdl:input message="tns:finOpRequest" />
<wsdl:output message="tns:finOpResponse" />
</wsdl:operation>
+
+ <wsdl:operation name="echoStringWSGEN1">
+ <wsdl:input message="tns:echoStringWSGEN1Request" />
+ <wsdl:output message="tns:echoStringWSGEN1Response" />
+ </wsdl:operation>
+
+ <wsdl:operation name="echoStringWSGEN2">
+ <wsdl:input message="tns:echoStringWSGEN2Request" />
+ <wsdl:output message="tns:echoStringWSGEN2Response" />
+ </wsdl:operation>
</wsdl:portType>
@@ -329,6 +385,32 @@
<soap:body use="literal" />
</wsdl:output>
+ </wsdl:operation>
+
+ <wsdl:operation name="echoStringWSGEN1">
+ <soap:operation
+ soapAction="http://addheaders.sample.test.org/echoStringWSGEN1" />
+
+ <wsdl:input>
+ <soap:header use="literal" message="tns:echoStringWSGEN1Request" part="headerPart"/>
+ <soap:body use="literal" message="tns:echoStringWSGEN1Request" part="bodyPart"/>
+ </wsdl:input>
+ <wsdl:output>
+ <soap:body use="literal" />
+ </wsdl:output>
+ </wsdl:operation>
+
+ <wsdl:operation name="echoStringWSGEN2">
+ <soap:operation
+ soapAction="http://addheaders.sample.test.org/echoStringWSGEN2" />
+
+ <wsdl:input>
+ <soap:body use="literal" />
+ </wsdl:input>
+ <wsdl:output>
+ <soap:header use="literal" message="tns:echoStringWSGEN2Response" part="headerPart"/>
+ <soap:body use="literal" message="tns:echoStringWSGEN2Response" part="bodyPart"/>
+ </wsdl:output>
</wsdl:operation>
</wsdl:binding>
Modified: webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/sample/wrap/sei/DocLitWrap.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/sample/wrap/sei/DocLitWrap.java?view=diff&rev=500532&r1=500531&r2=500532
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/sample/wrap/sei/DocLitWrap.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/sample/wrap/sei/DocLitWrap.java Sat Jan 27 05:58:08 2007
@@ -122,6 +122,41 @@
Holder<HeaderPart0> header0,
@WebParam(name = "headerPart1", targetNamespace = "http://wrap.sample.test.org", header = true, partName = "header1")
HeaderPart1 header1);
+
+
+ /**
+ * The SOAPBinding for this method will default to wrapped. Yes Wrapped !
+ * However the parameter is a header parameter...which violates wrapped rules.
+ * Unfortunately WSGEN can produce this kind of situation...thus we need to
+ * handle it
+ * @param headerValue
+ * @return
+ * returns String
+ */
+ @WebMethod(action = "http://addheaders.sample.test.org/echoStringWSGEN1")
+ @RequestWrapper(localName = "echoStringWSGEN1", targetNamespace = "http://wrap.sample.test.org", className = "org.test.sample.wrap.EchoStringWSGEN1")
+ @ResponseWrapper(localName = "echoStringWSGEN1Response", targetNamespace = "http://wrap.sample.test.org", className = "org.test.sample.wrap.EchoStringWSGEN1Response")
+ public String echoStringWSGEN1(
+ @WebParam(name = "headerValue", targetNamespace = "http://wrap.sample.test.org", header = true)
+ String headerValue
+ );
+
+ /**
+ * The same as echoStringWSGEN1 except that the return String is in the header
+ * @param data
+ * @return
+ * returns String
+ */
+
+ @WebMethod(action = "http://addheaders.sample.test.org/echoStringWSGEN2")
+ @RequestWrapper(localName = "echoStringWSGEN2", targetNamespace = "http://wrap.sample.test.org", className = "org.test.sample.wrap.EchoStringWSGEN2")
+ @ResponseWrapper(localName = "echoStringWSGEN2Response", targetNamespace = "http://wrap.sample.test.org", className = "org.test.sample.wrap.EchoStringWSGEN2Response")
+ @WebResult(name = "headerValue", targetNamespace = "http://wrap.sample.test.org", header = true)
+ public String echoStringWSGEN2(
+ @WebParam(name = "data", targetNamespace = "")
+ String data
+ );
+
}
Modified: webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/util/JavaUtils.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/util/JavaUtils.java?view=diff&rev=500532&r1=500531&r2=500532
==============================================================================
--- webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/util/JavaUtils.java (original)
+++ webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/util/JavaUtils.java Sat Jan 27 05:58:08 2007
@@ -193,20 +193,28 @@
}
/**
- * Get a string containing the stack of the specified exception
+ * Get a string containing the stack of the current location
* @return String
*/
public static String stackToString(){
- Exception e = new RuntimeException();
+ return stackToString(new RuntimeException());
+ }
+
+ /**
+ * Get a string containing the stack of the specified exception
+ * @param e
+ * @return
+ */
+ public static String stackToString(Throwable e) {
java.io.StringWriter sw= new java.io.StringWriter();
java.io.BufferedWriter bw = new java.io.BufferedWriter(sw);
java.io.PrintWriter pw= new java.io.PrintWriter(bw);
e.printStackTrace(pw);
pw.close();
String text = sw.getBuffer().toString();
- // Jump past the "RuntimeException"
+ // Jump past the throwable
text = text.substring(text.indexOf("at"));
text = replace(text, "at ", "DEBUG_FRAME = ");
return text;
- }
+ }
}
Modified: webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/util/XMLRootElementUtil.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/util/XMLRootElementUtil.java?view=diff&rev=500532&r1=500531&r2=500532
==============================================================================
--- webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/util/XMLRootElementUtil.java (original)
+++ webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/util/XMLRootElementUtil.java Sat Jan 27 05:58:08 2007
@@ -20,6 +20,8 @@
import java.beans.Introspector;
import java.beans.PropertyDescriptor;
import java.lang.reflect.Field;
+import java.util.ArrayList;
+import java.util.List;
import java.util.Map;
import java.util.WeakHashMap;
@@ -28,6 +30,8 @@
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlSchema;
import javax.xml.namespace.QName;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
/**
* This utility contains code to determine if an Object is
@@ -73,6 +77,8 @@
*
*/
public class XMLRootElementUtil {
+
+ private static final Log log = LogFactory.getLog(XMLRootElementUtil.class);
/**
* Constructor is intentionally private. This class only provides static utility methods
@@ -200,16 +206,41 @@
*/
public static Map<String, PropertyDescriptor> createPropertyDescriptorMap(Class jaxbClass) throws NoSuchFieldException, IntrospectionException {
- // TODO This is a very performance intensive search we should cache the calculated map keyed by the jaxbClass
+ if (log.isDebugEnabled()) {
+ log.debug("Get the PropertyDescriptor[] for " + jaxbClass);
+ }
+ // TODO This is a very performance intensive search we should cache the calculated map keyed by the jaxbClass
PropertyDescriptor[] pds = Introspector.getBeanInfo(jaxbClass).getPropertyDescriptors();
- // Make this a weak map in case we want to cache the resolts
+ // Make this a weak map in case we want to cache the results
Map<String, PropertyDescriptor> map = new WeakHashMap<String, PropertyDescriptor>();
// Unfortunately the element names are stored on the fields.
- // Therefore we need to to match up the field and property descriptor
- Field[] fields = jaxbClass.getDeclaredFields();
+ // Get all of the fields in the class and super classes
+ List<Field> fields = new ArrayList<Field>();
+ Class cls = jaxbClass;
+ while(cls != null) {
+ Field[] fieldArray = cls.getDeclaredFields();
+ for (Field field:fieldArray) {
+ fields.add(field);
+ }
+ cls = cls.getSuperclass();
+ }
+
+ // Now match up the fields with the property descriptors...Sigh why didn't JAXB put the @XMLElement annotations on the
+ // property methods!
for(PropertyDescriptor pd:pds){
+
+ // Skip over the class property..it is never represented as an xml element
+ if (pd.getName().equals("class")) {
+ continue;
+ }
+
+ // For the current property, find a matching field...so that we can get the xml name
+ boolean found = false;
+ if (log.isDebugEnabled()) {
+ log.debug(" Start: Find xmlname for property:" + pd.getName());
+ }
for(Field field:fields){
String fieldName = field.getName();
@@ -217,7 +248,16 @@
if (fieldName.equalsIgnoreCase(pd.getDisplayName()) ||
fieldName.equalsIgnoreCase(pd.getName()) ) {
// Get the xmlElement name for this field
- String xmlName =getXmlElementName(jaxbClass, field);
+ String xmlName =getXmlElementName(field.getDeclaringClass(), field);
+ found = true;
+ if (log.isDebugEnabled()) {
+ log.debug(" Found field " + field.getName() + " which has xmlname=" + xmlName);
+ }
+ if (map.get(xmlName) != null) {
+ if (log.isDebugEnabled()) {
+ log.debug(" ALERT: property " + map.get(xmlName).getName() + " already has this same xmlName..this may cause problems.");
+ }
+ }
map.put(xmlName, pd);
break;
}
@@ -228,11 +268,37 @@
if (fieldName.equalsIgnoreCase(pd.getDisplayName()) ||
fieldName.equalsIgnoreCase(pd.getName())) {
// Get the xmlElement name for this field
- String xmlName =getXmlElementName(jaxbClass, field);
+ String xmlName =getXmlElementName(field.getDeclaringClass(), field);
+ found = true;
+ if (log.isDebugEnabled()) {
+ log.debug(" Found field " + field.getName() + " which has xmlname=" + xmlName);
+ }
+ if (map.get(xmlName) != null) {
+ if (log.isDebugEnabled()) {
+ log.debug(" ALERT: property " + map.get(xmlName).getName() + " already has this same xmlName..this may cause problems.");
+ }
+ }
map.put(xmlName, pd);
break;
}
}
+ }
+
+ // We didn't find a field. Default the xmlname to the property name
+ if (!found) {
+ String xmlName = pd.getName();
+ if (log.isDebugEnabled()) {
+ log.debug(" A matching field was not found. Defaulting xmlname to " + xmlName);
+ }
+ if (map.get(xmlName) != null) {
+ if (log.isDebugEnabled()) {
+ log.debug(" ALERT: property " + map.get(xmlName).getName() + " already has this same xmlName..this may cause problems.");
+ }
+ }
+ map.put(xmlName, pd);
+ }
+ if (log.isDebugEnabled()) {
+ log.debug(" End: Find xmlname for property:" + pd.getName());
}
}
return map;
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org