cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ningji...@apache.org
Subject svn commit: r468617 - in /incubator/cxf/trunk/rt/frontend/jaxws/src: main/java/org/apache/cxf/jaxws/DispatchImpl.java main/java/org/apache/cxf/jaxws/EndpointInvocationHandler.java test/java/org/apache/cxf/jaxws/JaxWsClientTest.java
Date Sat, 28 Oct 2006 02:30:51 GMT
Author: ningjiang
Date: Fri Oct 27 19:30:50 2006
New Revision: 468617

URL: http://svn.apache.org/viewvc?view=rev&rev=468617
Log:
put endpoint address to the requestContext  

Modified:
    incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/DispatchImpl.java
    incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/EndpointInvocationHandler.java
    incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/JaxWsClientTest.java

Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/DispatchImpl.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/DispatchImpl.java?view=diff&rev=468617&r1=468616&r2=468617
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/DispatchImpl.java
(original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/DispatchImpl.java
Fri Oct 27 19:30:50 2006
@@ -32,6 +32,7 @@
 
 import javax.xml.bind.JAXBContext;
 import javax.xml.ws.AsyncHandler;
+import javax.xml.ws.BindingProvider;
 import javax.xml.ws.Dispatch;
 import javax.xml.ws.Response;
 import javax.xml.ws.Service;
@@ -68,13 +69,13 @@
 
     private Endpoint endpoint;
 
-    DispatchImpl(Bus b, Service.Mode m, Class<T> clazz, Executor e, Endpoint ep) {
+    DispatchImpl(Bus b, Service.Mode m, Class<T> clazz, Executor e, Endpoint ep) {
       
         bus = b;
         cl = clazz;
         executor = e;
         mode = m;
-
         endpoint = ep;
+        setupEndpointAddressContext();
     }
 
     DispatchImpl(Bus b, Service.Mode m, JAXBContext ctx, Class<T> clazz, Executor e,
Endpoint ep) {
@@ -83,10 +84,19 @@
         context = ctx;
         cl = clazz;
         mode = m;
-
         endpoint = ep;
+        setupEndpointAddressContext();
     }
 
+    private void setupEndpointAddressContext() {
+        //NOTE for jms transport the address would be null
+        if (null != endpoint
+            && null != endpoint.getEndpointInfo().getAddress()) {
+            Map<String, Object> requestContext = this.getRequestContext();
+            requestContext.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
+                           endpoint.getEndpointInfo().getAddress());
+        }    
+    }
     public T invoke(T obj) {
         return invoke(obj, false);
     }

Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/EndpointInvocationHandler.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/EndpointInvocationHandler.java?view=diff&rev=468617&r1=468616&r2=468617
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/EndpointInvocationHandler.java
(original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/EndpointInvocationHandler.java
Fri Oct 27 19:30:50 2006
@@ -57,6 +57,17 @@
         super(b);
         endpoint = c.getEndpoint();
         client = c;
+        setupEndpointAddressContext();
+    }
+    
+    private void setupEndpointAddressContext() {
+        //NOTE for jms transport the address would be null
+        if (null != endpoint 
+            && null != endpoint.getEndpointInfo().getAddress()) {
+            Map<String, Object> requestContext = this.getRequestContext();
+            requestContext.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
+                           endpoint.getEndpointInfo().getAddress());
+        }    
     }
 
     public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {

Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/JaxWsClientTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/JaxWsClientTest.java?view=diff&rev=468617&r1=468616&r2=468617
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/JaxWsClientTest.java
(original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/JaxWsClientTest.java
Fri Oct 27 19:30:50 2006
@@ -22,10 +22,14 @@
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Proxy;
 import java.net.URL;
+import java.util.Map;
 import java.util.ResourceBundle;
 
 import javax.xml.namespace.QName;
+import javax.xml.ws.BindingProvider;
 
 import org.apache.cxf.endpoint.ClientImpl;
 import org.apache.cxf.interceptor.Fault;
@@ -43,18 +47,23 @@
 import org.apache.cxf.transport.Destination;
 import org.apache.cxf.transport.MessageObserver;
 import org.apache.hello_world_soap_http.BadRecordLitFault;
+import org.apache.hello_world_soap_http.Greeter;
 import org.apache.hello_world_soap_http.GreeterImpl;
 
 public class JaxWsClientTest extends AbstractJaxWsTest {
 
     static String responseMessage;
-
+    private final QName serviceName = new QName("http://apache.org/hello_world_soap_http",
+                    "SOAPService");    
+    private final QName portName = new QName("http://apache.org/hello_world_soap_http",
+                    "SoapPort");
+    private final String address = "http://localhost:9000/SoapContext/SoapPort";
     @Override
     public void setUp() throws Exception {
         super.setUp();
 
         EndpointInfo ei = new EndpointInfo(null, "http://schemas.xmlsoap.org/soap/http");
-        ei.setAddress("http://localhost:9000/SoapContext/SoapPort");
+        ei.setAddress(address);
 
         Destination d = localTransport.getDestination(ei);
         d.setMessageObserver(new EchoObserver());
@@ -64,12 +73,32 @@
         javax.xml.ws.Service s = javax.xml.ws.Service
             .create(new QName("http://apache.org/hello_world_soap_http", "SoapPort"));
         assertNotNull(s);
-
+        
         try {
             s = javax.xml.ws.Service.create(new URL("file:/does/not/exist.wsdl"),
                                             new QName("http://apache.org/hello_world_soap_http",
"SoapPort"));
         } catch (ServiceConstructionException sce) {
             // ignore, this is expected
+        }
+    }
+    
+    public void testRequestContext() throws Exception {
+        javax.xml.ws.Service s = javax.xml.ws.Service
+        .create(serviceName);
+        Greeter greeter = s.getPort(portName, Greeter.class);
+        InvocationHandler handler  = Proxy.getInvocationHandler(greeter);
+        BindingProvider  bp = null;
+        
+        if (handler instanceof BindingProvider) {
+            bp = (BindingProvider)handler;
+            //System.out.println(bp.toString());
+            Map<String, Object> requestContext = bp.getRequestContext();
+            String reqAddr = 
+                (String)requestContext.get(BindingProvider.ENDPOINT_ADDRESS_PROPERTY);
+            assertEquals("the address get from requestContext is not equal",
+                         reqAddr, address);
+        } else {
+            fail("can't get the requset context");
         }
     }
 



Mime
View raw message