You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by jl...@apache.org on 2007/11/28 10:31:58 UTC
svn commit: r598926 - in /incubator/cxf/trunk/rt/frontend/jaxws/src:
main/java/org/apache/cxf/jaxws/JaxWsClientProxy.java
main/java/org/apache/cxf/jaxws/spi/ProviderImpl.java
test/java/org/apache/cxf/jaxws/EndpointReferenceTest.java
Author: jliu
Date: Wed Nov 28 01:31:58 2007
New Revision: 598926
URL: http://svn.apache.org/viewvc?rev=598926&view=rev
Log:
Support JAX-WS 2.1 BindingProvider.getEndpointReference()
Modified:
incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxWsClientProxy.java
incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/spi/ProviderImpl.java
incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/EndpointReferenceTest.java
Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxWsClientProxy.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxWsClientProxy.java?rev=598926&r1=598925&r2=598926&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxWsClientProxy.java (original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxWsClientProxy.java Wed Nov 28 01:31:58 2007
@@ -20,6 +20,7 @@
package org.apache.cxf.jaxws;
import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.net.HttpURLConnection;
import java.util.HashMap;
@@ -41,6 +42,7 @@
import javax.xml.ws.http.HTTPException;
import javax.xml.ws.soap.SOAPBinding;
import javax.xml.ws.soap.SOAPFaultException;
+import javax.xml.ws.wsaddressing.W3CEndpointReferenceBuilder;
import org.w3c.dom.Node;
@@ -94,7 +96,11 @@
if (method.getDeclaringClass().equals(BindingProvider.class)
|| method.getDeclaringClass().equals(BindingProviderImpl.class)
|| method.getDeclaringClass().equals(Object.class)) {
- return method.invoke(this);
+ try {
+ return method.invoke(this);
+ } catch (InvocationTargetException e) {
+ throw e.fillInStackTrace().getCause();
+ }
}
Message msg = new Message("NO_OPERATION_INFO", LOG, method.getName());
@@ -249,9 +255,24 @@
return binding;
}
- // TODO JAX-WS 2.1
public EndpointReference getEndpointReference() {
- throw new UnsupportedOperationException();
+ String bindingId = getBinding().getBindingID();
+ if (!"http://schemas.xmlsoap.org/soap/".equals(bindingId)) {
+ throw new UnsupportedOperationException(new Message("GET_ENDPOINTREFERENCE_UNSUPPORTED_BINDING",
+ LOG).toString());
+ }
+
+ W3CEndpointReferenceBuilder builder = new W3CEndpointReferenceBuilder();
+
+ Endpoint endpoint = getClient().getEndpoint();
+ builder.address(endpoint.getEndpointInfo().getAddress());
+ builder.serviceName(endpoint.getService().getName());
+ builder.endpointName(endpoint.getEndpointInfo().getName());
+
+ //TODO: get wsdlDocumentLocation
+ //builder.wsdlDocumentLocation(endpoint.getService().getServiceInfos().toString());
+
+ return builder.build();
}
public <T extends EndpointReference> T getEndpointReference(Class<T> clazz) {
Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/spi/ProviderImpl.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/spi/ProviderImpl.java?rev=598926&r1=598925&r2=598926&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/spi/ProviderImpl.java (original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/spi/ProviderImpl.java Wed Nov 28 01:31:58 2007
@@ -116,7 +116,9 @@
}
writer.writeStartElement("wsa", "Address", W3C_NS);
- writer.writeCharacters(address);
+ if (address != null) {
+ writer.writeCharacters(address);
+ }
writer.writeEndElement();
writer.writeStartElement("wsa", "portName", W3C_NS);
@@ -138,6 +140,8 @@
StaxUtils.writeElement(meta, writer, true);
}
}
+
+ //TODO: Write wsdlDocumentLocation
writer.writeEndElement();
writer.flush();
Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/EndpointReferenceTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/EndpointReferenceTest.java?rev=598926&r1=598925&r2=598926&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/EndpointReferenceTest.java (original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/EndpointReferenceTest.java Wed Nov 28 01:31:58 2007
@@ -66,7 +66,6 @@
}
@Test
- @Ignore("Not implemented yet")
public void testBindingProviderSOAPBinding() throws Exception {
javax.xml.ws.Service s = javax.xml.ws.Service
.create(new QName("http://apache.org/hello_world_soap_http", "SoapPort"));
@@ -82,24 +81,37 @@
//1.2/HTTP, then a W3CEndpointReference MUST be returned.
assertTrue(er instanceof W3CEndpointReference);
}
-
+
@Test
- @Ignore("Not implemented yet")
- public void testBindingProviderXMLBinding() throws Exception {
- javax.xml.ws.Service s = javax.xml.ws.Service
- .create(new QName("http://apache.org/hello_world_soap_http", "SoapPort"));
- assertNotNull(s);
+ public void testBindingProviderSOAPBindingStaicService() throws Exception {
+ org.apache.hello_world_soap_http.SOAPService s = new org.apache.hello_world_soap_http.SOAPService();
Greeter greeter = s.getPort(Greeter.class);
BindingProvider bindingProvider = (BindingProvider)greeter;
+ EndpointReference er = bindingProvider.getEndpointReference();
+ assertNotNull(er);
+
+ //If the BindingProvider instance has a binding that is either SOAP 1.1/HTTP or SOAP
+ //1.2/HTTP, then a W3CEndpointReference MUST be returned.
+ assertTrue(er instanceof W3CEndpointReference);
+ }
+
+ @Test
+ public void testBindingProviderXMLBindingStaticService() throws Exception {
+ org.apache.hello_world_xml_http.bare.XMLService s =
+ new org.apache.hello_world_xml_http.bare.XMLService();
+
+ org.apache.hello_world_xml_http.bare.Greeter greeter = s.getXMLPort();
+ BindingProvider bindingProvider = (BindingProvider)greeter;
+
//If the binding is XML/HTTP an java.lang.UnsupportedOperationException MUST be thrown.
try {
bindingProvider.getEndpointReference();
fail("Did not get expected UnsupportedOperationException");
} catch (UnsupportedOperationException e) {
- // do nothing
- }
+ //do nothing
+ }
}
/*