Author: richard.opalka(a)jboss.com
Date: 2010-05-27 06:24:59 -0400 (Thu, 27 May 2010)
New Revision: 12354
Modified:
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/CommonBindingProvider.java
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxws/spi/ServiceDelegateImpl.java
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/metadata/builder/jaxws/JAXWSClientMetaDataBuilder.java
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/metadata/umdm/EndpointMetaData.java
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/tools/wsdl/WSDL11Reader.java
Log:
[JBWS-3041] implemented support for EPR specified in WSDL
Modified:
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/CommonBindingProvider.java
===================================================================
---
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/CommonBindingProvider.java 2010-05-27
10:19:44 UTC (rev 12353)
+++
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/CommonBindingProvider.java 2010-05-27
10:24:59 UTC (rev 12354)
@@ -129,18 +129,20 @@
{
throw new UnsupportedOperationException("Cannot get epr for BindingProvider
instances using the XML/HTTP binding");
}
- W3CEndpointReferenceBuilder builder = new W3CEndpointReferenceBuilder();
- if (epMetaData != null)
+ if (epMetaData == null)
+ throw new IllegalStateException("Cannot get endpoint reference info from
endpoint metadata!");
+
+ if (epMetaData.getEndpointReference() != null)
{
- builder.address(epMetaData.getEndpointAddress());
- builder.serviceName(epMetaData.getServiceMetaData().getServiceName());
- builder.endpointName(epMetaData.getPortName());
- builder.wsdlDocumentLocation(epMetaData.getEndpointAddress() +
"?wsdl");
+ return EndpointReferenceUtil.transform(clazz,
epMetaData.getEndpointReference());
}
- else
- {
- log.warn("Cannot get endpoint reference info from endpoint
metadata!");
- }
+
+ W3CEndpointReferenceBuilder builder = new W3CEndpointReferenceBuilder();
+ builder.address(epMetaData.getEndpointAddress());
+ builder.serviceName(epMetaData.getServiceMetaData().getServiceName());
+ builder.endpointName(epMetaData.getPortName());
+ builder.wsdlDocumentLocation(epMetaData.getEndpointAddress() + "?wsdl");
+
return EndpointReferenceUtil.transform(clazz, builder.build());
}
Modified:
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxws/spi/ServiceDelegateImpl.java
===================================================================
---
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxws/spi/ServiceDelegateImpl.java 2010-05-27
10:19:44 UTC (rev 12353)
+++
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxws/spi/ServiceDelegateImpl.java 2010-05-27
10:24:59 UTC (rev 12354)
@@ -235,7 +235,12 @@
}
}
- T port = (T)createProxy(seiClass, epMetaData);
+ T port = (T)createProxy(seiClass, epMetaData);
+ EndpointReference epr = epMetaData.getEndpointReference();
+ if (epr != null)
+ {
+ initAddressingProperties((BindingProvider)port, epr);
+ }
initWebserviceFeatures(port, epMetaData.getFeatures().getFeatures());
return port;
}
Modified:
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/metadata/builder/jaxws/JAXWSClientMetaDataBuilder.java
===================================================================
---
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/metadata/builder/jaxws/JAXWSClientMetaDataBuilder.java 2010-05-27
10:19:44 UTC (rev 12353)
+++
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/metadata/builder/jaxws/JAXWSClientMetaDataBuilder.java 2010-05-27
10:24:59 UTC (rev 12354)
@@ -23,30 +23,32 @@
import java.io.IOException;
import java.net.URL;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
import javax.jws.soap.SOAPBinding;
import javax.xml.namespace.QName;
+import javax.xml.transform.dom.DOMSource;
import javax.xml.ws.BindingType;
+import javax.xml.ws.EndpointReference;
+import javax.xml.ws.wsaddressing.W3CEndpointReference;
import org.jboss.ws.Constants;
import org.jboss.ws.WSException;
+import org.jboss.ws.annotation.EndpointConfig;
import org.jboss.ws.core.jaxws.client.ServiceObjectFactoryJAXWS;
-import org.jboss.ws.core.soap.Style;
import org.jboss.ws.extensions.policy.metadata.PolicyMetaDataBuilder;
import org.jboss.ws.extensions.wsrm.common.RMHelper;
import org.jboss.ws.metadata.umdm.ClientEndpointMetaData;
import org.jboss.ws.metadata.umdm.EndpointMetaData;
-import org.jboss.ws.metadata.umdm.OperationMetaData;
import org.jboss.ws.metadata.umdm.ServiceMetaData;
import org.jboss.ws.metadata.umdm.UnifiedMetaData;
import org.jboss.ws.metadata.umdm.EndpointMetaData.Type;
import org.jboss.ws.metadata.wsdl.WSDLBinding;
-import org.jboss.ws.metadata.wsdl.WSDLBindingOperation;
import org.jboss.ws.metadata.wsdl.WSDLDefinitions;
import org.jboss.ws.metadata.wsdl.WSDLEndpoint;
-import org.jboss.ws.metadata.wsdl.WSDLInterface;
-import org.jboss.ws.metadata.wsdl.WSDLInterfaceOperation;
+import org.jboss.ws.metadata.wsdl.WSDLExtensibilityElement;
import org.jboss.ws.metadata.wsdl.WSDLService;
import org.jboss.ws.metadata.wsdl.WSDLUtils;
import org.jboss.ws.metadata.wsdl.xmlschema.JBossXSModel;
@@ -56,7 +58,7 @@
import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedPortComponentRefMetaData;
import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedServiceRefMetaData;
import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedStubPropertyMetaData;
-import org.jboss.ws.annotation.EndpointConfig;
+import org.w3c.dom.Element;
/**
* A client side meta data builder.
@@ -71,7 +73,8 @@
return this.buildMetaData(serviceName, wsdlURL, vfsRoot, null);
}
- public ServiceMetaData buildMetaData(QName serviceName, URL wsdlURL,
UnifiedVirtualFile vfsRoot, ClassLoader classLoader)
+ public ServiceMetaData buildMetaData(QName serviceName, URL wsdlURL,
UnifiedVirtualFile vfsRoot,
+ ClassLoader classLoader)
{
if (wsdlURL == null)
throw new IllegalArgumentException("Invalid wsdlURL: " + wsdlURL);
@@ -80,7 +83,9 @@
log.debug("START buildMetaData: [service=" + serviceName +
"]");
try
{
- UnifiedMetaData wsMetaData = classLoader != null ? new UnifiedMetaData(vfsRoot,
classLoader) : new UnifiedMetaData(vfsRoot);
+ UnifiedMetaData wsMetaData = classLoader != null
+ ? new UnifiedMetaData(vfsRoot, classLoader)
+ : new UnifiedMetaData(vfsRoot);
ServiceMetaData serviceMetaData = new ServiceMetaData(wsMetaData, serviceName);
wsMetaData.addService(serviceMetaData);
@@ -90,13 +95,14 @@
buildMetaDataInternal(serviceMetaData, wsdlDefinitions);
- //Setup policies for each endpoint
+ //Setup policies and EPRs for each endpoint
for (EndpointMetaData epMetaData : serviceMetaData.getEndpoints())
{
PolicyMetaDataBuilder policyBuilder =
PolicyMetaDataBuilder.getClientSidePolicyMetaDataBuilder();
policyBuilder.processPolicyExtensions(epMetaData, wsdlDefinitions);
+ processEPRs(epMetaData, wsdlDefinitions);
}
-
+
// Read the WSDL and initialize the schema model
// This should only be needed for debuging purposes of the UMDM
JBossXSModel schemaModel =
WSDLUtils.getSchemaModel(wsdlDefinitions.getWsdlTypes());
@@ -116,6 +122,29 @@
}
}
+ private void processEPRs(EndpointMetaData endpointMD, WSDLDefinitions
wsdlDefinitions)
+ {
+ WSDLService wsdlService =
wsdlDefinitions.getService(endpointMD.getServiceMetaData().getServiceName());
+ if (wsdlService != null)
+ {
+ WSDLEndpoint wsdlEndpoint = wsdlService.getEndpoint(endpointMD.getPortName());
+ if (wsdlEndpoint != null)
+ {
+ List<WSDLExtensibilityElement> portEPRs =
wsdlEndpoint.getExtensibilityElements(Constants.WSDL_ELEMENT_EPR);
+ if (portEPRs != null && portEPRs.size() != 0)
+ {
+ if (portEPRs.size() > 1)
+ throw new IllegalStateException("Only one EPR can be specified on
port");
+
+ Element eprElement = portEPRs.get(0).getElement();
+ DOMSource eprInfoset = new DOMSource(eprElement);
+ EndpointReference epr = W3CEndpointReference.readFrom(eprInfoset);
+ endpointMD.setEndpointReference(epr);
+ }
+ }
+ }
+ }
+
/** Build from WSDL and service name
*/
public ServiceMetaData buildMetaData(QName serviceName, URL wsdlURL)
@@ -123,7 +152,8 @@
return buildMetaData(serviceName, wsdlURL, new ResourceLoaderAdapter());
}
- private void buildMetaDataInternal(ServiceMetaData serviceMetaData, WSDLDefinitions
wsdlDefinitions) throws IOException
+ private void buildMetaDataInternal(ServiceMetaData serviceMetaData, WSDLDefinitions
wsdlDefinitions)
+ throws IOException
{
QName serviceName = serviceMetaData.getServiceName();
@@ -146,7 +176,7 @@
List<QName> serviceNames = new ArrayList<QName>();
for (WSDLService wsdls : wsdlDefinitions.getServices())
serviceNames.add(wsdls.getName());
-
+
throw new IllegalArgumentException("Cannot obtain wsdl service: " +
serviceName + " we have " + serviceNames);
}
@@ -161,7 +191,8 @@
{
QName portName = wsdlEndpoint.getName();
QName interfaceQName = wsdlEndpoint.getInterface().getName();
- ClientEndpointMetaData epMetaData = new
ClientEndpointMetaData(serviceMetaData, portName, interfaceQName, Type.JAXWS);
+ ClientEndpointMetaData epMetaData = new
ClientEndpointMetaData(serviceMetaData, portName, interfaceQName,
+ Type.JAXWS);
epMetaData.setEndpointAddress(wsdlEndpoint.getAddress());
serviceMetaData.addEndpoint(epMetaData);
@@ -188,9 +219,9 @@
{
UnifiedServiceRefMetaData serviceRefMetaData =
ServiceObjectFactoryJAXWS.getServiceRefAssociation();
- if(serviceRefMetaData!=null)
+ if (serviceRefMetaData != null)
{
- for(UnifiedPortComponentRefMetaData portComp :
serviceRefMetaData.getPortComponentRefs())
+ for (UnifiedPortComponentRefMetaData portComp :
serviceRefMetaData.getPortComponentRefs())
{
epMetaData.getServiceRefContrib().add(portComp);
}
@@ -206,37 +237,37 @@
Iterator<UnifiedPortComponentRefMetaData> it =
epMetaData.getServiceRefContrib().iterator();
- while(it.hasNext())
+ while (it.hasNext())
{
UnifiedPortComponentRefMetaData portComp = it.next();
- if(epMetaData.matches(portComp))
+ if (epMetaData.matches(portComp))
{
if (log.isDebugEnabled())
- log.debug("Processing service-ref contribution on portType:
"+epMetaData.getPortTypeName());
+ log.debug("Processing service-ref contribution on portType: " +
epMetaData.getPortTypeName());
// process MTOM overrides
- if(portComp.getEnableMTOM())
+ if (portComp.getEnableMTOM())
{
String bindingId = epMetaData.getBindingId();
- if(bindingId.equals(Constants.SOAP11HTTP_BINDING))
+ if (bindingId.equals(Constants.SOAP11HTTP_BINDING))
epMetaData.setBindingId(Constants.SOAP11HTTP_MTOM_BINDING);
- else if(bindingId.equals(Constants.SOAP12HTTP_BINDING))
+ else if (bindingId.equals(Constants.SOAP12HTTP_BINDING))
epMetaData.setBindingId(Constants.SOAP12HTTP_MTOM_BINDING);
}
// process stub properties
- for(UnifiedStubPropertyMetaData stubProp: portComp.getStubProperties())
+ for (UnifiedStubPropertyMetaData stubProp : portComp.getStubProperties())
{
- epMetaData.getProperties().put(stubProp.getPropName(),
stubProp.getPropValue());
+ epMetaData.getProperties().put(stubProp.getPropName(),
stubProp.getPropValue());
}
// process call properties
- for(UnifiedCallPropertyMetaData callProp: portComp.getCallProperties())
+ for (UnifiedCallPropertyMetaData callProp : portComp.getCallProperties())
{
epMetaData.getProperties().put(callProp.getPropName(),
callProp.getPropValue());
}
-
+
}
}
@@ -245,7 +276,8 @@
public void rebuildEndpointMetaData(EndpointMetaData epMetaData, Class<?>
wsClass)
{
- if(log.isDebugEnabled()) log.debug("START: rebuildMetaData");
+ if (log.isDebugEnabled())
+ log.debug("START: rebuildMetaData");
// Clear the java types, etc.
resetMetaDataBuilder(epMetaData.getClassLoader());
@@ -267,7 +299,7 @@
// Process @WebMethod
processWebMethods(epMetaData, wsClass);
-
+
processXmlSeeAlso(wsClass);
// Initialize types
@@ -290,7 +322,8 @@
RMHelper.setupRMOperations(epMetaData);
}
- if(log.isDebugEnabled()) log.debug("END: rebuildMetaData\n" +
epMetaData.getServiceMetaData());
+ if (log.isDebugEnabled())
+ log.debug("END: rebuildMetaData\n" +
epMetaData.getServiceMetaData());
}
/**
@@ -299,7 +332,7 @@
* @param wsClass - the service endpoint interface
*/
private void processEndpointConfig(EndpointMetaData epMetaData, Class<?>
wsClass)
- {
+ {
if (wsClass.isAnnotationPresent(EndpointConfig.class))
{
EndpointConfig anConfig = wsClass.getAnnotation(EndpointConfig.class);
Modified:
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/metadata/umdm/EndpointMetaData.java
===================================================================
---
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/metadata/umdm/EndpointMetaData.java 2010-05-27
10:19:44 UTC (rev 12353)
+++
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/metadata/umdm/EndpointMetaData.java 2010-05-27
10:24:59 UTC (rev 12354)
@@ -43,6 +43,7 @@
import javax.xml.bind.annotation.XmlElementDecl;
import javax.xml.namespace.QName;
import javax.xml.rpc.ParameterMode;
+import javax.xml.ws.EndpointReference;
import javax.xml.ws.WebServiceFeature;
import javax.xml.ws.Service.Mode;
@@ -147,6 +148,8 @@
private FeatureSet features = new FeatureSet();
// The documentation edfined through the @Documentation annotation
private String documentation;
+
+ private EndpointReference epr;
private ConfigObservable configObservable = new ConfigObservable();
@@ -182,6 +185,16 @@
this.portName = portName;
}
+ public EndpointReference getEndpointReference()
+ {
+ return epr;
+ }
+
+ public void setEndpointReference(final EndpointReference epr)
+ {
+ this.epr = epr;
+ }
+
public QName getPortTypeName()
{
return portTypeName;
Modified:
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/tools/wsdl/WSDL11Reader.java
===================================================================
---
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/tools/wsdl/WSDL11Reader.java 2010-05-27
10:19:44 UTC (rev 12353)
+++
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/tools/wsdl/WSDL11Reader.java 2010-05-27
10:24:59 UTC (rev 12354)
@@ -319,7 +319,7 @@
UnknownExtensibilityElement uee = (UnknownExtensibilityElement)extElement;
boolean understood = false;
understood = understood || processPolicyElements(uee, dest);
- understood = understood || processUseAddressing(uee, dest);
+ understood = understood || processEPR(uee, dest);
//add processing of further extensibility element types below
if (!understood)
@@ -378,10 +378,25 @@
* @param dest
* @return
*/
- private boolean processUseAddressing(UnknownExtensibilityElement extElement,
Extendable dest)
+ private boolean processEPR(UnknownExtensibilityElement extElement, Extendable dest)
{
- log.warn("UsingAddressing extensibility element not supported yet.");
- return false;
+ final Element srcElement = extElement.getElement();
+ final boolean isWSANamespace =
AddressingConstants.Core.NS.equals(srcElement.getNamespaceURI());
+ final boolean isEPRLocalName =
AddressingConstants.Core.Elements.ENDPOINTREFERENCE.equals(srcElement.getLocalName());
+ boolean result = false;
+
+ if (isWSANamespace && isEPRLocalName)
+ {
+ Element element = (Element) srcElement.cloneNode(true);
+ copyMissingNamespaceDeclarations(element, srcElement);
+
+ WSDLExtensibilityElement el = new
WSDLExtensibilityElement(Constants.WSDL_ELEMENT_EPR, element);
+ el.setRequired(true);
+ dest.addExtensibilityElement(el);
+ result = true;
+ }
+
+ return result;
}
private void processNotUnderstoodExtesibilityElement(UnknownExtensibilityElement
extElement, Extendable dest)