cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ff...@apache.org
Subject svn commit: r538061 - /incubator/cxf/trunk/distribution/src/main/release/samples/handlers/src/demo/handlers/common/SmallNumberHandler.java
Date Tue, 15 May 2007 05:42:40 GMT
Author: ffang
Date: Mon May 14 22:42:39 2007
New Revision: 538061

URL: http://svn.apache.org/viewvc?view=rev&rev=538061
Log:
[CXF-651] get handlers sample work

Modified:
    incubator/cxf/trunk/distribution/src/main/release/samples/handlers/src/demo/handlers/common/SmallNumberHandler.java

Modified: incubator/cxf/trunk/distribution/src/main/release/samples/handlers/src/demo/handlers/common/SmallNumberHandler.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/distribution/src/main/release/samples/handlers/src/demo/handlers/common/SmallNumberHandler.java?view=diff&rev=538061&r1=538060&r2=538061
==============================================================================
--- incubator/cxf/trunk/distribution/src/main/release/samples/handlers/src/demo/handlers/common/SmallNumberHandler.java
(original)
+++ incubator/cxf/trunk/distribution/src/main/release/samples/handlers/src/demo/handlers/common/SmallNumberHandler.java
Mon May 14 22:42:39 2007
@@ -21,14 +21,18 @@
 
 import java.util.Map;
 import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBElement;
 import javax.xml.bind.JAXBException;
+import javax.xml.transform.Source;
 import javax.xml.ws.LogicalMessage;
 import javax.xml.ws.ProtocolException;
+import javax.xml.ws.WebServiceException;
 import javax.xml.ws.handler.LogicalHandler;
 import javax.xml.ws.handler.LogicalMessageContext;
 import javax.xml.ws.handler.MessageContext;
 import org.apache.handlers.types.AddNumbers;
 import org.apache.handlers.types.AddNumbersResponse;
+import org.apache.handlers.types.ObjectFactory;
 
 
 
@@ -53,8 +57,11 @@
 
                 // check the payload, if its an AddNumbers request, we'll intervene
                 //
-                JAXBContext jaxbContext = JAXBContext.newInstance(AddNumbers.class);
+                JAXBContext jaxbContext = JAXBContext.newInstance(ObjectFactory.class);
                 Object payload = msg.getPayload(jaxbContext);
+                if (payload instanceof JAXBElement) {
+                    payload = ((JAXBElement)payload).getValue();
+                }
 
                 if (payload instanceof AddNumbers) {
                     AddNumbers req = (AddNumbers)payload;
@@ -67,12 +74,27 @@
                     if (isSmall(a) && isSmall(b)) {
                         int answer = a + b;
 
-                        System.out.printf("SmallNumberHandler addNumbers(%d, %d) == %d\n",
a, b, answer);
+                        //System.out.printf("SmallNumberHandler addNumbers(%d, %d) == %d\n",
a, b, answer);
                         // ok, we've done the calculation, so build the
                         // response and set it as the payload of the message
+                        
                         AddNumbersResponse resp = new AddNumbersResponse();
                         resp.setReturn(answer);
-                        msg.setPayload(resp, jaxbContext);
+                        msg.setPayload(new ObjectFactory().createAddNumbersResponse(resp),
+                                       jaxbContext);
+                        
+                        Source src = msg.getPayload();                                  
          
+                        msg.setPayload(src);
+                        
+                        payload = msg.getPayload(jaxbContext);
+                        if (payload instanceof JAXBElement) {
+                            payload = ((JAXBElement)payload).getValue();
+                        }
+                        
+                        AddNumbersResponse resp2 = (AddNumbersResponse)payload;
+                        if (resp2 == resp) {
+                            throw new WebServiceException("Shouldn't be the same object");
+                        }
 
                         // finally, return false, indicating that request
                         // processing stops here and our answer will be



Mime
View raw message