You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by js...@apache.org on 2006/02/28 09:21:27 UTC
svn commit: r381590 - in /incubator/tuscany/java/sca/binding.axis/src:
main/java/org/apache/tuscany/binding/axis/builder/
main/java/org/apache/tuscany/binding/axis/engine/config/
main/java/org/apache/tuscany/binding/axis/handler/ test/resources/org/apa...
Author: jsdelfino
Date: Tue Feb 28 00:21:24 2006
New Revision: 381590
URL: http://svn.apache.org/viewcvs?rev=381590&view=rev
Log:
web service entry point bringup - fixed the configuration of the axis engine, and the runtime configuration builders
Modified:
incubator/tuscany/java/sca/binding.axis/src/main/java/org/apache/tuscany/binding/axis/builder/ExternalWebServiceConfigurationBuilder.java
incubator/tuscany/java/sca/binding.axis/src/main/java/org/apache/tuscany/binding/axis/builder/WebServiceEntryPointConfigurationBuilder.java
incubator/tuscany/java/sca/binding.axis/src/main/java/org/apache/tuscany/binding/axis/engine/config/AxisEngineConfigurationFactory.java
incubator/tuscany/java/sca/binding.axis/src/main/java/org/apache/tuscany/binding/axis/handler/ExternalWebServiceClient.java
incubator/tuscany/java/sca/binding.axis/src/main/java/org/apache/tuscany/binding/axis/handler/WebServiceEntryPointBean.java
incubator/tuscany/java/sca/binding.axis/src/main/java/org/apache/tuscany/binding/axis/handler/WebServiceOperationMetaData.java
incubator/tuscany/java/sca/binding.axis/src/test/resources/org/apache/tuscany/binding/axis/assembly/tests/sca.module
Modified: incubator/tuscany/java/sca/binding.axis/src/main/java/org/apache/tuscany/binding/axis/builder/ExternalWebServiceConfigurationBuilder.java
URL: http://svn.apache.org/viewcvs/incubator/tuscany/java/sca/binding.axis/src/main/java/org/apache/tuscany/binding/axis/builder/ExternalWebServiceConfigurationBuilder.java?rev=381590&r1=381589&r2=381590&view=diff
==============================================================================
--- incubator/tuscany/java/sca/binding.axis/src/main/java/org/apache/tuscany/binding/axis/builder/ExternalWebServiceConfigurationBuilder.java (original)
+++ incubator/tuscany/java/sca/binding.axis/src/main/java/org/apache/tuscany/binding/axis/builder/ExternalWebServiceConfigurationBuilder.java Tue Feb 28 00:21:24 2006
@@ -130,7 +130,7 @@
iConfigMap.put(method, iConfig);
}
QualifiedName qName = new QualifiedName(externalService.getName() + "/" + service.getName());
- ProxyConfiguration pConfiguration = new ProxyConfiguration(qName, iConfigMap, null, messageFactory);
+ ProxyConfiguration pConfiguration = new ProxyConfiguration(qName, iConfigMap, serviceContract.getInterface().getClassLoader(), messageFactory);
proxyFactory.setBusinessInterface(serviceContract.getInterface());
proxyFactory.setProxyConfiguration(pConfiguration);
config.addTargetProxyFactory(service.getName(), proxyFactory);
Modified: incubator/tuscany/java/sca/binding.axis/src/main/java/org/apache/tuscany/binding/axis/builder/WebServiceEntryPointConfigurationBuilder.java
URL: http://svn.apache.org/viewcvs/incubator/tuscany/java/sca/binding.axis/src/main/java/org/apache/tuscany/binding/axis/builder/WebServiceEntryPointConfigurationBuilder.java?rev=381590&r1=381589&r2=381590&view=diff
==============================================================================
--- incubator/tuscany/java/sca/binding.axis/src/main/java/org/apache/tuscany/binding/axis/builder/WebServiceEntryPointConfigurationBuilder.java (original)
+++ incubator/tuscany/java/sca/binding.axis/src/main/java/org/apache/tuscany/binding/axis/builder/WebServiceEntryPointConfigurationBuilder.java Tue Feb 28 00:21:24 2006
@@ -15,6 +15,7 @@
import java.lang.reflect.Method;
import java.util.Collection;
+import java.util.HashMap;
import java.util.Map;
import java.util.Set;
@@ -22,15 +23,18 @@
import org.apache.tuscany.binding.axis.config.WebServiceEntryPointRuntimeConfiguration;
import org.apache.tuscany.core.builder.BuilderException;
import org.apache.tuscany.core.builder.RuntimeConfigurationBuilder;
+import org.apache.tuscany.core.builder.impl.EntryPointRuntimeConfiguration;
import org.apache.tuscany.core.config.JavaIntrospectionHelper;
import org.apache.tuscany.core.context.AggregateContext;
import org.apache.tuscany.core.context.QualifiedName;
+import org.apache.tuscany.core.invocation.Interceptor;
import org.apache.tuscany.core.invocation.InvocationConfiguration;
-import org.apache.tuscany.core.invocation.MethodHashMap;
+import org.apache.tuscany.core.invocation.InvocationRuntimeException;
import org.apache.tuscany.core.invocation.ProxyConfiguration;
-import org.apache.tuscany.core.invocation.impl.InvokerInterceptor;
+import org.apache.tuscany.core.invocation.TargetInvoker;
import org.apache.tuscany.core.invocation.spi.ProxyFactory;
import org.apache.tuscany.core.invocation.spi.ProxyFactoryFactory;
+import org.apache.tuscany.core.message.Message;
import org.apache.tuscany.core.message.MessageFactory;
import org.apache.tuscany.core.runtime.RuntimeContext;
import org.apache.tuscany.core.system.annotation.Autowire;
@@ -112,26 +116,23 @@
return;
}
- WebServiceBinding wsBinding=(WebServiceBinding)entryPoint.getBindings().get(0);
-
- WebServiceEntryPointRuntimeConfiguration config = new WebServiceEntryPointRuntimeConfiguration(entryPoint.getName(), entryPoint.getConfiguredService()
- .getService().getName(), messageFactory);
+ EntryPointRuntimeConfiguration config = new WebServiceEntryPointRuntimeConfiguration(entryPoint.getName(), entryPoint.getConfiguredService().getService().getName(), messageFactory);
ConfiguredService configuredService = entryPoint.getConfiguredService();
Service service = configuredService.getService();
ServiceContract serviceContract = service.getServiceContract();
- Map<Method, InvocationConfiguration> iConfigMap = new MethodHashMap();
+ Map<Method, InvocationConfiguration> iConfigMap = new HashMap();
ProxyFactory proxyFactory = proxyFactoryFactory.createProxyFactory();
Set<Method> javaMethods = JavaIntrospectionHelper.getAllUniqueMethods(serviceContract.getInterface());
for (Method method : javaMethods) {
InvocationConfiguration iConfig = new InvocationConfiguration(method);
iConfigMap.put(method, iConfig);
}
- QualifiedName qName = new QualifiedName(entryPoint.getName() + "/" + service.getName());
- ProxyConfiguration pConfiguration = new ProxyConfiguration(qName, iConfigMap, null, messageFactory);
+ QualifiedName qName = new QualifiedName(entryPoint.getConfiguredReference().getTargetConfiguredServices().get(0).getAggregatePart().getName() + "/" + service.getName());
+ ProxyConfiguration pConfiguration = new ProxyConfiguration(qName, iConfigMap, serviceContract.getInterface().getClassLoader(), messageFactory);
proxyFactory.setBusinessInterface(serviceContract.getInterface());
proxyFactory.setProxyConfiguration(pConfiguration);
- config.addTargetProxyFactory(service.getName(), proxyFactory);
+ config.addSourceProxyFactory(service.getName(), proxyFactory);
configuredService.setProxyFactory(proxyFactory);
if (policyBuilder != null) {
// invoke the reference builder to handle additional policy metadata
@@ -139,10 +140,31 @@
}
// add tail interceptor
for (InvocationConfiguration iConfig : (Collection<InvocationConfiguration>) iConfigMap.values()) {
- iConfig.addTargetInterceptor(new InvokerInterceptor());
+ iConfig.addTargetInterceptor(new EntryPointInvokerInterceptor());
}
-
entryPoint.getConfiguredReference().setRuntimeConfiguration(config);
}
+
+ //FIXME same as the InvokerInterceptor except that it doesn't throw an exception in setNext
+ // For some reason another InvokerInterceptor is added after this one, need Jim to look into it
+ // and figure out why.
+ public class EntryPointInvokerInterceptor implements Interceptor {
+
+ public EntryPointInvokerInterceptor() {
+ }
+
+ public Message invoke(Message msg) throws InvocationRuntimeException {
+ TargetInvoker invoker = msg.getTargetInvoker();
+ if (invoker == null) {
+ throw new InvocationRuntimeException("No target invoker specified on message");
+ }
+ return invoker.invoke(msg);
+ }
+
+ public void setNext(Interceptor next) {
+ }
+
+ }
+
}
Modified: incubator/tuscany/java/sca/binding.axis/src/main/java/org/apache/tuscany/binding/axis/engine/config/AxisEngineConfigurationFactory.java
URL: http://svn.apache.org/viewcvs/incubator/tuscany/java/sca/binding.axis/src/main/java/org/apache/tuscany/binding/axis/engine/config/AxisEngineConfigurationFactory.java?rev=381590&r1=381589&r2=381590&view=diff
==============================================================================
--- incubator/tuscany/java/sca/binding.axis/src/main/java/org/apache/tuscany/binding/axis/engine/config/AxisEngineConfigurationFactory.java (original)
+++ incubator/tuscany/java/sca/binding.axis/src/main/java/org/apache/tuscany/binding/axis/engine/config/AxisEngineConfigurationFactory.java Tue Feb 28 00:21:24 2006
@@ -18,19 +18,27 @@
import java.io.IOException;
import java.io.InputStream;
+import java.lang.reflect.Method;
+import java.net.MalformedURLException;
import java.net.URL;
+import java.util.ArrayList;
import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
import javax.servlet.ServletConfig;
import javax.wsdl.Definition;
-import javax.wsdl.Message;
import javax.wsdl.Operation;
import javax.wsdl.Port;
import javax.wsdl.PortType;
import javax.xml.namespace.QName;
+import javax.xml.rpc.Service;
+import javax.xml.rpc.ServiceException;
+import javax.xml.rpc.ServiceFactory;
import org.apache.axis.EngineConfiguration;
import org.apache.axis.EngineConfigurationFactory;
+import org.apache.axis.MessageContext;
import org.apache.axis.configuration.FileProvider;
import org.apache.axis.configuration.SimpleProvider;
import org.apache.axis.constants.Style;
@@ -39,22 +47,21 @@
import org.apache.axis.description.OperationDesc;
import org.apache.axis.description.ParameterDesc;
import org.apache.axis.handlers.soap.SOAPService;
-import org.apache.axis.providers.java.MsgProvider;
+import org.apache.axis.providers.java.RPCProvider;
import org.apache.tuscany.binding.axis.assembly.WebServiceBinding;
import org.apache.tuscany.binding.axis.handler.WebServiceEntryPointBean;
-import org.apache.tuscany.binding.axis.handler.WebServiceOperationMetaData;
import org.apache.tuscany.binding.axis.handler.WebServicePortMetaData;
import org.apache.tuscany.common.resource.ResourceLoader;
+import org.apache.tuscany.core.config.JavaIntrospectionHelper;
import org.apache.tuscany.core.context.AggregateContext;
import org.apache.tuscany.core.context.webapp.TuscanyWebAppRuntime;
-import org.apache.tuscany.model.assembly.AssemblyFactory;
+import org.apache.tuscany.core.invocation.spi.ProxyFactory;
import org.apache.tuscany.model.assembly.AssemblyModelContext;
import org.apache.tuscany.model.assembly.Binding;
import org.apache.tuscany.model.assembly.EntryPoint;
import org.apache.tuscany.model.assembly.Module;
-import org.apache.tuscany.model.assembly.impl.AssemblyFactoryImpl;
-import org.eclipse.xsd.util.XSDConstants;
import org.osoa.sca.ServiceRuntimeException;
+import org.osoa.sca.ServiceUnavailableException;
/**
*/
@@ -104,8 +111,6 @@
*/
public EngineConfiguration getServerEngineConfig() {
- AssemblyFactory assemblyFactory = new AssemblyFactoryImpl();
-
// Get the current SCA module context
AggregateContext moduleContext = tuscanyRuntime.getModuleComponentContext();
tuscanyRuntime.start();
@@ -133,79 +138,119 @@
EntryPoint entryPoint = (EntryPoint) i.next();
Binding binding = (Binding) entryPoint.getBindings().get(0);
if (binding instanceof WebServiceBinding) {
+
+ // Get the proxy factory associated with the entry point
+ final ProxyFactory proxyFactory=(ProxyFactory)entryPoint.getConfiguredService().getProxyFactory();
+
+ // Create a new SOAP service
+ SOAPService service = new SOAPService(new RPCProvider() {
+ protected Object makeNewServiceObject(MessageContext arg0, String arg1) throws Exception {
+
+ // The SOAP service will delegate to a dynamic proxy
+ return proxyFactory.createProxy();
+ }
+ });
+
+ // Get the WSDL definition and port
WebServiceBinding wsBinding = (WebServiceBinding) binding;
Definition definition=wsBinding.getWSDLDefinition();
Port port=wsBinding.getWSDLPort();
- QName qname = new QName(definition.getTargetNamespace(), port.getName());
- if (qname != null) {
- WebServicePortMetaData wsdlPortInfo = new WebServicePortMetaData(definition, port, null, false);
-
- // Create a new message SOAP service
- SOAPService service = new SOAPService(new MsgProvider());
- service.setOption(MsgProvider.OPTION_WSDL_TARGETNAMESPACE, wsdlPortInfo.getPortName().getNamespaceURI());
- service.setOption(MsgProvider.OPTION_WSDL_SERVICEELEMENT, wsdlPortInfo.getServiceName().getLocalPart());
- service.setOption(MsgProvider.OPTION_WSDL_SERVICEPORT, wsdlPortInfo.getPortName().getLocalPart());
- service.setOption(MsgProvider.OPTION_CLASSNAME, WebServiceEntryPointBean.class.getName());
- service.setOption(MsgProvider.OPTION_WSDL_PORTTYPE, wsdlPortInfo.getPortTypeName().getLocalPart());
-
- // Create a service description
- JavaServiceDesc serviceDesc = (JavaServiceDesc) service.getServiceDescription();
- serviceDesc.setName(entryPoint.getName());
- String wsdlFile = definition.getDocumentBaseURI();
- if (wsdlFile.startsWith("file:"))
- wsdlFile = wsdlFile.substring(5);
- serviceDesc.setWSDLFile(wsdlFile);
- serviceDesc.setDefaultNamespace(wsdlPortInfo.getPortName().getNamespaceURI());
- boolean rpcStyle = wsdlPortInfo.getStyle().equals(Style.RPC_STR);
- serviceDesc.setStyle(rpcStyle ? Style.RPC : Style.DOCUMENT);
- serviceDesc.setUse(wsdlPortInfo.getUse().equals(Use.ENCODED_STR) ? Use.ENCODED : Use.LITERAL);
- serviceDesc.setImplClass(WebServiceEntryPointBean.class);
-
- // Create operation descriptions for all the operations
- PortType wsdlPortType = wsdlPortInfo.getPortType();
- for (Iterator j = wsdlPortType.getOperations().iterator(); j.hasNext();) {
- Operation wsdlOperation = (Operation) j.next();
- String operationName = wsdlOperation.getName();
-
- OperationDesc operationDesc = new OperationDesc();
- operationDesc.setName(operationName);
- operationDesc.setMessageOperationStyle(OperationDesc.MSG_METHOD_SOAPENVELOPE);
- operationDesc.setMethod(WebServiceEntryPointBean.SERVICE_METHOD);
- String soapAction = wsdlPortInfo.getOperationMetaData(operationName).getSOAPAction();
- if (soapAction != null)
- operationDesc.setSoapAction(soapAction);
-
- if (rpcStyle) {
- operationDesc.setElementQName(new QName("", operationName));
- } else {
- WebServiceOperationMetaData operationMetaData = wsdlPortInfo.getOperationMetaData(operationName);
- operationDesc.setElementQName((QName) operationMetaData.getOperationSignature().get(0));
- }
-
- Message inputMessage=wsdlOperation.getInput()!=null? wsdlOperation.getInput().getMessage():null;
- if (inputMessage!=null & !inputMessage.getParts().isEmpty()) {
- ParameterDesc parameterDesc = new ParameterDesc();
- QName anyQName = new QName(XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001, "any");
- parameterDesc.setTypeQName(anyQName);
- parameterDesc.setQName(anyQName);
- parameterDesc.setJavaType(Object.class);
- operationDesc.addParameter(parameterDesc);
- }
-
- Message outputMessage=wsdlOperation.getOutput()!=null? wsdlOperation.getOutput().getMessage():null;
- if (outputMessage!=null & !outputMessage.getParts().isEmpty()) {
- QName anyQName = new QName(XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001, "any");
- operationDesc.setReturnType(anyQName);
- operationDesc.setReturnQName(anyQName);
- operationDesc.setReturnClass(Object.class);
- }
+ WebServicePortMetaData wsPortMetaData = new WebServicePortMetaData(definition, port, null, false);
+
+ // Configure the SOAP service
+ service.setOption(RPCProvider.OPTION_WSDL_TARGETNAMESPACE, wsPortMetaData.getPortName().getNamespaceURI());
+ service.setOption(RPCProvider.OPTION_WSDL_SERVICEELEMENT, wsPortMetaData.getServiceName().getLocalPart());
+ service.setOption(RPCProvider.OPTION_WSDL_SERVICEPORT, wsPortMetaData.getPortName().getLocalPart());
+ service.setOption(RPCProvider.OPTION_CLASSNAME, WebServiceEntryPointBean.class.getName());
+ service.setOption(RPCProvider.OPTION_WSDL_PORTTYPE, wsPortMetaData.getPortTypeName().getLocalPart());
+
+ // Create a service description
+ JavaServiceDesc serviceDesc = (JavaServiceDesc) service.getServiceDescription();
+ serviceDesc.setName(entryPoint.getName());
+ String wsdlFile = definition.getDocumentBaseURI();
+ if (wsdlFile.startsWith("file:"))
+ wsdlFile = wsdlFile.substring(5);
+ serviceDesc.setWSDLFile(wsdlFile);
+ serviceDesc.setDefaultNamespace(wsPortMetaData.getPortName().getNamespaceURI());
+ serviceDesc.setStyle(Style.DOCUMENT);
+ serviceDesc.setUse(Use.LITERAL);
+
+ // Get the service interface
+ Class serviceInterface=entryPoint.getConfiguredService().getService().getServiceContract().getInterface();
+ Set methods=JavaIntrospectionHelper.getAllUniqueMethods(serviceInterface);
+ serviceDesc.setAllowedMethods(new ArrayList(methods));
+
+ // Create a JAX-RPC service
+ QName wsdlServiceName = wsPortMetaData.getService().getQName();
+ Service jaxrpcService;
+ try {
+ URL url=new URL(wsBinding.getWSDLDefinition().getDocumentBaseURI());
+ jaxrpcService = ServiceFactory.newInstance().createService(url, wsdlServiceName);
+ } catch (ServiceException e) {
+ throw new ServiceUnavailableException(e);
+ } catch (MalformedURLException e) {
+ throw new ServiceUnavailableException(e);
+ }
- serviceDesc.addOperationDesc(operationDesc);
+ // Create operation descriptions for all the operations
+ PortType wsdlPortType = wsPortMetaData.getPortType();
+ for (Iterator j = wsdlPortType.getOperations().iterator(); j.hasNext();) {
+ Operation wsdlOperation = (Operation) j.next();
+ String operationName = wsdlOperation.getName();
+
+ // Create a JAX RPC call object
+ QName portName = wsPortMetaData.getPortName();
+ org.apache.axis.client.Call call;
+ try {
+ call = (org.apache.axis.client.Call) jaxrpcService.createCall(portName, operationName);
+ } catch (ServiceException e) {
+ throw new IllegalArgumentException(e);
}
- // Deploy the service
- dynamicConfigurationProvider.deployService(entryPoint.getName(), service);
+ OperationDesc operationDesc = call.getOperation();
+ operationDesc.setName(operationName);
+ List<Class> argTypes=new ArrayList<Class>();
+ for (ParameterDesc parameterDesc : (List<ParameterDesc>)operationDesc.getAllInParams()) {
+ argTypes.add(parameterDesc.getJavaType());
+ }
+ Method method=JavaIntrospectionHelper.findClosestMatchingMethod(operationName, argTypes.toArray(new Class[argTypes.size()]), methods);
+ operationDesc.setMethod(method);
+
+// OperationDesc operationDesc = new OperationDesc();
+// operationDesc.setName(operationName);
+// Method method=JavaIntrospectionHelper.findClosestMatchingMethod(operationName, new Class[]{String.class}, methods);
+// operationDesc.setMethod(method);
+//
+// WebServiceOperationMetaData wsOperationMetaData = wsPortMetaData.getOperationMetaData(operationName);
+// String soapAction = wsOperationMetaData.getSOAPAction();
+// if (soapAction != null && soapAction.length()!=0)
+// operationDesc.setSoapAction(soapAction);
+//
+// operationDesc.setElementQName((QName) wsOperationMetaData.getOperationSignature().get(0));
+//
+// Message inputMessage=wsdlOperation.getInput()!=null? wsdlOperation.getInput().getMessage():null;
+// if (inputMessage!=null & !inputMessage.getParts().isEmpty()) {
+// ParameterDesc parameterDesc = new ParameterDesc();
+// QName anyQName = new QName(XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001, "any");
+// parameterDesc.setTypeQName(anyQName);
+// parameterDesc.setQName(anyQName);
+// parameterDesc.setJavaType(Object.class);
+// operationDesc.addParameter(parameterDesc);
+// }
+//
+// Message outputMessage=wsdlOperation.getOutput()!=null? wsdlOperation.getOutput().getMessage():null;
+// if (outputMessage!=null & !outputMessage.getParts().isEmpty()) {
+// QName anyQName = new QName(XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001, "any");
+// operationDesc.setReturnType(anyQName);
+// operationDesc.setReturnQName(anyQName);
+// operationDesc.setReturnClass(Object.class);
+// }
+
+ serviceDesc.addOperationDesc(operationDesc);
}
+
+ // Deploy the service
+ dynamicConfigurationProvider.deployService(entryPoint.getName(), service);
}
}
Modified: incubator/tuscany/java/sca/binding.axis/src/main/java/org/apache/tuscany/binding/axis/handler/ExternalWebServiceClient.java
URL: http://svn.apache.org/viewcvs/incubator/tuscany/java/sca/binding.axis/src/main/java/org/apache/tuscany/binding/axis/handler/ExternalWebServiceClient.java?rev=381590&r1=381589&r2=381590&view=diff
==============================================================================
--- incubator/tuscany/java/sca/binding.axis/src/main/java/org/apache/tuscany/binding/axis/handler/ExternalWebServiceClient.java (original)
+++ incubator/tuscany/java/sca/binding.axis/src/main/java/org/apache/tuscany/binding/axis/handler/ExternalWebServiceClient.java Tue Feb 28 00:21:24 2006
@@ -14,6 +14,8 @@
package org.apache.tuscany.binding.axis.handler;
import java.lang.reflect.Method;
+import java.net.MalformedURLException;
+import java.net.URL;
import java.rmi.RemoteException;
import java.util.Map;
import java.util.Set;
@@ -39,9 +41,9 @@
public class ExternalWebServiceClient {
- private WebServicePortMetaData portMetaData;
+ private WebServicePortMetaData wsPortMetaData;
private Service jaxrpcService;
- private Map<Method, Call> calls=new MethodHashMap();
+ private Map<Method, Call> jaxrpcCalls=new MethodHashMap();
/**
* Constructs a new ExternalWebServiceClient.
@@ -51,21 +53,24 @@
public ExternalWebServiceClient(ExternalService externalService, WebServiceBinding wsBinding) {
// Create a port metadata info object to hold the port information
- portMetaData = new WebServicePortMetaData(wsBinding.getWSDLDefinition(), wsBinding.getWSDLPort(), wsBinding.getURI(), false);
+ wsPortMetaData = new WebServicePortMetaData(wsBinding.getWSDLDefinition(), wsBinding.getWSDLPort(), wsBinding.getURI(), false);
// Create a JAX-RPC service
- QName wsdlServiceName = portMetaData.getService().getQName();
+ QName wsdlServiceName = wsPortMetaData.getService().getQName();
try {
- jaxrpcService = ServiceFactory.newInstance().createService(wsdlServiceName);
+ URL url=new URL(wsBinding.getWSDLDefinition().getDocumentBaseURI());
+ jaxrpcService = ServiceFactory.newInstance().createService(url, wsdlServiceName);
} catch (ServiceException e) {
throw new ServiceUnavailableException(e);
+ } catch (MalformedURLException e) {
+ throw new ServiceUnavailableException(e);
}
// Create JAX-RPC calls for all the methods on the service contract
Set<Method> methods=JavaIntrospectionHelper.getAllUniqueMethods(externalService.getConfiguredService().getService().getServiceContract().getInterface());
for (Method method : methods) {
Call call=createCall(method);
- calls.put(method, call);
+ jaxrpcCalls.put(method, call);
}
}
@@ -78,7 +83,7 @@
private Call createCall(Method method) {
// Create a JAX RPC call object
- QName portName = portMetaData.getPortName();
+ QName portName = wsPortMetaData.getPortName();
Call call;
try {
call = (Call) jaxrpcService.createCall(portName, method.getName());
@@ -87,7 +92,7 @@
}
// Set the target endpoint address
- String endpoint = portMetaData.getEndpoint();
+ String endpoint = wsPortMetaData.getEndpoint();
if (endpoint != null) {
String originalEndpoint = call.getTargetEndpointAddress();
if (!endpoint.equals(originalEndpoint))
@@ -104,7 +109,7 @@
* @return
*/
public Object invoke(Method method, Object[] args) {
- Call call=calls.get(method);
+ Call call=jaxrpcCalls.get(method);
try {
return call.invoke(args);
} catch (RemoteException e) {
Modified: incubator/tuscany/java/sca/binding.axis/src/main/java/org/apache/tuscany/binding/axis/handler/WebServiceEntryPointBean.java
URL: http://svn.apache.org/viewcvs/incubator/tuscany/java/sca/binding.axis/src/main/java/org/apache/tuscany/binding/axis/handler/WebServiceEntryPointBean.java?rev=381590&r1=381589&r2=381590&view=diff
==============================================================================
--- incubator/tuscany/java/sca/binding.axis/src/main/java/org/apache/tuscany/binding/axis/handler/WebServiceEntryPointBean.java (original)
+++ incubator/tuscany/java/sca/binding.axis/src/main/java/org/apache/tuscany/binding/axis/handler/WebServiceEntryPointBean.java Tue Feb 28 00:21:24 2006
@@ -16,42 +16,29 @@
*/
package org.apache.tuscany.binding.axis.handler;
-import java.lang.reflect.Method;
-import java.util.Map;
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Proxy;
import javax.xml.rpc.ServiceException;
import javax.xml.rpc.server.ServiceLifecycle;
import javax.xml.rpc.server.ServletEndpointContext;
import org.apache.axis.MessageContext;
-import org.apache.axis.message.SOAPEnvelope;
-import org.apache.tuscany.core.addressing.EndpointReference;
import org.apache.tuscany.core.context.AggregateContext;
-import org.apache.tuscany.model.types.wsdl.WSDLServiceContract;
-
-//FIXME most of this class is commented out for now
+import org.apache.tuscany.core.context.EntryPointContext;
+import org.apache.tuscany.model.assembly.Aggregate;
+import org.apache.tuscany.model.assembly.EntryPoint;
+import org.osoa.sca.CurrentModuleContext;
+import org.osoa.sca.ServiceRuntimeException;
/**
- * Bean implementation class for web service entry points..
+ * Base implementation class for web service entry points beans.
*/
public class WebServiceEntryPointBean implements ServiceLifecycle {
private AggregateContext moduleContext;
- private WSDLServiceContract serviceContract;
- private WebServicePortMetaData portMetaData;
- private EndpointReference toEndpointReference;
- private EndpointReference fromEndpointReference;
+ private EntryPointContext entryPointContext;
+ private InvocationHandler invocationHandler;
private Object proxy;
- private Map<String, Method> methodMap;
-
- public final static Method SERVICE_METHOD = getServiceMethod();
-
- private static Method getServiceMethod() {
- try {
- return WebServiceEntryPointBean.class.getMethod("processSOAPEnvelope", new Class[]{SOAPEnvelope.class, SOAPEnvelope.class});
- } catch (Throwable e) {
- return null;
- }
- }
/**
* Constructor.
@@ -83,157 +70,35 @@
* Initialize.
*/
protected void initialize(String entryPointName) {
-// try {
-//
-// // Get the current module component, module and entry point
-// moduleContext = (AggregateContext) CurrentModuleContext.getContext();
-//
-// Module module = (Module)moduleContext.getAggregate();
-// EntryPoint entryPoint = module.getEntryPoint(entryPointName);
-// if (entryPoint == null) {
-// throw new ServiceRuntimeException("Entry point not found: " + entryPointName);
-// }
-//
-// // Get the target service
-// ConfiguredReference referenceValue = entryPoint.getConfiguredReference();
-// ConfiguredService targetServiceEndpoint = referenceValue.getTargetConfiguredServices().get(0);
-//
-// // Create a service reference for the target service
-// AssemblyFactory assemblyFactory = new AssemblyFactoryImpl();
-// toEndpointReference = new AddressingFactoryImpl().createEndpointReference();
-// //FIXME
-// //toEndpointReference.setModuleContext(moduleContext);
-// ServiceURI serviceAddress = assemblyFactory.createServiceURI(moduleContext.getModuleComponent(), targetServiceEndpoint);
-// toEndpointReference.setAddress(serviceAddress.getAddress());
-//
-// // Get the entry point interface
-// ServiceContract serviceInterface = entryPoint.getServiceContract();
-// InterfaceType interfaceEClass = serviceInterface.getInterfaceType();
-// if (interfaceEClass != null)
-// toEndpointReference.setPortTypeName(serviceInterface.getInterface());
-//
-// // Create the target service
-// //FIXME
-// //toEndpointReference.getService();
-//
-// // Create a service reference for the entry point itself
-// fromEndpointReference = new AddressingFactoryImpl().createEndpointReference();
-// //FIXME
-// //fromEndpointReference.setModuleContext(moduleContext);
-// ServiceURI fromAddress = assemblyFactory.createServiceURI(moduleContext.getModuleComponent(), entryPoint.getConfiguredReference());
-// fromEndpointReference.setAddress(fromAddress.getAddress());
-//
-// // Get the WSDL port name
-// WebServiceBinding wsBinding = (WebServiceBinding) entryPoint.getBindings().get(0);
-// QName wsdlPortName = assemblyFactory.createQName(wsBinding.getWSDLPort());
-//
-// WSDLTypeHelper typeHelper = moduleContext.getAssemblyModelContext().getWSDLTypeHelper();
-//
-// // Get the WSDL definition for this port
-// Definition definition = typeHelper.getWSDLDefinition(wsdlPortName.getNamespaceURI());
-// if (definition == null) {
-// throw new IllegalArgumentException("Unable to locate WSDL package for target namespace " + wsdlPortName.getNamespaceURI());
-// }
-//
-// // Create a port info object to hold the WSDL port info
-// portMetaData = new WebServicePortMetaData(typeHelper, definition, wsdlPortName, null, true);
-//
-// // Get the EInterface representing the WSDL portType
-// QName portTypeName = portMetaData.getPortTypeName();
-// serviceContract = typeHelper.getWSDLInterfaceType(portTypeName);
-// if (serviceContract == null) {
-// throw new ServiceRuntimeException("Unable to get metadata for WSDL portType " + portTypeName);
-// }
-//
-// // Create a proxy
-// ProxyFactory proxyFactory = (ProxyFactory) targetServiceEndpoint.getProxyFactory();
-// proxy = proxyFactory.createProxy();
-// Method[] methods = proxy.getClass().getMethods();
-// methodMap = new HashMap<String, Method>();
-// for (int i = 0; i < methods.length; i++) {
-// methodMap.put(methods[i].getName(), methods[i]);
-// }
-//
-// } catch (Exception e) {
-// throw new ServiceRuntimeException(e);
-// }
+
+ // Get the current aggregate context
+ moduleContext = (AggregateContext) CurrentModuleContext.getContext();
+
+ // Get the current entry point context
+ entryPointContext = (EntryPointContext)moduleContext.getContext(entryPointName);
+ if (entryPointContext == null) {
+ throw new ServiceRuntimeException("Entry point not found: " + entryPointName);
+ }
+
+ // Get the service interface
+ Aggregate aggregate=moduleContext.getAggregate();
+ EntryPoint entryPoint=aggregate.getEntryPoint(entryPointName);
+ Class serviceInterface=entryPoint.getConfiguredService().getService().getServiceContract().getInterface();
+
+ // Get the invocation handler for the entry point
+ invocationHandler=(InvocationHandler)entryPointContext.getInstance(null);
+
+ // Create a dynamic proxy
+ // The proxy implements the service interface and delegates to the invocation handler
+ proxy=Proxy.newProxyInstance(serviceInterface.getClassLoader(), new Class[]{serviceInterface}, invocationHandler);
}
/**
- * Process the SOAP envelope passed by the Axis runtime
- *
- * @param requestEnvelope
+ * Returns the dynamic proxy
+ * @return
*/
- public void processSOAPEnvelope(SOAPEnvelope requestEnvelope, SOAPEnvelope responseEnvelope) {
-// try {
-//
-// // Get the SOAP body
-// SOAPBody soapBody = (SOAPBody) requestEnvelope.getBody();
-//
-// WebServiceOperationMetaData operationMetaData = portMetaData.getOperationMetaData(soapBody);
-// if (operationMetaData == null) {
-// throw new IllegalArgumentException("Failed to resolve operation: " + soapBody);
-// }
-// // Get the WSDL operation
-// Operation wsdlOperation = operationMetaData.getBindingOperation().getOperation();
-//
-// String operationName = wsdlOperation.getName();
-// WSDLOperationType operationType = (WSDLOperationType) serviceContract.getOperationType(operationName);
-//
-// // Create the appropriate mediator
-// boolean rpcEncoded = operationMetaData.getUse().equals("encoded");
-// SOAPMediator mediator;
-// if (operationMetaData.getStyle().equals("rpc")) {
-// if (rpcEncoded) {
-// mediator = new SOAPRPCEncodedMediatorImpl(portMetaData);
-// } else {
-// mediator = new SOAPRPCLiteralMediatorImpl(portMetaData);
-// }
-// } else {
-// mediator = new SOAPDocumentLiteralMediatorImpl(portMetaData);
-// }
-//
-// // Read the SOAP envelope into an SCA message
-// Message message = new MessageFactoryImpl().createMessage();
-// mediator.readRequest(moduleContext, requestEnvelope, message, operationType);
-//
-// // Set the message ID
-// message.setMessageID(new AddressingFactoryImpl().createMessageID());
-//
-// // Set the action header
-// message.setAction(operationName);
-// message.setOperationName(operationName);
-//
-// // Set the endpoint reference header
-// message.setEndpointReference(toEndpointReference);
-//
-// // Set the callback endpoint reference
-// message.setFrom(fromEndpointReference);
-//
-// Object[] args = ExternalWebServiceHandler.getRequest(message, operationType);
-// Object result = methodMap.get(operationName).invoke(proxy, args);
-//
-// // Send the message
-// Message responseMessage = ExternalWebServiceHandler.createResponseMessage(moduleContext, operationType, result);
-//
-// // Write the response message into the response SOAP envelope
-// SOAPEnvelope tempEnvelope = new SOAPEnvelopeImpl();
-// mediator.writeResponse(moduleContext, responseMessage, operationType, tempEnvelope);
-// for (Iterator i = tempEnvelope.getHeader().getChildElements(); i.hasNext();) {
-// responseEnvelope.getHeader().addChildElement((MessageElement) i.next());
-// }
-// for (Iterator i = tempEnvelope.getBody().getChildElements(); i.hasNext();) {
-// responseEnvelope.getBody().addChildElement((MessageElement) i.next());
-// }
-//
-// } catch (Throwable e) {
-// if (e instanceof ServiceRuntimeException) {
-// throw (ServiceRuntimeException) e;
-// }
-//
-// throw new ServiceRuntimeException(e);
-// }
+ protected Object getProxy() {
+ return proxy;
}
-
-
+
}
Modified: incubator/tuscany/java/sca/binding.axis/src/main/java/org/apache/tuscany/binding/axis/handler/WebServiceOperationMetaData.java
URL: http://svn.apache.org/viewcvs/incubator/tuscany/java/sca/binding.axis/src/main/java/org/apache/tuscany/binding/axis/handler/WebServiceOperationMetaData.java?rev=381590&r1=381589&r2=381590&view=diff
==============================================================================
--- incubator/tuscany/java/sca/binding.axis/src/main/java/org/apache/tuscany/binding/axis/handler/WebServiceOperationMetaData.java (original)
+++ incubator/tuscany/java/sca/binding.axis/src/main/java/org/apache/tuscany/binding/axis/handler/WebServiceOperationMetaData.java Tue Feb 28 00:21:24 2006
@@ -177,16 +177,19 @@
javax.wsdl.extensions.soap.SOAPBody soapBody = getSOAPBody(input);
if (soapBody != null) {
List parts = soapBody.getParts();
- List names = new ArrayList();
- for (Iterator i = parts.iterator(); i.hasNext();) {
- Object part = i.next();
- if (part instanceof String)
- names.add(part);
- else if (part instanceof Part) {
- names.add(((Part) part).getName());
+ if (parts!=null) {
+ List names = new ArrayList();
+ for (Iterator i = parts.iterator(); i.hasNext();) {
+ Object part = i.next();
+ if (part instanceof String)
+ names.add(part);
+ else if (part instanceof Part) {
+ names.add(((Part) part).getName());
+ }
}
- }
- return names;
+ return names;
+ } else
+ return null;
} else
return null;
}
Modified: incubator/tuscany/java/sca/binding.axis/src/test/resources/org/apache/tuscany/binding/axis/assembly/tests/sca.module
URL: http://svn.apache.org/viewcvs/incubator/tuscany/java/sca/binding.axis/src/test/resources/org/apache/tuscany/binding/axis/assembly/tests/sca.module?rev=381590&r1=381589&r2=381590&view=diff
==============================================================================
--- incubator/tuscany/java/sca/binding.axis/src/test/resources/org/apache/tuscany/binding/axis/assembly/tests/sca.module (original)
+++ incubator/tuscany/java/sca/binding.axis/src/test/resources/org/apache/tuscany/binding/axis/assembly/tests/sca.module Tue Feb 28 00:21:24 2006
@@ -21,13 +21,13 @@
<entryPoint name="AccountService">
<interface.java interface="org.apache.tuscany.binding.axis.assembly.tests.bigbank.account.services.account.AccountService"/>
<binding.ws port="http://www.bigbank.com/AccountService/#AccountServiceSOAP"/>
- <reference>AccountServiceComponent</reference>
+ <reference>AccountExternalService</reference>
</entryPoint>
<entryPoint name="AccountService2">
<interface.wsdl interface="http://www.bigbank.com/AccountService/#AccountService"/>
<binding.ws port="http://www.bigbank.com/AccountService/#AccountServiceSOAP"/>
- <reference>AccountServiceComponent</reference>
+ <reference>AccountExternalService</reference>
</entryPoint>
<component name="AccountServiceComponent">
@@ -44,6 +44,11 @@
</component>
-->
+ <externalService name="AccountExternalService">
+ <interface.wsdl interface="http://www.bigbank.com/AccountService/#AccountService"/>
+ <binding.ws port="http://www.bigbank.com/AccountService/#AccountServiceSOAP"/>
+ </externalService>
+
<externalService name="StockQuoteService">
<interface.java interface="org.apache.tuscany.binding.axis.assembly.tests.bigbank.account.services.stockquote.StockQuoteService"/>
<binding.ws port="http://webservice.stockquote#StockQuoteWebService"/>