Author: tho...@jb... Date: 2006-07-04 12:42:35 -0400 (Tue, 04 Jul 2006) New Revision: 553 Added: trunk/src/main/java/org/jboss/ws/client/ trunk/src/main/java/org/jboss/ws/client/CommonClient.java trunk/src/main/java/org/jboss/ws/deployment/JAXWSClientMetaDataBuilder.java trunk/src/main/java/org/jboss/ws/jaxws/client/ trunk/src/main/java/org/jboss/ws/jaxws/client/BindingImpl.java trunk/src/main/java/org/jboss/ws/jaxws/client/BindingProviderImpl.java trunk/src/main/java/org/jboss/ws/jaxws/client/JAXWSClient.java trunk/src/main/java/org/jboss/ws/jaxws/client/PortProxy.java trunk/src/main/java/org/jboss/ws/jaxws/spi/ trunk/src/main/java/org/jboss/ws/jaxws/spi/ProviderImpl.java trunk/src/main/java/org/jboss/ws/jaxws/spi/ServiceDelegateImpl.java trunk/src/main/java/org/jboss/ws/jaxws/util/ trunk/src/main/java/org/jboss/ws/jaxws/util/FactoryFinder.java Removed: trunk/src/test/resources/samples/jsr181ejb/META-INF/application-client.xml trunk/src/test/resources/samples/jsr181ejb/META-INF/jboss-client.xml trunk/src/test/resources/samples/jsr181ejb/wstools-config.xml trunk/src/test/resources/samples/jsr181pojo/META-INF/application-client.xml trunk/src/test/resources/samples/jsr181pojo/META-INF/jboss-client.xml trunk/src/test/resources/samples/jsr181pojo/wstools-config.xml Modified: trunk/src/main/java/javax/xml/ws/Service.java trunk/src/main/java/javax/xml/ws/spi/Provider.java trunk/src/main/java/org/jboss/ws/addressing/metadata/AddressingOpMetaExt.java trunk/src/main/java/org/jboss/ws/deployment/AbstractMetaDataBuilder.java trunk/src/main/java/org/jboss/ws/deployment/JSR109MetaDataBuilder.java trunk/src/main/java/org/jboss/ws/deployment/JSR181MetaDataBuilder.java trunk/src/main/java/org/jboss/ws/jaxrpc/CallImpl.java trunk/src/main/java/org/jboss/ws/metadata/MetaDataExtension.java trunk/src/main/java/org/jboss/ws/metadata/TypesMetaData.java trunk/src/main/java/org/jboss/ws/soap/SOAPConnectionImpl.java trunk/src/test/ant/build-jars.xml trunk/src/test/build.xml trunk/src/test/java/org/jboss/test/ws/jbws871/RpcArrayEndpointImpl.java trunk/src/test/java/org/jboss/test/ws/samples/jsr181ejb/JSR181WebServiceEJB3TestCase.java trunk/src/test/java/org/jboss/test/ws/samples/jsr181pojo/JSR181WebServiceJSETestCase.java Log: Implement javax.xml.ws.Service Modified: trunk/src/main/java/javax/xml/ws/Service.java =================================================================== --- trunk/src/main/java/javax/xml/ws/Service.java 2006-07-04 11:35:28 UTC (rev 552) +++ trunk/src/main/java/javax/xml/ws/Service.java 2006-07-04 16:42:35 UTC (rev 553) @@ -127,11 +127,17 @@ delegate.setExecutor(executor); } + /** + * Create a Service instance. The specified WSDL document location and service qualified name must uniquely identify a wsdl:service element. + */ public static Service create(URL wsdlDocumentLocation, QName serviceName) { return new Service(wsdlDocumentLocation, serviceName); } + /** + * Create a Service instance. + */ public static Service create(QName serviceName) { return new Service(null, serviceName); Modified: trunk/src/main/java/javax/xml/ws/spi/Provider.java =================================================================== --- trunk/src/main/java/javax/xml/ws/spi/Provider.java 2006-07-04 11:35:28 UTC (rev 552) +++ trunk/src/main/java/javax/xml/ws/spi/Provider.java 2006-07-04 16:42:35 UTC (rev 553) @@ -21,12 +21,16 @@ */ package javax.xml.ws.spi; +// $Id$ + import java.net.URL; import javax.xml.namespace.QName; import javax.xml.ws.Endpoint; import javax.xml.ws.WebServiceException; +import org.jboss.ws.jaxws.util.FactoryFinder; + /** * Service provider for ServiceDelegate and Endpoint objects. * @@ -42,11 +46,20 @@ { } + /** + * The algorithm used to locate the provider subclass to use consists of the following steps: + * + * - If a resource with the name of META-INF/services/javax.xml.ws.spi.Provider exists, then its first line, if present, is used as the UTF-8 encoded name of the implementation class. + * - If the $java.home/lib/jaxws.properties file exists and it is readable by the java.util.Properties.load(InputStream) method and it contains an entry whose key is javax.xml.ws.spi.Provider, then the value of that entry is used as the name of the implementation class. + * - If a system property with the name javax.xml.ws.spi.Provider is defined, then its value is used as the name of the implementation class. + * + * Finally, a default implementation class name is used. + */ public static Provider provider() { try { - return null; //(Provider)FactoryFinder.find(JAXWSPROVIDER_PROPERTY, DEFAULT_JAXWSPROVIDER); + return (Provider)FactoryFinder.find(JAXWSPROVIDER_PROPERTY, DEFAULT_JAXWSPROVIDER); } catch (Exception ex) { Modified: trunk/src/main/java/org/jboss/ws/addressing/metadata/AddressingOpMetaExt.java =================================================================== --- trunk/src/main/java/org/jboss/ws/addressing/metadata/AddressingOpMetaExt.java 2006-07-04 11:35:28 UTC (rev 552) +++ trunk/src/main/java/org/jboss/ws/addressing/metadata/AddressingOpMetaExt.java 2006-07-04 16:42:35 UTC (rev 553) @@ -1,9 +1,30 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2005, JBoss Inc., and individual contributors as indicated + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ package org.jboss.ws.addressing.metadata; +// $Id$ + import org.jboss.ws.metadata.MetaDataExtension; -import javax.xml.namespace.QName; - /** * Addressing meta data extensions: * <ul> @@ -12,28 +33,33 @@ * @author Heiko Braun, <he...@op...> * @since 17-Mar-2006 */ -public class AddressingOpMetaExt extends MetaDataExtension { - +public class AddressingOpMetaExt extends MetaDataExtension +{ private String inboundAction; - private String outboundAction; + private String outboundAction; - public AddressingOpMetaExt(String extensionNameSpace) { + public AddressingOpMetaExt(String extensionNameSpace) + { super(extensionNameSpace); } - public String getInboundAction() { + public String getInboundAction() + { return inboundAction; } - public void setInboundAction(String inboundAction) { + public void setInboundAction(String inboundAction) + { this.inboundAction = inboundAction; } - public String getOutboundAction() { + public String getOutboundAction() + { return outboundAction; } - public void setOutboundAction(String outboundAction) { + public void setOutboundAction(String outboundAction) + { this.outboundAction = outboundAction; } Added: trunk/src/main/java/org/jboss/ws/client/CommonClient.java =================================================================== --- trunk/src/main/java/org/jboss/ws/client/CommonClient.java 2006-07-04 11:35:28 UTC (rev 552) +++ trunk/src/main/java/org/jboss/ws/client/CommonClient.java 2006-07-04 16:42:35 UTC (rev 553) @@ -0,0 +1,381 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2005, JBoss Inc., and individual contributors as indicated + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ +package org.jboss.ws.client; + +// $Id$ + +import java.net.MalformedURLException; +import java.net.URL; +import java.rmi.RemoteException; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; + +import javax.xml.namespace.QName; +import javax.xml.rpc.ParameterMode; +import javax.xml.rpc.handler.MessageContext; +import javax.xml.rpc.soap.SOAPFaultException; +import javax.xml.soap.SOAPException; +import javax.xml.soap.SOAPMessage; +import javax.xml.ws.addressing.AddressingProperties; +import javax.xml.ws.addressing.JAXWSAConstants; + +import org.jboss.logging.Logger; +import org.jboss.ws.Constants; +import org.jboss.ws.WSException; +import org.jboss.ws.addressing.AddressingConstantsImpl; +import org.jboss.ws.binding.BindingProvider; +import org.jboss.ws.binding.BindingProviderRegistry; +import org.jboss.ws.binding.EndpointInvocation; +import org.jboss.ws.binding.UnboundHeader; +import org.jboss.ws.jaxrpc.ParameterWrapping; +import org.jboss.ws.jaxrpc.Style; +import org.jboss.ws.metadata.ClientEndpointMetaData; +import org.jboss.ws.metadata.EndpointMetaData; +import org.jboss.ws.metadata.OperationMetaData; +import org.jboss.ws.metadata.ParameterMetaData; +import org.jboss.ws.metadata.ServiceMetaData; +import org.jboss.ws.metadata.UnifiedMetaData; +import org.jboss.ws.soap.EndpointInfo; +import org.jboss.ws.soap.MessageContextAssociation; +import org.jboss.ws.soap.SOAPConnectionImpl; +import org.jboss.ws.soap.SOAPMessageContextImpl; +import org.jboss.ws.utils.HolderUtils; +import org.jboss.ws.utils.JavaUtils; + +/** + * Provides support for the dynamic invocation of a service endpoint. + * + * @author Tho...@jb... + * @since 10-Oct-2004 + */ +public abstract class CommonClient +{ + // provide logging + private static Logger log = Logger.getLogger(CommonClient.class); + + // The endpoint together with the operationName uniquely identify the call operation + protected EndpointMetaData epMetaData; + // The current operation name + protected QName operationName; + // Output parameters + protected EndpointInvocation epInv; + + /** Create a call that needs to be configured manually + */ + protected CommonClient(ServiceMetaData serviceMetaData) + { + // If the WSDLService has only one endpoint, use it + if (serviceMetaData != null && serviceMetaData.getEndpoints().size() == 1) + { + this.epMetaData = serviceMetaData.getEndpoints().get(0); + } + } + + /** Create a call for a known WSDL endpoint. + */ + protected CommonClient(EndpointMetaData epMetaData) + { + this.epMetaData = epMetaData; + } + + /** Create a call for a known WSDL endpoint. + */ + protected CommonClient(ServiceMetaData serviceMetaData, QName portName, QName opName) + { + if (serviceMetaData != null) + { + EndpointMetaData epMetaData = null; + if (serviceMetaData.getEndpoints().size() > 0) + { + epMetaData = serviceMetaData.getEndpoint(portName); + if (epMetaData == null) + throw new WSException("Cannot find endpoint for name: " + portName); + } + + if (epMetaData != null) + { + this.epMetaData = epMetaData; + } + } + + if (opName != null) + { + setOperationName(opName); + } + } + + /** Gets the address of a target service endpoint. + */ + public abstract String getTargetEndpointAddress(); + + /** Sets the address of the target service endpoint. + */ + public abstract void setTargetEndpointAddress(String address); + + /** Gets the name of the operation to be invoked using this Call instance. + */ + public QName getOperationName() + { + return this.operationName; + } + + /** Sets the name of the operation to be invoked using this Call instance. + */ + public void setOperationName(QName operationName) + { + this.operationName = operationName; + } + + /** Get the OperationMetaData for the given operation name + * If it does not exist, it will be created + */ + public OperationMetaData getOperationMetaData() + { + if (operationName == null) + throw new WSException("Operation name not set"); + + return getOperationMetaData(operationName); + } + + /** Get the OperationMetaData for the given operation name + * If it does not exist, it will be created + */ + public OperationMetaData getOperationMetaData(QName opName) + { + if (opName == null) + throw new IllegalArgumentException("Cannot get OperationMetaData for null"); + + EndpointMetaData epMetaData = getEndpointMetaData(); + OperationMetaData opMetaData = epMetaData.getOperation(opName); + if (opMetaData == null && epMetaData.getServiceMetaData().getWsdlDefinitions() == null) + { + opMetaData = new OperationMetaData(epMetaData, opName, opName.getLocalPart()); + epMetaData.addOperation(opMetaData); + } + + if (opMetaData == null) + throw new WSException("Cannot obtain operation meta data for: " + opName); + + return opMetaData; + } + + // Get the EndpointMetaData for all OperationMetaData + public EndpointMetaData getEndpointMetaData() + { + if (epMetaData == null) + { + UnifiedMetaData wsMetaData = new UnifiedMetaData(); + ServiceMetaData serviceMetaData = new ServiceMetaData(wsMetaData, new QName(Constants.NS_JBOSSWS_URI, "AnonymousService")); + wsMetaData.addService(serviceMetaData); + + epMetaData = new ClientEndpointMetaData(serviceMetaData, new QName(Constants.NS_JBOSSWS_URI, "AnonymousEndpoint")); + epMetaData.setStyle(Style.RPC); + + serviceMetaData.addEndpoint(epMetaData); + } + return epMetaData; + } + + protected abstract boolean callRequestHandlerChain(QName portName, SOAPMessageContextImpl msgContext); + + protected abstract boolean callResponseHandlerChain(QName portName, SOAPMessageContextImpl msgContext); + + /** Call invokation goes as follows: + * + * 1) synchronize the operation name with the operation meta data + * 2) synchronize the input parameters with the operation meta data + * 3) generate the payload using a BindingProvider + * 4) get the Invoker from Remoting, based on the target endpoint address + * 5) do the invocation through the Remoting framework + * 6) unwrap the result using the BindingProvider + * 7) return the result + */ + protected Object invoke(QName opName, Object[] inputParams, Map<QName, UnboundHeader> unboundHeaders, boolean oneway) throws RemoteException + { + if (opName.equals(operationName) == false) + setOperationName(opName); + + OperationMetaData opMetaData = getOperationMetaData(); + + // Associate a message context with the current thread + SOAPMessageContextImpl msgContext = new SOAPMessageContextImpl(); + MessageContextAssociation.pushMessageContext(msgContext); + msgContext.setOperationMetaData(opMetaData); + + // copy properties to the message context + for (String key : getRequestContext().keySet()) + { + Object value = getRequestContext().get(key); + msgContext.setProperty(key, value); + } + + try + { + // Get the binding provider for the given bindingURI + BindingProvider bindingProvider = BindingProviderRegistry.getDefaultProvider(); + + // Create the invocation and sync the input parameters + epInv = new EndpointInvocation(opMetaData); + epInv.initInputParams(inputParams); + + // Bind the request message + SOAPMessage reqMessage = bindingProvider.bindRequestMessage(opMetaData, epInv, unboundHeaders); + + // Call the request handlers + QName portName = epMetaData.getQName(); + + if (callRequestHandlerChain(portName, msgContext)) + { + String targetAddress = getTargetEndpointAddress(); + + // Fall back to wsa:To + AddressingProperties addrProps = (AddressingProperties)msgContext.getProperty(JAXWSAConstants.CLIENT_ADDRESSING_PROPERTIES_OUTBOUND); + if (targetAddress == null && addrProps != null && addrProps.getTo() != null) + { + AddressingConstantsImpl ADDR = new AddressingConstantsImpl(); + String wsaTo = addrProps.getTo().getURI().toString(); + if (wsaTo.equals(ADDR.getAnonymousURI()) == false) + { + try + { + URL wsaToURL = new URL(wsaTo); + log.debug("Sending request to addressing destination: " + wsaToURL); + targetAddress = wsaToURL.toExternalForm(); + } + catch (MalformedURLException ex) + { + log.debug("Not a valid URL: " + wsaTo); + } + } + } + + // The endpoint address must be known beyond this point + if (targetAddress == null) + throw new WSException("Target endpoint address not set"); + + // Setup remoting call properties + Map<String, Object> callProps = new HashMap<String, Object>(); + callProps.putAll(getRequestContext()); + + syncMessageProperties(callProps, msgContext); + + EndpointInfo epInfo = new EndpointInfo(epMetaData, targetAddress, callProps); + SOAPMessage resMessage = new SOAPConnectionImpl().call(reqMessage, epInfo, oneway); + + // Associate current message with message context + msgContext.setMessage(resMessage); + } + + // Get the return object + Object retObj = null; + if (oneway == false) + { + // Call the response handlers + callResponseHandlerChain(portName, msgContext); + + // unbind the return values + SOAPMessage resMessage = msgContext.getMessage(); + bindingProvider.unbindResponseMessage(opMetaData, resMessage, epInv, unboundHeaders); + + retObj = syncOutputParams(inputParams, epInv); + } + + return retObj; + } + catch (SOAPFaultException ex) + { + log.error("Call invocation failed", ex); + String faultCode = ex.getFaultCode().getLocalPart(); + throw new RemoteException("Call invocation failed with code [" + faultCode + "] because of: " + ex.getFaultString(), ex); + } + catch (Exception ex) + { + throw new RemoteException("Call invocation failed: " + ex.getMessage(), ex); + } + finally + { + // Snyc context properties with the stub that clients can access them + syncMessageProperties(getResponseContext(), msgContext); + + // Reset the message context association + MessageContextAssociation.popMessageContext(); + } + } + + protected abstract Map<String, Object> getRequestContext(); + + protected abstract Map<String, Object> getResponseContext(); + + private void syncMessageProperties(Map<String, Object> props, MessageContext msgContext) + { + Iterator it = msgContext.getPropertyNames(); + while (it.hasNext()) + { + String propName = (String)it.next(); + Object property = msgContext.getProperty(propName); + props.put(propName, property); + } + } + + /** Synchronize the operation paramters with the call output parameters. + */ + private Object syncOutputParams(Object[] inParams, EndpointInvocation epInv) throws SOAPException + { + Object retValue = null; + + // Assign the return value, if we have a return param + OperationMetaData opMetaData = getOperationMetaData(); + ParameterMetaData retMetaData = opMetaData.getReturnParameter(); + if (retMetaData != null) + { + retValue = epInv.getReturnValue(); + if (opMetaData.isDocumentWrapped()) + retValue = ParameterWrapping.unwrapResponseParameter(opMetaData, retValue); + + if (JavaUtils.isPrimitive(retMetaData.getJavaType())) + retValue = JavaUtils.getPrimitiveValue(retValue); + } + + // Set the holder values for INOUT parameters + int index = 0; + for (ParameterMetaData paramMetaData : opMetaData.getParameters()) + { + ParameterMode paramMode = paramMetaData.getMode(); + + if (paramMode == ParameterMode.INOUT || paramMode == ParameterMode.OUT) + { + QName xmlName = paramMetaData.getXmlName(); + Object value = epInv.getResponseParamValue(xmlName); + log.debug("holder [" + index + "] " + xmlName); + HolderUtils.setHolderValue(inParams[index], value); + } + + if (index == 0 && opMetaData.isDocumentWrapped()) + index = paramMetaData.getWrappedVariables().size() - 1; + + index++; + } + + return retValue; + } +} Property changes on: trunk/src/main/java/org/jboss/ws/client/CommonClient.java ___________________________________________________________________ Name: svn:keywords + Id Revision Name: svn:eol-style + LF Modified: trunk/src/main/java/org/jboss/ws/deployment/AbstractMetaDataBuilder.java =================================================================== --- trunk/src/main/java/org/jboss/ws/deployment/AbstractMetaDataBuilder.java 2006-07-04 11:35:28 UTC (rev 552) +++ trunk/src/main/java/org/jboss/ws/deployment/AbstractMetaDataBuilder.java 2006-07-04 16:42:35 UTC (rev 553) @@ -39,15 +39,36 @@ import javax.wsdl.Service; import javax.wsdl.extensions.soap.SOAPAddress; import javax.xml.namespace.QName; +import javax.xml.ws.addressing.AddressingProperties; import org.jboss.logging.Logger; +import org.jboss.ws.Constants; import org.jboss.ws.WSException; +import org.jboss.ws.addressing.AddressingPropertiesImpl; +import org.jboss.ws.addressing.metadata.AddressingOpMetaExt; +import org.jboss.ws.eventing.EventingConstants; +import org.jboss.ws.eventing.deployment.EventingEndpoint; +import org.jboss.ws.eventing.metadata.EventingEpMetaExt; +import org.jboss.ws.jaxrpc.UnqualifiedFaultException; +import org.jboss.ws.jaxrpc.Use; +import org.jboss.ws.metadata.EndpointMetaData; +import org.jboss.ws.metadata.FaultMetaData; +import org.jboss.ws.metadata.OperationMetaData; import org.jboss.ws.metadata.ServerEndpointMetaData; +import org.jboss.ws.metadata.TypesMetaData; import org.jboss.ws.metadata.j2ee.UnifiedApplicationMetaData; import org.jboss.ws.metadata.j2ee.UnifiedBeanMetaData; import org.jboss.ws.metadata.j2ee.UnifiedMessageDrivenMetaData; +import org.jboss.ws.metadata.wsdl.NCName; +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.WSDLInterfaceFault; +import org.jboss.ws.metadata.wsdl.WSDLInterfaceOperation; +import org.jboss.ws.metadata.wsdl.WSDLInterfaceOperationOutfault; +import org.jboss.ws.metadata.wsdl.WSDLProperty; import org.jboss.ws.metadata.wsdl.WSDLService; import org.jboss.ws.server.ServiceEndpointManager; import org.jboss.ws.server.ServiceEndpointManagerFactory; @@ -76,6 +97,54 @@ this.resourceLoader = resourceLoader; } + /** Initialize the endpoint encoding style from the binding operations + */ + protected void initEndpointEncodingStyle(EndpointMetaData epMetaData) + { + WSDLDefinitions wsdlDefinitions = epMetaData.getServiceMetaData().getWsdlDefinitions(); + for (WSDLService wsdlService : wsdlDefinitions.getServices()) + { + for (WSDLEndpoint wsdlEndpoint : wsdlService.getEndpoints()) + { + if (epMetaData.getQName().equals(wsdlEndpoint.getQName())) + { + QName bindQName = wsdlEndpoint.getBinding(); + NCName ncName = new NCName(bindQName.getLocalPart()); + WSDLBinding wsdlBinding = wsdlDefinitions.getBinding(ncName); + if (wsdlBinding == null) + throw new WSException("Cannot obtain binding: " + ncName); + + for (WSDLBindingOperation wsdlBindingOperation : wsdlBinding.getOperations()) + { + String encStyle = wsdlBindingOperation.getEncodingStyle(); + epMetaData.setEncodingStyle(Use.valueOf(encStyle)); + } + } + } + } + } + + protected void processEndpointMetaDataExtensions(EndpointMetaData epMetaData, WSDLDefinitions wsdlDefinitions) + { + for (WSDLInterface wsdlInterface : wsdlDefinitions.getInterfaces()) + { + WSDLProperty eventSourceProp = wsdlInterface.getProperty(Constants.WSDL_PROPERTY_EVENTSOURCE); + if (eventSourceProp != null && epMetaData instanceof ServerEndpointMetaData) + { + ServerEndpointMetaData sepMetaData = (ServerEndpointMetaData)epMetaData; + String eventSourceNS = wsdlInterface.getQName().getNamespaceURI() + "/" + wsdlInterface.getQName().getLocalPart(); + Object notificationSchema = null; // todo: resolve schema from operation message + + EventingEpMetaExt ext = new EventingEpMetaExt(EventingConstants.NS_EVENTING); + ext.setEventSourceNS(eventSourceNS); + ext.setNotificationSchema(notificationSchema); + + sepMetaData.addExtension(ext); + sepMetaData.setManagedEndpointBean(EventingEndpoint.class.getName()); + } + } + } + protected ObjectName getServiceEndpointID(UnifiedDeploymentInfo udi, ServerEndpointMetaData sepMetaData) { String endpoint = sepMetaData.getLinkName(); @@ -110,6 +179,71 @@ return ObjectNameFactory.create(idstr.toString()); } + protected void buildFaultMetaData(OperationMetaData opMetaData, WSDLInterfaceOperation wsdlOperation) + { + TypesMetaData typesMetaData = opMetaData.getEndpointMetaData().getServiceMetaData().getTypesMetaData(); + + WSDLInterface wsdlInterface = wsdlOperation.getWsdlInterface(); + for (WSDLInterfaceOperationOutfault outFault : wsdlOperation.getOutfaults()) + { + QName ref = outFault.getRef(); + + WSDLInterfaceFault wsdlFault = wsdlInterface.getFault(new NCName(ref.getLocalPart())); + QName xmlName = wsdlFault.getXmlName(); + QName xmlType = wsdlFault.getXmlType(); + String javaTypeName = null; + + if (typesMetaData.getTypeMappingByXMLType(xmlType) != null) + javaTypeName = typesMetaData.getTypeMappingByXMLType(xmlType).getJavaTypeName(); + + if (javaTypeName == null) + { + log.warn("Cannot obtain java type mapping for: " + xmlType); + javaTypeName = new UnqualifiedFaultException(xmlType).getClass().getName(); + } + + FaultMetaData faultMetaData = new FaultMetaData(opMetaData, xmlName, xmlType, javaTypeName); + opMetaData.addFault(faultMetaData); + } + } + + /** Process operation meta data extensions. */ + protected void processOpMetaExtensions(OperationMetaData opMetaData, WSDLInterfaceOperation wsdlOperation) + { + + String tns = wsdlOperation.getQName().getNamespaceURI(); + String portTypeName = wsdlOperation.getQName().getLocalPart(); + + AddressingProperties ADDR = new AddressingPropertiesImpl(); + AddressingOpMetaExt addrExt = new AddressingOpMetaExt(ADDR.getNamespaceURI()); + + // inbound action + WSDLProperty wsaInAction = wsdlOperation.getProperty(Constants.WSDL_PROPERTY_ACTION_IN); + if (wsaInAction != null) + { + addrExt.setInboundAction(wsaInAction.getValue()); + } + else + { + WSDLProperty messageName = wsdlOperation.getProperty(Constants.WSDL_PROPERTY_MESSAGE_NAME_IN); + addrExt.setInboundAction(tns + "/" + portTypeName + "/" + messageName); + } + + // outbound action + WSDLProperty wsaOutAction = wsdlOperation.getProperty(Constants.WSDL_PROPERTY_ACTION_OUT); + if (wsaOutAction != null) + { + addrExt.setOutboundAction(wsaOutAction.getValue()); + } + else + { + WSDLProperty messageName = wsdlOperation.getProperty(Constants.WSDL_PROPERTY_MESSAGE_NAME_OUT); + addrExt.setOutboundAction(tns + "/" + portTypeName + "/" + messageName); + } + + opMetaData.addExtension(addrExt); + } + /** Get the web service address for a given path */ public String getServiceEndpointAddress(String uriScheme, String servicePath) Added: trunk/src/main/java/org/jboss/ws/deployment/JAXWSClientMetaDataBuilder.java =================================================================== --- trunk/src/main/java/org/jboss/ws/deployment/JAXWSClientMetaDataBuilder.java 2006-07-04 11:35:28 UTC (rev 552) +++ trunk/src/main/java/org/jboss/ws/deployment/JAXWSClientMetaDataBuilder.java 2006-07-04 16:42:35 UTC (rev 553) @@ -0,0 +1,338 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2005, JBoss Inc., and individual contributors as indicated + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ +package org.jboss.ws.deployment; + +//$Id$ + +import java.io.IOException; +import java.net.URL; + +import javax.xml.namespace.QName; +import javax.xml.rpc.ParameterMode; +import javax.xml.rpc.encoding.TypeMappingRegistry; + +import org.jboss.logging.Logger; +import org.jboss.ws.Constants; +import org.jboss.ws.WSException; +import org.jboss.ws.jaxrpc.ParameterStyle; +import org.jboss.ws.jaxrpc.Style; +import org.jboss.ws.jaxrpc.TypeMappingImpl; +import org.jboss.ws.jaxrpc.TypeMappingRegistryImpl; +import org.jboss.ws.metadata.ClientEndpointMetaData; +import org.jboss.ws.metadata.EndpointMetaData; +import org.jboss.ws.metadata.OperationMetaData; +import org.jboss.ws.metadata.ParameterMetaData; +import org.jboss.ws.metadata.ServiceMetaData; +import org.jboss.ws.metadata.TypeMappingMetaData; +import org.jboss.ws.metadata.TypesMetaData; +import org.jboss.ws.metadata.UnifiedMetaData; +import org.jboss.ws.metadata.wsdl.NCName; +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.WSDLInterfaceOperationInput; +import org.jboss.ws.metadata.wsdl.WSDLInterfaceOperationOutput; +import org.jboss.ws.metadata.wsdl.WSDLService; + +/** + * A client side meta data builder. + * + * @author Tho...@jb... + * @since 19-May-2005 + */ +public class JAXWSClientMetaDataBuilder extends JAXWSMetaDataBuilder +{ + // provide logging + private final Logger log = Logger.getLogger(JAXWSClientMetaDataBuilder.class); + + /** Build from WSDL and jaxrpc-mapping.xml + */ + public ServiceMetaData buildMetaData(QName serviceQName, URL wsdlURL) + { + log.debug("START buildMetaData: [service=" + serviceQName + "]"); + try + { + UnifiedMetaData wsMetaData = new UnifiedMetaData(); + wsMetaData.setResourceLoader(resourceLoader); + wsMetaData.setClassLoader(classLoader); + + ServiceMetaData serviceMetaData = new ServiceMetaData(wsMetaData, serviceQName); + wsMetaData.addService(serviceMetaData); + + serviceMetaData.setWsdlFile(wsdlURL.toExternalForm()); + WSDLDefinitions wsdlDefinitions = serviceMetaData.getWsdlDefinitions(); + + buildMetaDataInternal(serviceMetaData, wsdlDefinitions); + + // eagerly initialize + wsMetaData.eagerInitialize(); + + log.debug("END buildMetaData: " + serviceMetaData); + return serviceMetaData; + } + catch (RuntimeException rte) + { + throw rte; + } + catch (Exception ex) + { + throw new WSException("Cannot build meta data: " + ex.getMessage(), ex); + } + } + + private void buildMetaDataInternal(ServiceMetaData serviceMetaData, WSDLDefinitions wsdlDefinitions) throws IOException + { + QName serviceQName = serviceMetaData.getName(); + + // Get the WSDL service + WSDLService wsdlService = null; + if (serviceQName == null) + { + if (wsdlDefinitions.getServices().length != 1) + throw new IllegalArgumentException("Expected a single service element"); + + wsdlService = wsdlDefinitions.getServices()[0]; + serviceMetaData.setName(wsdlService.getQName()); + } + else + { + wsdlService = wsdlDefinitions.getService(new NCName(serviceQName.getLocalPart())); + } + if (wsdlService == null) + throw new IllegalArgumentException("Cannot obtain wsdl service: " + serviceQName); + + // Build endpoint meta data + for (WSDLEndpoint wsdlEndpoint : wsdlService.getEndpoints()) + { + QName portName = wsdlEndpoint.getQName(); + ClientEndpointMetaData epMetaData = new ClientEndpointMetaData(serviceMetaData, portName); + epMetaData.setEndpointAddress(wsdlEndpoint.getAddress()); + serviceMetaData.addEndpoint(epMetaData); + + // Init the service encoding style + initEndpointEncodingStyle(epMetaData); + + processEndpointMetaDataExtensions(epMetaData, wsdlDefinitions); + setupOperationsFromWSDL(epMetaData, wsdlEndpoint); + } + } + + protected void setupOperationsFromWSDL(EndpointMetaData epMetaData, WSDLEndpoint wsdlEndpoint) + { + WSDLDefinitions wsdlDefinitions = wsdlEndpoint.getInterface().getWsdlDefinitions(); + + // For every WSDL interface operation build the OperationMetaData + WSDLInterface wsdlInterface = wsdlEndpoint.getInterface(); + for (WSDLInterfaceOperation wsdlOperation : wsdlInterface.getOperations()) + { + String opName = wsdlOperation.getName().toString(); + QName opQName = wsdlOperation.getQName(); + + // Set java method name + String javaName = opName.substring(0, 1).toLowerCase() + opName.substring(1); + + OperationMetaData opMetaData = new OperationMetaData(epMetaData, opQName, javaName); + epMetaData.addOperation(opMetaData); + + // Set the operation style + String style = wsdlOperation.getStyle(); + epMetaData.setStyle(Style.valueOf(style)); + + // Set the operation MEP + if (Constants.WSDL20_PATTERN_IN_ONLY.equals(wsdlOperation.getPattern())) + opMetaData.setOneWayOperation(true); + + // Set the operation SOAPAction + WSDLBinding wsdlBinding = wsdlDefinitions.getBindingByInterfaceName(wsdlInterface.getQName()); + WSDLBindingOperation wsdlBindingOperation = wsdlBinding.getOperationByRef(opQName); + if (wsdlBindingOperation != null) + opMetaData.setSOAPAction(wsdlBindingOperation.getSOAPAction()); + + // Get the type mapping for the encoding style + String encStyle = epMetaData.getEncodingStyle().toURI(); + TypeMappingRegistry tmRegistry = new TypeMappingRegistryImpl(); + TypeMappingImpl typeMapping = (TypeMappingImpl)tmRegistry.getTypeMapping(encStyle); + + // Build the parameter meta data + if (opMetaData.getStyle() == Style.RPC) + { + buildParameterMetaDataRpc(opMetaData, wsdlOperation, typeMapping); + } + else + { + buildParameterMetaDataDoc(opMetaData, wsdlOperation, typeMapping); + } + + // Build operation faults + buildFaultMetaData(opMetaData, wsdlOperation); + + // process further operation extensions + processOpMetaExtensions(opMetaData, wsdlOperation); + } + } + + private void buildParameterMetaDataRpc(OperationMetaData opMetaData, WSDLInterfaceOperation wsdlOperation, TypeMappingImpl typeMapping) + { + log.trace("buildParameterMetaDataRpc: " + opMetaData.getXmlName()); + + TypesMetaData typesMetaData = opMetaData.getEndpointMetaData().getServiceMetaData().getTypesMetaData(); + + for (WSDLInterfaceOperationInput opInput : wsdlOperation.getInputs()) + { + QName xmlName = opInput.getElement(); + QName xmlType = opInput.getXMLType(); + String javaTypeName = typeMapping.getJavaTypeName(xmlType); + + if (javaTypeName == null) + throw new WSException("Cannot obtain java type mapping for: " + xmlType); + + ParameterMetaData inMetaData = new ParameterMetaData(opMetaData, xmlName, xmlType, javaTypeName); + opMetaData.addParameter(inMetaData); + + boolean inHeader = opInput.getProperty(Constants.WSDL_PROPERTY_APPLICATION_DATA) != null; + inMetaData.setInHeader(inHeader); + } + + for (WSDLInterfaceOperationOutput opOutput : wsdlOperation.getOutputs()) + { + String partName = opOutput.getProperty(Constants.WSDL_PROPERTY_PART_NAME).getValue(); + QName xmlName = opOutput.getElement(); + + ParameterMetaData outMetaData = opMetaData.getParameter(xmlName); + if (outMetaData != null && wsdlOperation.getInputByPartName(partName) != null) + { + outMetaData.setMode(ParameterMode.INOUT); + } + else + { + QName xmlType = opOutput.getXMLType(); + String javaTypeName = typeMapping.getJavaTypeName(xmlType); + + boolean inHeader = opOutput.getProperty(Constants.WSDL_PROPERTY_APPLICATION_DATA) != null; + boolean hasReturnMapping = (inHeader == false); + + if (javaTypeName == null) + throw new WSException("Cannot obtain java type mapping for: " + xmlType); + + if (hasReturnMapping) + { + outMetaData = new ParameterMetaData(opMetaData, xmlName, xmlType, javaTypeName); + opMetaData.setReturnParameter(outMetaData); + } + else + { + outMetaData = new ParameterMetaData(opMetaData, xmlName, xmlType, javaTypeName); + outMetaData.setMode(ParameterMode.OUT); + opMetaData.addParameter(outMetaData); + + outMetaData.setInHeader(inHeader); + } + } + } + } + + private void buildParameterMetaDataDoc(OperationMetaData opMetaData, WSDLInterfaceOperation wsdlOperation, TypeMappingImpl typeMapping) + { + log.trace("buildParameterMetaDataDoc: " + opMetaData.getXmlName()); + + EndpointMetaData epMetaData = opMetaData.getEndpointMetaData(); + ServiceMetaData serviceMetaData = epMetaData.getServiceMetaData(); + TypesMetaData typesMetaData = serviceMetaData.getTypesMetaData(); + + for (WSDLInterfaceOperationInput opInput : wsdlOperation.getInputs()) + { + QName xmlName = opInput.getElement(); + QName xmlType = opInput.getXMLType(); + String javaTypeName = typeMapping.getJavaTypeName(xmlType); + + TypeMappingMetaData typeMetaData = typesMetaData.getTypeMappingByXMLType(xmlType); + if (typeMetaData != null) + javaTypeName = typeMetaData.getJavaTypeName(); + + if (javaTypeName == null) + throw new WSException("Cannot obtain java type mapping for: " + xmlType); + + // Check if we need to wrap the parameters + boolean isWrapParameters = false; + + ParameterMetaData inMetaData = new ParameterMetaData(opMetaData, xmlName, xmlType, javaTypeName); + epMetaData.setParameterStyle(isWrapParameters ? ParameterStyle.WRAPPED : ParameterStyle.BARE); + inMetaData.setInHeader(opInput.getProperty(Constants.WSDL_PROPERTY_APPLICATION_DATA) != null); + opMetaData.addParameter(inMetaData); + + // Set the variable names + if (opMetaData.isDocumentWrapped()) + { + throw new WSException("Cannot obtain java/xml type mapping for: " + xmlType); + } + } + + for (WSDLInterfaceOperationOutput opOutput : wsdlOperation.getOutputs()) + { + String partName = opOutput.getProperty(Constants.WSDL_PROPERTY_PART_NAME).getValue(); + QName xmlName = opOutput.getElement(); + + ParameterMetaData paramMetaData = opMetaData.getParameter(xmlName); + if (paramMetaData != null && wsdlOperation.getInputByPartName(partName) != null) + { + paramMetaData.setMode(ParameterMode.INOUT); + } + else + { + QName xmlType = opOutput.getXMLType(); + String javaTypeName = typeMapping.getJavaTypeName(xmlType); + + boolean inHeader = opOutput.getProperty(Constants.WSDL_PROPERTY_APPLICATION_DATA) != null; + boolean hasReturnMapping = (inHeader == false); + + if (typesMetaData.getTypeMappingByXMLType(xmlType) != null) + javaTypeName = typesMetaData.getTypeMappingByXMLType(xmlType).getJavaTypeName(); + + if (javaTypeName == null) + throw new WSException("Cannot obtain java/xml type mapping for: " + xmlType); + + if (hasReturnMapping) + { + ParameterMetaData retMetaData = new ParameterMetaData(opMetaData, xmlName, xmlType, javaTypeName); + opMetaData.setReturnParameter(retMetaData); + + // Set the variable names + if (opMetaData.getParameterStyle() == ParameterStyle.WRAPPED) + { + throw new IllegalArgumentException("Cannot wrap parameters without SEI method mapping"); + } + } + else + { + ParameterMetaData outMetaData = new ParameterMetaData(opMetaData, xmlName, xmlType, javaTypeName); + opMetaData.addParameter(outMetaData); + outMetaData.setMode(ParameterMode.OUT); + + outMetaData.setInHeader(inHeader); + } + } + } + } +} Property changes on: trunk/src/main/java/org/jboss/ws/deployment/JAXWSClientMetaDataBuilder.java ___________________________________________________________________ Name: svn:keywords + Id Revision Name: svn:eol-style + LF Modified: trunk/src/main/java/org/jboss/ws/deployment/JSR109MetaDataBuilder.java =================================================================== --- trunk/src/main/java/org/jboss/ws/deployment/JSR109MetaDataBuilder.java 2006-07-04 11:35:28 UTC (rev 552) +++ trunk/src/main/java/org/jboss/ws/deployment/JSR109MetaDataBuilder.java 2006-07-04 16:42:35 UTC (rev 553) @@ -39,22 +39,15 @@ import org.jboss.ws.Constants; import org.jboss.ws.WSException; import org.jboss.ws.addressing.AddressingConstantsImpl; -import org.jboss.ws.addressing.metadata.AddressingOpMetaExt; -import org.jboss.ws.eventing.EventingConstants; -import org.jboss.ws.eventing.deployment.EventingEndpoint; -import org.jboss.ws.eventing.metadata.EventingEpMetaExt; import org.jboss.ws.jaxrpc.LiteralTypeMapping; import org.jboss.ws.jaxrpc.ParameterStyle; import org.jboss.ws.jaxrpc.Style; import org.jboss.ws.jaxrpc.TypeMappingImpl; import org.jboss.ws.jaxrpc.TypeMappingRegistryImpl; -import org.jboss.ws.jaxrpc.UnqualifiedFaultException; import org.jboss.ws.jaxrpc.Use; import org.jboss.ws.metadata.EndpointMetaData; -import org.jboss.ws.metadata.FaultMetaData; import org.jboss.ws.metadata.OperationMetaData; import org.jboss.ws.metadata.ParameterMetaData; -import org.jboss.ws.metadata.ServerEndpointMetaData; import org.jboss.ws.metadata.ServiceMetaData; import org.jboss.ws.metadata.TypeMappingMetaData; import org.jboss.ws.metadata.TypesMetaData; @@ -67,20 +60,16 @@ import org.jboss.ws.metadata.jaxrpcmapping.VariableMapping; import org.jboss.ws.metadata.jaxrpcmapping.WsdlMessageMapping; import org.jboss.ws.metadata.jaxrpcmapping.WsdlReturnValueMapping; -import org.jboss.ws.metadata.wsdl.NCName; 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.WSDLInterfaceFault; import org.jboss.ws.metadata.wsdl.WSDLInterfaceOperation; import org.jboss.ws.metadata.wsdl.WSDLInterfaceOperationInput; -import org.jboss.ws.metadata.wsdl.WSDLInterfaceOperationOutfault; import org.jboss.ws.metadata.wsdl.WSDLInterfaceOperationOutput; import org.jboss.ws.metadata.wsdl.WSDLInterfaceOperationPart; import org.jboss.ws.metadata.wsdl.WSDLProperty; -import org.jboss.ws.metadata.wsdl.WSDLService; import org.jboss.ws.metadata.wsdl.WSDLTypes; import org.jboss.ws.metadata.wsdl.xmlschema.JBossXSModel; import org.jboss.ws.utils.JavaUtils; @@ -201,7 +190,7 @@ } // Build operation faults - buildFaultMetaData(opMetaData, wsdlOperation, seiMapping); + buildFaultMetaData(opMetaData, wsdlOperation); // process further operation extensions processOpMetaExtensions(opMetaData, wsdlOperation); @@ -628,124 +617,7 @@ } } - private void buildFaultMetaData(OperationMetaData opMetaData, WSDLInterfaceOperation wsdlOperation, ServiceEndpointInterfaceMapping seiMapping) - { - TypesMetaData typesMetaData = opMetaData.getEndpointMetaData().getServiceMetaData().getTypesMetaData(); - - WSDLInterface wsdlInterface = wsdlOperation.getWsdlInterface(); - for (WSDLInterfaceOperationOutfault outFault : wsdlOperation.getOutfaults()) - { - QName ref = outFault.getRef(); - - WSDLInterfaceFault wsdlFault = wsdlInterface.getFault(new NCName(ref.getLocalPart())); - QName xmlName = wsdlFault.getXmlName(); - QName xmlType = wsdlFault.getXmlType(); - String javaTypeName = null; - - if (typesMetaData.getTypeMappingByXMLType(xmlType) != null) - javaTypeName = typesMetaData.getTypeMappingByXMLType(xmlType).getJavaTypeName(); - - if (javaTypeName == null) - { - log.warn("Cannot obtain java type mapping for: " + xmlType); - javaTypeName = new UnqualifiedFaultException(xmlType).getClass().getName(); - } - - FaultMetaData faultMetaData = new FaultMetaData(opMetaData, xmlName, xmlType, javaTypeName); - opMetaData.addFault(faultMetaData); - } - } - - /** Initialize the endpoint encoding style from the binding operations - */ - protected void initEndpointEncodingStyle(EndpointMetaData epMetaData) - { - WSDLDefinitions wsdlDefinitions = epMetaData.getServiceMetaData().getWsdlDefinitions(); - for (WSDLService wsdlService : wsdlDefinitions.getServices()) - { - for (WSDLEndpoint wsdlEndpoint : wsdlService.getEndpoints()) - { - if (epMetaData.getQName().equals(wsdlEndpoint.getQName())) - { - QName bindQName = wsdlEndpoint.getBinding(); - NCName ncName = new NCName(bindQName.getLocalPart()); - WSDLBinding wsdlBinding = wsdlDefinitions.getBinding(ncName); - if (wsdlBinding == null) - throw new WSException("Cannot obtain binding: " + ncName); - - for (WSDLBindingOperation wsdlBindingOperation : wsdlBinding.getOperations()) - { - String encStyle = wsdlBindingOperation.getEncodingStyle(); - epMetaData.setEncodingStyle(Use.valueOf(encStyle)); - } - } - } - } - } - - protected void processEndpointMetaDataExtensions(EndpointMetaData epMetaData, WSDLDefinitions wsdlDefinitions) - { - for (WSDLInterface wsdlInterface : wsdlDefinitions.getInterfaces()) - { - WSDLProperty eventSourceProp = wsdlInterface.getProperty(Constants.WSDL_PROPERTY_EVENTSOURCE); - if (eventSourceProp != null && epMetaData instanceof ServerEndpointMetaData) - { - ServerEndpointMetaData sepMetaData = (ServerEndpointMetaData)epMetaData; - String eventSourceNS = wsdlInterface.getQName().getNamespaceURI() + "/" + wsdlInterface.getQName().getLocalPart(); - Object notificationSchema = null; // todo: resolve schema from operation message - - EventingEpMetaExt ext = new EventingEpMetaExt(EventingConstants.NS_EVENTING); - ext.setEventSourceNS(eventSourceNS); - ext.setNotificationSchema(notificationSchema); - - sepMetaData.addExtension(ext); - sepMetaData.setManagedEndpointBean(EventingEndpoint.class.getName()); - } - } - } - /** - * Process operation meta data extensions. - * - * @param opMetaData - * @param wsdlOperation - */ - protected void processOpMetaExtensions(OperationMetaData opMetaData, WSDLInterfaceOperation wsdlOperation) - { - - String tns = wsdlOperation.getQName().getNamespaceURI(); - String portTypeName = wsdlOperation.getQName().getLocalPart(); - - AddressingOpMetaExt addrExt = new AddressingOpMetaExt(ADDR.getNamespaceURI()); - - // inbound action - WSDLProperty wsaInAction = wsdlOperation.getProperty(Constants.WSDL_PROPERTY_ACTION_IN); - if (wsaInAction != null) - { - addrExt.setInboundAction(wsaInAction.getValue()); - } - else - { - WSDLProperty messageName = wsdlOperation.getProperty(Constants.WSDL_PROPERTY_MESSAGE_NAME_IN); - addrExt.setInboundAction(tns + "/" + portTypeName + "/" + messageName); - } - - // outbound action - WSDLProperty wsaOutAction = wsdlOperation.getProperty(Constants.WSDL_PROPERTY_ACTION_OUT); - if (wsaOutAction != null) - { - addrExt.setOutboundAction(wsaOutAction.getValue()); - } - else - { - WSDLProperty messageName = wsdlOperation.getProperty(Constants.WSDL_PROPERTY_MESSAGE_NAME_OUT); - addrExt.setOutboundAction(tns + "/" + portTypeName + "/" + messageName); - } - - opMetaData.addExtension(addrExt); - } - - /** * Build default action according to the pattern described in * http://www.w3.org/Submission/2004/SUBM-ws-addressing-20040810/ * Section 3.3.2 'Default Action Pattern'<br> Modified: trunk/src/main/java/org/jboss/ws/deployment/JSR181MetaDataBuilder.java =================================================================== --- trunk/src/main/java/org/jboss/ws/deployment/JSR181MetaDataBuilder.java 2006-07-04 11:35:28 UTC (rev 552) +++ trunk/src/main/java/org/jboss/ws/deployment/JSR181MetaDataBuilder.java 2006-07-04 16:42:35 UTC (rev 553) @@ -296,11 +296,11 @@ if (method.isAnnotationPresent(RequestWrapper.class)) { RequestWrapper anReqWrapper = method.getAnnotation(RequestWrapper.class); - + String localName = (anReqWrapper.localName().length() > 0 ? anReqWrapper.localName() : operationName); String targetNamespace = (anReqWrapper.targetNamespace().length() > 0 ? anReqWrapper.targetNamespace() : epMetaData.getQName().getNamespaceURI()); xmlName = new QName(targetNamespace, localName); - + if (anReqWrapper.className().length() > 0) { requestWrapperType = anReqWrapper.className(); @@ -332,11 +332,11 @@ if (method.isAnnotationPresent(ResponseWrapper.class)) { ResponseWrapper anResWrapper = method.getAnnotation(ResponseWrapper.class); - + String localName = (anResWrapper.localName().length() > 0 ? anResWrapper.localName() : operationName + "Response"); String targetNamespace = (anResWrapper.targetNamespace().length() > 0 ? anResWrapper.targetNamespace() : epMetaData.getQName().getNamespaceURI()); xmlName = new QName(targetNamespace, localName); - + if (anResWrapper.className().length() > 0) { responseWrapperType = anResWrapper.className(); Modified: trunk/src/main/java/org/jboss/ws/jaxrpc/CallImpl.java =================================================================== --- trunk/src/main/java/org/jboss/ws/jaxrpc/CallImpl.java 2006-07-04 11:35:28 UTC (rev 552) +++ trunk/src/main/java/org/jboss/ws/jaxrpc/CallImpl.java 2006-07-04 16:42:35 UTC (rev 553) @@ -23,8 +23,6 @@ // $Id$ -import java.net.MalformedURLException; -import java.net.URL; import java.rmi.RemoteException; import java.util.ArrayList; import java.util.Arrays; @@ -44,37 +42,22 @@ import javax.xml.rpc.Stub; import javax.xml.rpc.encoding.SerializerFactory; import javax.xml.rpc.handler.HandlerChain; -import javax.xml.rpc.handler.MessageContext; -import javax.xml.rpc.soap.SOAPFaultException; import javax.xml.soap.SOAPException; -import javax.xml.soap.SOAPMessage; -import javax.xml.ws.addressing.AddressingProperties; -import javax.xml.ws.addressing.JAXWSAConstants; import org.jboss.logging.Logger; import org.jboss.ws.Constants; -import org.jboss.ws.WSException; -import org.jboss.ws.addressing.AddressingConstantsImpl; -import org.jboss.ws.binding.BindingProvider; -import org.jboss.ws.binding.BindingProviderRegistry; -import org.jboss.ws.binding.EndpointInvocation; import org.jboss.ws.binding.UnboundHeader; +import org.jboss.ws.client.CommonClient; import org.jboss.ws.handler.HandlerChainBaseImpl; import org.jboss.ws.jbossxb.JBossXBDeserializerFactory; import org.jboss.ws.jbossxb.JBossXBSerializerFactory; -import org.jboss.ws.metadata.ClientEndpointMetaData; import org.jboss.ws.metadata.EndpointMetaData; import org.jboss.ws.metadata.OperationMetaData; import org.jboss.ws.metadata.ParameterMetaData; import org.jboss.ws.metadata.ServiceMetaData; import org.jboss.ws.metadata.TypesMetaData; -import org.jboss.ws.metadata.UnifiedMetaData; import org.jboss.ws.metadata.wsdl.xmlschema.JBossXSModel; -import org.jboss.ws.soap.EndpointInfo; -import org.jboss.ws.soap.MessageContextAssociation; -import org.jboss.ws.soap.SOAPConnectionImpl; import org.jboss.ws.soap.SOAPMessageContextImpl; -import org.jboss.ws.utils.HolderUtils; import org.jboss.ws.utils.JavaUtils; /** Provides support for the dynamic invocation of a service endpoint. @@ -85,25 +68,19 @@ * @author Tho...@jb... * @since 10-Oct-2004 */ -public class CallImpl implements Call +public class CallImpl extends CommonClient implements Call { // provide logging private static Logger log = Logger.getLogger(CallImpl.class); // The service that created this call private ServiceImpl jaxrpcService; - // The endpoint together with the operationName uniquely identify the call operation - private EndpointMetaData epMetaData; - // The current operation name - private QName operationName; // The port type name private QName portType; - // A Map<String,Object> of Call properties - private Map<String, Object> properties = new HashMap<String, Object>(); - // Output parameters - private EndpointInvocation epInv; // A Map<QName,UnboundHeader> of header entries private Map<QName, UnboundHeader> unboundHeaders = new LinkedHashMap<QName, UnboundHeader>(); + // A Map<String,Object> of Call properties + private Map<String, Object> properties = new HashMap<String, Object>(); // The set of supported properties private static final Set<String> standardProperties = new HashSet<String>(); @@ -116,7 +93,7 @@ standardProperties.add(Call.SOAPACTION_USE_PROPERTY); standardProperties.add(Call.USERNAME_PROPERTY); standardProperties.add(Call.PASSWORD_PROPERTY); - + standardProperties.add(Stub.ENDPOINT_ADDRESS_PROPERTY); standardProperties.add(Stub.SESSION_MAINTAIN_PROPERTY); standardProperties.add(Stub.USERNAME_PROPERTY); @@ -127,15 +104,11 @@ */ CallImpl(ServiceImpl service) { + super(service.getServiceMetaData()); this.jaxrpcService = service; - - // If the WSDLService has only one endpoint, use it - ServiceMetaData serviceMetaData = service.getServiceMetaData(); - if (serviceMetaData != null && serviceMetaData.getEndpoints().size() == 1) - { - this.epMetaData = serviceMetaData.getEndpoints().get(0); + + if (epMetaData != null) setTargetEndpointAddress(epMetaData.getEndpointAddress()); - } } /** Create a call for a known WSDL endpoint. @@ -144,8 +117,9 @@ */ CallImpl(ServiceImpl service, EndpointMetaData epMetaData) { + super(epMetaData); this.jaxrpcService = service; - this.epMetaData = epMetaData; + setTargetEndpointAddress(epMetaData.getEndpointAddress()); } @@ -156,32 +130,25 @@ */ CallImpl(ServiceImpl service, QName portName, QName opName) throws ServiceException { + super(service.getServiceMetaData(), portName, opName); this.jaxrpcService = service; + + if (epMetaData != null) + setTargetEndpointAddress(epMetaData.getEndpointAddress()); + } - ServiceMetaData serviceMetaData = service.getServiceMetaData(); - if (serviceMetaData != null) - { - EndpointMetaData epMetaData = null; - if (serviceMetaData.getEndpoints().size() > 0) - { - epMetaData = serviceMetaData.getEndpoint(portName); - if (epMetaData == null) - throw new ServiceException("Cannot find endpoint for name: " + portName); - } - - if (epMetaData != null) - { - this.epMetaData = epMetaData; - setTargetEndpointAddress(epMetaData.getEndpointAddress()); - } - } - - if (opName != null) - { - setOperationName(opName); - } + @Override + protected Map<String, Object> getRequestContext() + { + return properties; } + @Override + protected Map<String, Object> getResponseContext() + { + return properties; + } + /** * Add a header that is not bound to an input parameter. * A propriatory extension, that is not part of JAXRPC. @@ -267,20 +234,6 @@ this.properties.put(Stub.ENDPOINT_ADDRESS_PROPERTY, address); } - /** Gets the name of the operation to be invoked using this Call instance. - */ - public QName getOperationName() - { - return this.operationName; - } - - /** Sets the name of the operation to be invoked using this Call instance. - */ - public void setOperationName(QName operationName) - { - this.operationName = operationName; - } - /** Adds a parameter t... [truncated message content] |