Author: erwan
Date: Wed Jun 30 10:52:12 2010 New Revision: 959261 URL: http://svn.apache.org/viewvc?rev=959261&view=rev Log: OFBIZ-3798 Add xml-rpc engine on serviceengine - A new patch from Nicolas Malin (https://issues.apache.org/jira/browse/OFBIZ-3798) - Also updating xml-rpc libs from 3.0.1 to 3.1.2 Added: ofbiz/trunk/framework/base/lib/ws-commons-java5-1.0.1.jar - copied unchanged from r959249, ofbiz/trunk/framework/webapp/lib/ws-commons-java5-1.0.1.jar ofbiz/trunk/framework/base/lib/ws-commons-util-1.0.2.jar (with props) ofbiz/trunk/framework/base/lib/xmlrpc-client-3.1.2.jar (with props) ofbiz/trunk/framework/base/lib/xmlrpc-common-3.1.2.jar (with props) ofbiz/trunk/framework/base/lib/xmlrpc-server-3.1.2.jar (with props) ofbiz/trunk/framework/service/src/org/ofbiz/service/engine/XMLRPCClientEngine.java (with props) ofbiz/trunk/framework/service/src/org/ofbiz/service/test/AbstractXmlRpcTestCase.java - copied, changed from r959249, ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/test/AbstractXmlRpcTestCase.java ofbiz/trunk/framework/service/src/org/ofbiz/service/test/XmlRpcTests.java - copied, changed from r959249, ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/test/XmlRpcTests.java ofbiz/trunk/framework/service/src/org/ofbiz/service/xmlrpc/ - copied from r959249, ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/xmlrpc/ Removed: ofbiz/trunk/framework/webapp/lib/ws-commons-java5-1.0.1.jar ofbiz/trunk/framework/webapp/lib/ws-commons-util-1.0.1.jar ofbiz/trunk/framework/webapp/lib/xmlrpc-client-3.0.jar ofbiz/trunk/framework/webapp/lib/xmlrpc-common-3.0.jar ofbiz/trunk/framework/webapp/lib/xmlrpc-server-3.0.jar ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/test/AbstractXmlRpcTestCase.java ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/test/XmlRpcTests.java ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/xmlrpc/ Modified: ofbiz/trunk/.classpath ofbiz/trunk/LICENSE ofbiz/trunk/framework/service/config/serviceengine.xml ofbiz/trunk/framework/service/dtd/service-config.xsd ofbiz/trunk/framework/service/servicedef/services_test_se.xml ofbiz/trunk/framework/service/src/org/ofbiz/service/config/ServiceConfigUtil.java ofbiz/trunk/framework/service/src/org/ofbiz/service/xmlrpc/AliasSupportedTransportFactory.java ofbiz/trunk/framework/service/src/org/ofbiz/service/xmlrpc/XmlRpcClient.java ofbiz/trunk/framework/service/testdef/servicetests.xml ofbiz/trunk/framework/webapp/testdef/webapptests.xml Modified: ofbiz/trunk/.classpath URL: http://svn.apache.org/viewvc/ofbiz/trunk/.classpath?rev=959261&r1=959260&r2=959261&view=diff ============================================================================== --- ofbiz/trunk/.classpath (original) +++ ofbiz/trunk/.classpath Wed Jun 30 10:52:12 2010 @@ -43,9 +43,15 @@ <classpathentry kind="lib" path="framework/base/lib/serializer-2.9.1.jar"/> <classpathentry kind="lib" path="framework/base/lib/Tidy.jar"/> <classpathentry kind="lib" path="framework/base/lib/xercesImpl-2.9.1.jar"/> + <classpathentry kind="lib" path="framework/base/lib/ws-commons-java5-1.0.1.jar"/> + <classpathentry kind="lib" path="framework/base/lib/ws-commons-util-1.0.2.jar"/> + <classpathentry kind="lib" path="framework/base/lib/xml-apis-2.9.1.jar"/> <classpathentry kind="lib" path="framework/base/lib/xml-apis-ext-1.3.04.jar"/> <classpathentry kind="lib" path="framework/base/lib/xmlgraphics-commons-1.3.1.jar"/> + <classpathentry kind="lib" path="framework/base/lib/xmlrpc-client-3.1.2.jar"/> + <classpathentry kind="lib" path="framework/base/lib/xmlrpc-common-3.1.2.jar"/> + <classpathentry kind="lib" path="framework/base/lib/xmlrpc-server-3.1.2.jar"/> <classpathentry kind="lib" path="framework/base/lib/xstream-1.3.1.jar"/> <classpathentry kind="lib" path="framework/base/lib/xpp3_min-1.1.4c.jar"/> <classpathentry kind="lib" path="framework/base/lib/commons/commons-beanutils-1.7.0.jar"/> @@ -144,11 +150,6 @@ <classpathentry kind="lib" path="framework/webapp/lib/json-lib-2.2.3-jdk15.jar"/> <classpathentry kind="lib" path="framework/webapp/lib/rome-0.9.jar"/> <classpathentry kind="lib" path="framework/webapp/lib/velocity-1.6.1.jar"/> - <classpathentry kind="lib" path="framework/webapp/lib/ws-commons-java5-1.0.1.jar"/> - <classpathentry kind="lib" path="framework/webapp/lib/ws-commons-util-1.0.1.jar"/> - <classpathentry kind="lib" path="framework/webapp/lib/xmlrpc-client-3.0.jar"/> - <classpathentry kind="lib" path="framework/webapp/lib/xmlrpc-common-3.0.jar"/> - <classpathentry kind="lib" path="framework/webapp/lib/xmlrpc-server-3.0.jar"/> <classpathentry kind="lib" path="framework/base/lib/webslinger-base-invoker-20091211-3897-7ab22baea4b6.jar"/> <classpathentry kind="lib" path="framework/webslinger/lib/webslinger-20091211-3897-7ab22baea4b6.jar"/> <classpathentry kind="lib" path="framework/webslinger/lib/webslinger-base-cache-20091211-3897-7ab22baea4b6.jar"/> Modified: ofbiz/trunk/LICENSE URL: http://svn.apache.org/viewvc/ofbiz/trunk/LICENSE?rev=959261&r1=959260&r2=959261&view=diff ============================================================================== --- ofbiz/trunk/LICENSE (original) +++ ofbiz/trunk/LICENSE Wed Jun 30 10:52:12 2010 @@ -31,6 +31,8 @@ ofbiz/trunk/framework/base/lib/mx4j-remo ofbiz/trunk/framework/base/lib/nekohtml.jar ofbiz/trunk/framework/base/lib/resolver-2.9.1.jar ofbiz/trunk/framework/base/lib/serializer-2.9.1.jar +ofbiz/trunk/framework/base/lib/ws-commons-java5-1.0.1.jar +ofbiz/trunk/framework/base/lib/ws-commons-util-1.0.2.jar ofbiz/trunk/framework/base/lib/xercesImpl-2.9.1.jar ofbiz/trunk/framework/base/lib/xml-apis-2.9.1.jar ofbiz/trunk/framework/base/lib/commons/commons-beanutils-1.7.0.jar @@ -65,6 +67,9 @@ ofbiz/trunk/framework/base/lib/j2eespecs ofbiz/trunk/framework/base/lib/scripting/bsf-2.4.0.jar ofbiz/trunk/framework/base/lib/scripting/jakarta-oro-2.0.8.jar ofbiz/trunk/framework/base/lib/scripting/groovy-all-1.7.3.jar +ofbiz/trunk/framework/base/lib/xmlrpc-client-3.1.2.jar +ofbiz/trunk/framework/base/lib/xmlrpc-common-3.1.2.jar +ofbiz/trunk/framework/base/lib/xmlrpc-server-3.1.2.jar ofbiz/trunk/framework/catalina/lib/tomcat-6.0.26-catalina-ha.jar ofbiz/trunk/framework/catalina/lib/tomcat-6.0.26-catalina-tribes.jar ofbiz/trunk/framework/catalina/lib/tomcat-6.0.26-catalina.jar @@ -104,11 +109,6 @@ ofbiz/trunk/framework/webapp/lib/ezmorph ofbiz/trunk/framework/webapp/lib/rome-0.9.jar ofbiz/trunk/framework/webapp/lib/serializer-2.7.0.jar ofbiz/trunk/framework/webapp/lib/xalan-2.7.1.jar -ofbiz/trunk/framework/webapp/lib/xmlrpc-client-3.0.jar -ofbiz/trunk/framework/webapp/lib/xmlrpc-common-3.0.jar -ofbiz/trunk/framework/webapp/lib/xmlrpc-server-3.0.jar -ofbiz/trunk/framework/webapp/lib/ws-commons-java5-1.0.1.jar -ofbiz/trunk/framework/webapp/lib/ws-commons-util-1.0.1.jar ofbiz/trunk/framework/geronimo/lib/geronimo-connector-2.1.1.jar ofbiz/trunk/framework/geronimo/lib/geronimo-transaction-2.1.1.jar ofbiz/trunk/framework/base/lib/webslinger-base-invoker-20091211-3897-7ab22baea4b6.jar Added: ofbiz/trunk/framework/base/lib/ws-commons-util-1.0.2.jar URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/lib/ws-commons-util-1.0.2.jar?rev=959261&view=auto ============================================================================== Binary file - no diff available. Propchange: ofbiz/trunk/framework/base/lib/ws-commons-util-1.0.2.jar ------------------------------------------------------------------------------ svn:mime-type = application/octet-stream Added: ofbiz/trunk/framework/base/lib/xmlrpc-client-3.1.2.jar URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/lib/xmlrpc-client-3.1.2.jar?rev=959261&view=auto ============================================================================== Binary file - no diff available. Propchange: ofbiz/trunk/framework/base/lib/xmlrpc-client-3.1.2.jar ------------------------------------------------------------------------------ svn:mime-type = application/octet-stream Added: ofbiz/trunk/framework/base/lib/xmlrpc-common-3.1.2.jar URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/lib/xmlrpc-common-3.1.2.jar?rev=959261&view=auto ============================================================================== Binary file - no diff available. Propchange: ofbiz/trunk/framework/base/lib/xmlrpc-common-3.1.2.jar ------------------------------------------------------------------------------ svn:mime-type = application/octet-stream Added: ofbiz/trunk/framework/base/lib/xmlrpc-server-3.1.2.jar URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/lib/xmlrpc-server-3.1.2.jar?rev=959261&view=auto ============================================================================== Binary file - no diff available. Propchange: ofbiz/trunk/framework/base/lib/xmlrpc-server-3.1.2.jar ------------------------------------------------------------------------------ svn:mime-type = application/octet-stream Modified: ofbiz/trunk/framework/service/config/serviceengine.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/service/config/serviceengine.xml?rev=959261&r1=959260&r2=959261&view=diff ============================================================================== --- ofbiz/trunk/framework/service/config/serviceengine.xml (original) +++ ofbiz/trunk/framework/service/config/serviceengine.xml Wed Jun 30 10:52:12 2010 @@ -58,7 +58,11 @@ under the License. <engine name="ofbiz-workflow" class="org.ofbiz.workflow.WorkflowEngine"/> <engine name="workflow" class="org.ofbiz.shark.service.SharkServiceEngine"/> <engine name="webslinger-server" class="org.ofbiz.webslinger.WebslingerServerEngine"/> - + <engine name="xml-rpc-local" class="org.ofbiz.service.engine.XMLRPCClientEngine"> + <parameter name="url" value="http://localhost:8080/webtools/control/xmlrpc"/> + <parameter name="login" value="admin"/> + <parameter name="password" value="ofbiz"/> + </engine> <service-location name="main-rmi" location="rmi://localhost:1099/RMIDispatcher"/> <service-location name="main-http" location="http://localhost:8080/webtools/control/httpService"/> Modified: ofbiz/trunk/framework/service/dtd/service-config.xsd URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/service/dtd/service-config.xsd?rev=959261&r1=959260&r2=959261&view=diff ============================================================================== --- ofbiz/trunk/framework/service/dtd/service-config.xsd (original) +++ ofbiz/trunk/framework/service/dtd/service-config.xsd Wed Jun 30 10:52:12 2010 @@ -92,9 +92,26 @@ under the License. </xs:attributeGroup> <xs:element name="engine"> <xs:complexType> + <xs:sequence> + <xs:element minOccurs="0" maxOccurs="unbounded" ref="parameter"/> + </xs:sequence> <xs:attributeGroup ref="attlist.engine"/> </xs:complexType> </xs:element> + <xs:element name="parameter"> + <xs:annotation> + <xs:documentation> + Technical parameters use by engine + </xs:documentation> + </xs:annotation> + <xs:complexType> + <xs:attributeGroup ref="attlist.parameter"/> + </xs:complexType> + </xs:element> + <xs:attributeGroup name="attlist.parameter"> + <xs:attribute type="xs:string" name="name" use="required"/> + <xs:attribute type="xs:string" name="value" use="required"/> + </xs:attributeGroup> <xs:attributeGroup name="attlist.engine"> <xs:attribute type="xs:string" name="name" use="required"/> <xs:attribute type="xs:string" name="class" use="required"/> Modified: ofbiz/trunk/framework/service/servicedef/services_test_se.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/service/servicedef/services_test_se.xml?rev=959261&r1=959260&r2=959261&view=diff ============================================================================== --- ofbiz/trunk/framework/service/servicedef/services_test_se.xml (original) +++ ofbiz/trunk/framework/service/servicedef/services_test_se.xml Wed Jun 30 10:52:12 2010 @@ -83,4 +83,19 @@ under the License. <service name="testServiceEcaGlobalEventExecOnRollback" engine="java" auth="false" location="org.ofbiz.service.test.ServiceEngineTestServices" invoke="testServiceEcaGlobalEventExecOnRollback"> </service> + + <!-- Call xml rpc from engine --> + <service name="testXmlRpcAdd" engine="java" auth="false" location="org.ofbiz.service.test.XmlRpcTests" invoke="testXmlRpcAdd" export="true"> + <attribute name="num1" mode="IN" type="Integer"/> + <attribute name="num2" mode="IN" type="Integer"/> + <attribute name="resulting" mode="OUT" type="Integer"/> + </service> + <service name="testXmlRpcLocalEngine" engine="xml-rpc-local" auth="false" invoke="testXmlRpcAdd"> + <attribute name="num1" mode="IN" type="Integer"/> + <attribute name="num2" mode="IN" type="Integer"/> + <attribute name="resulting" mode="OUT" type="Integer"/> + </service> + <service name="testXmlRpcClientAdd" engine="java" auth="false" location="org.ofbiz.service.test.XmlRpcTests" invoke="testXmlRpcClientAdd"> + <implements service="testServiceInterface"/> + </service> </services> Modified: ofbiz/trunk/framework/service/src/org/ofbiz/service/config/ServiceConfigUtil.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/service/src/org/ofbiz/service/config/ServiceConfigUtil.java?rev=959261&r1=959260&r2=959261&view=diff ============================================================================== --- ofbiz/trunk/framework/service/src/org/ofbiz/service/config/ServiceConfigUtil.java (original) +++ ofbiz/trunk/framework/service/src/org/ofbiz/service/config/ServiceConfigUtil.java Wed Jun 30 10:52:12 2010 @@ -31,6 +31,8 @@ import org.ofbiz.base.util.Debug; import org.ofbiz.base.util.UtilXml; import org.ofbiz.base.util.cache.UtilCache; import org.w3c.dom.Element; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; /** * Misc. utility method for dealing with the serviceengine.xml file @@ -144,6 +146,32 @@ public class ServiceConfigUtil implement return null; } + + public static String getEngineParameter(String engineName, String name) throws GenericConfigException { + Element root = ServiceConfigUtil.getXmlRootElement(); + Node node = root.getFirstChild(); + + if (node != null) { + do { + if (node.getNodeType() == Node.ELEMENT_NODE && "engine".equals(node.getLocalName())) { + Element engine = (Element) node; + if (engineName.equals(engine.getAttribute("name"))) { + NodeList params = engine.getElementsByTagName("parameter"); + if (params.getLength() > 0) { + for (int index = 0; index < params.getLength(); index++) { + Element param = (Element) params.item(index); + if (param != null && name.equals(param.getAttribute("name"))) { + return (String) param.getAttribute("value"); + } + } + } + } + } + } while ((node = node.getNextSibling()) != null); + } + return null; + } + public static class NotificationGroup implements Serializable { protected Notification notification; protected List<Notify> notify; Added: ofbiz/trunk/framework/service/src/org/ofbiz/service/engine/XMLRPCClientEngine.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/service/src/org/ofbiz/service/engine/XMLRPCClientEngine.java?rev=959261&view=auto ============================================================================== --- ofbiz/trunk/framework/service/src/org/ofbiz/service/engine/XMLRPCClientEngine.java (added) +++ ofbiz/trunk/framework/service/src/org/ofbiz/service/engine/XMLRPCClientEngine.java Wed Jun 30 10:52:12 2010 @@ -0,0 +1,143 @@ +/******************************************************************************* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + *******************************************************************************/ +package org.ofbiz.service.engine; + +import java.net.MalformedURLException; +import java.net.URL; +import java.util.List; +import java.util.Map; + +import javolution.util.FastMap; + +import org.apache.xmlrpc.XmlRpcException; +import org.apache.xmlrpc.client.XmlRpcClientConfigImpl; +import org.ofbiz.base.config.GenericConfigException; +import org.ofbiz.base.util.Debug; +import org.ofbiz.base.util.UtilGenerics; +import org.ofbiz.base.util.UtilMisc; +import org.ofbiz.base.util.UtilValidate; +import org.ofbiz.service.GenericServiceException; +import org.ofbiz.service.ModelParam; +import org.ofbiz.service.ModelService; +import org.ofbiz.service.ServiceDispatcher; +import org.ofbiz.service.ServiceUtil; +import org.ofbiz.service.config.ServiceConfigUtil; +import org.ofbiz.service.xmlrpc.XmlRpcClient; + +/** + * Engine For XML RPC CLient Configuration management + */ +public class XMLRPCClientEngine extends GenericAsyncEngine { + + public static final String module = XMLRPCClientEngine.class.getName(); + + public XMLRPCClientEngine(ServiceDispatcher dispatcher) { + super(dispatcher); + } + + /** + * @see org.ofbiz.service.engine.GenericEngine#runSyncIgnore(java.lang.String, org.ofbiz.service.ModelService, java.util.Map) + */ + @Override + public void runSyncIgnore(String localName, ModelService modelService, Map<String, Object> context) throws GenericServiceException { + runSync(localName, modelService, context); + } + + /** + * @see org.ofbiz.service.engine.GenericEngine#runSync(java.lang.String, org.ofbiz.service.ModelService, java.util.Map) + */ + @Override + public Map<String, Object> runSync(String localName, ModelService modelService, Map<String, Object> context) throws GenericServiceException { + Map<String, Object> result = serviceInvoker(modelService, context); + + if (result == null) + throw new GenericServiceException("Service did not return expected result"); + return result; + } + + /* + * Invoke the remote XMLRPC SERVICE : This engine convert all value in IN mode to one struct. + */ + private Map<String, Object> serviceInvoker(ModelService modelService, Map<String, Object> context) throws GenericServiceException { + if (modelService.location == null || modelService.invoke == null) + throw new GenericServiceException("Cannot locate service to invoke"); + + XmlRpcClientConfigImpl config = null; + XmlRpcClient client = null; + String serviceName = modelService.invoke; + String engine = modelService.engineName; + String url = null; + String login = null; + String password = null; + String keyStoreComponent = null; + String keyStoreName = null; + String keyAlias = null; + try { + url = ServiceConfigUtil.getEngineParameter(engine, "url"); + login = ServiceConfigUtil.getEngineParameter(engine, "login"); + password = ServiceConfigUtil.getEngineParameter(engine, "password"); + keyStoreComponent = ServiceConfigUtil.getEngineParameter(engine, "keyStoreComponent"); + keyStoreName = ServiceConfigUtil.getEngineParameter(engine, "keyStoreName"); + keyAlias = ServiceConfigUtil.getEngineParameter(engine, "keyAlias"); + config = new XmlRpcClientConfigImpl(); + config.setBasicUserName(login); + config.setBasicPassword(password); + config.setServerURL(new URL(url)); + }catch (MalformedURLException e) { + throw new GenericServiceException("Cannot invoke service : engine parameters are not correct"); + } + catch (GenericConfigException e) { + throw new GenericServiceException("Cannot invoke service : engine parameters are not correct"); + } + if(UtilValidate.isNotEmpty(keyStoreComponent) && UtilValidate.isNotEmpty(keyStoreName) && UtilValidate.isNotEmpty(keyAlias)){ + client = new XmlRpcClient(config, keyStoreComponent, keyStoreName, keyAlias); + } + else{ + client = new XmlRpcClient(config); + } + List<ModelParam> inModelParamList = modelService.getInModelParamList(); + + if (Debug.verboseOn()) { + Debug.logVerbose("[XMLRPCClientEngine.invoke] : Parameter length - " + inModelParamList.size(), module); + for (ModelParam p: inModelParamList) { + Debug.logVerbose("[XMLRPCClientEngine.invoke} : Parameter: " + p.name + " (" + p.mode + ")", module); + } + } + + Map<String, Object> result = null; + Map<String, Object> params = FastMap.newInstance(); + for (ModelParam modelParam: modelService.getModelParamList()) { + // don't include OUT parameters in this list, only IN and INOUT + if ("OUT".equals(modelParam.mode) || modelParam.internal) continue; + + Object paramValue = context.get(modelParam.name); + if (paramValue != null) { + params.put(modelParam.name, paramValue); + } + } + + List<Map<String,Object>> listParams = UtilMisc.toList(params); + try{ + result = UtilGenerics.cast(client.execute(serviceName, listParams.toArray())); + }catch (XmlRpcException e) { + result = ServiceUtil.returnError(e.getLocalizedMessage()); + } + return result; + } +} Propchange: ofbiz/trunk/framework/service/src/org/ofbiz/service/engine/XMLRPCClientEngine.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/trunk/framework/service/src/org/ofbiz/service/engine/XMLRPCClientEngine.java ------------------------------------------------------------------------------ svn:keywords = "Date Rev Author URL Id" Propchange: ofbiz/trunk/framework/service/src/org/ofbiz/service/engine/XMLRPCClientEngine.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Copied: ofbiz/trunk/framework/service/src/org/ofbiz/service/test/AbstractXmlRpcTestCase.java (from r959249, ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/test/AbstractXmlRpcTestCase.java) URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/service/src/org/ofbiz/service/test/AbstractXmlRpcTestCase.java?p2=ofbiz/trunk/framework/service/src/org/ofbiz/service/test/AbstractXmlRpcTestCase.java&p1=ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/test/AbstractXmlRpcTestCase.java&r1=959249&r2=959261&rev=959261&view=diff ============================================================================== --- ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/test/AbstractXmlRpcTestCase.java (original) +++ ofbiz/trunk/framework/service/src/org/ofbiz/service/test/AbstractXmlRpcTestCase.java Wed Jun 30 10:52:12 2010 @@ -17,14 +17,15 @@ under the License. */ -package org.ofbiz.webapp.test; +package org.ofbiz.service.test; + +import java.net.MalformedURLException; +import java.net.URL; import junit.framework.TestCase; -import org.ofbiz.webapp.xmlrpc.XmlRpcClient; -import org.apache.xmlrpc.client.XmlRpcClientConfigImpl; -import java.net.URL; -import java.net.MalformedURLException; +import org.apache.xmlrpc.client.XmlRpcClientConfigImpl; +import org.ofbiz.service.xmlrpc.XmlRpcClient; /** * AbstractXmlRpcTestCase Copied: ofbiz/trunk/framework/service/src/org/ofbiz/service/test/XmlRpcTests.java (from r959249, ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/test/XmlRpcTests.java) URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/service/src/org/ofbiz/service/test/XmlRpcTests.java?p2=ofbiz/trunk/framework/service/src/org/ofbiz/service/test/XmlRpcTests.java&p1=ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/test/XmlRpcTests.java&r1=959249&r2=959261&rev=959261&view=diff ============================================================================== --- ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/test/XmlRpcTests.java (original) +++ ofbiz/trunk/framework/service/src/org/ofbiz/service/test/XmlRpcTests.java Wed Jun 30 10:52:12 2010 @@ -17,12 +17,16 @@ under the License. */ -package org.ofbiz.webapp.test; +package org.ofbiz.service.test; + +import java.util.Map; import org.apache.xmlrpc.client.XmlRpcClient; import org.ofbiz.base.util.UtilGenerics; - -import java.util.Map; +import org.ofbiz.base.util.UtilValidate; +import org.ofbiz.service.DispatchContext; +import org.ofbiz.service.GenericServiceException; +import org.ofbiz.service.ServiceUtil; /** * XmlRpcTests @@ -36,10 +40,55 @@ public class XmlRpcTests extends Abstrac super(name); } + /** + * Test Xml Rpc by java class call with a Object List + * @throws Exception + */ public void testXmlRpcRequest() throws Exception { XmlRpcClient client = this.getRpcClient(url, "admin", "ofbiz"); Object[] params = new Object[] { 55.00, "message from xml-rpc client" }; Map<String, Object> result = UtilGenerics.cast(client.execute("testScv", params)); assertEquals("XML-RPC Service result success", "service done", result.get("resp")); } + + /** + * Service to receive information from xml-rpc call + */ + public static Map<String, Object> testXmlRpcAdd(DispatchContext dctx, Map<String, ?> context) { + Map<String, Object> response = ServiceUtil.returnSuccess(); + Integer num1 = (Integer) context.get("num1"); + Integer num2 = (Integer) context.get("num2"); + if (UtilValidate.isEmpty(num1) || UtilValidate.isEmpty(num2)) { + return ServiceUtil.returnError("missing parameters"); + } + Integer res = num1 + num2; + response.put("resulting", res); + return response; + } + + /** + * Service to send information to xml-rpc service + */ + public static Map<String, Object> testXmlRpcClientAdd(DispatchContext dctx, Map<String, ?> context) { + Map<String, Object> result = null; + Integer num1 = 125; + Integer num2 = 365; + try { + Map<String, Object> localMap = dctx.makeValidContext("testXmlRpcLocalEngine", "IN", context); + localMap.put("num1", num1); + localMap.put("num2", num2); + result = dctx.getDispatcher().runSync("testXmlRpcLocalEngine", localMap); + } + catch (GenericServiceException e) { + return ServiceUtil.returnError(e.getLocalizedMessage()); + } + if (ServiceUtil.isError(result)) return result; + Integer res = (Integer) result.get("resulting"); + if (res == (num1 + num2)) { + result = ServiceUtil.returnSuccess("adding integer 125 to 365 yields " + res); + } else { + result = ServiceUtil.returnError("calcul is wrong ! Why ?"); + } + return result; + } } Modified: ofbiz/trunk/framework/service/src/org/ofbiz/service/xmlrpc/AliasSupportedTransportFactory.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/service/src/org/ofbiz/service/xmlrpc/AliasSupportedTransportFactory.java?rev=959261&r1=959249&r2=959261&view=diff ============================================================================== --- ofbiz/trunk/framework/service/src/org/ofbiz/service/xmlrpc/AliasSupportedTransportFactory.java (original) +++ ofbiz/trunk/framework/service/src/org/ofbiz/service/xmlrpc/AliasSupportedTransportFactory.java Wed Jun 30 10:52:12 2010 @@ -17,30 +17,31 @@ under the License. */ -package org.ofbiz.webapp.xmlrpc; +package org.ofbiz.service.xmlrpc; +import java.io.IOException; +import java.io.InputStream; +import java.net.HttpURLConnection; +import java.net.URL; +import java.net.URLConnection; +import java.security.GeneralSecurityException; +import java.security.KeyStore; + +import javax.net.ssl.HttpsURLConnection; + +import org.apache.xmlrpc.XmlRpcException; +import org.apache.xmlrpc.XmlRpcRequest; import org.apache.xmlrpc.client.XmlRpcClientException; import org.apache.xmlrpc.client.XmlRpcHttpClientConfig; import org.apache.xmlrpc.client.XmlRpcHttpTransport; import org.apache.xmlrpc.client.XmlRpcTransport; import org.apache.xmlrpc.client.XmlRpcTransportFactoryImpl; -import org.apache.xmlrpc.XmlRpcRequest; -import org.apache.xmlrpc.XmlRpcException; -import org.apache.xmlrpc.util.HttpUtil; import org.apache.xmlrpc.common.XmlRpcStreamRequestConfig; -import org.ofbiz.base.util.SSLUtil; +import org.apache.xmlrpc.util.HttpUtil; import org.ofbiz.base.util.GeneralException; +import org.ofbiz.base.util.SSLUtil; import org.xml.sax.SAXException; -import javax.net.ssl.HttpsURLConnection; -import java.security.KeyStore; -import java.security.GeneralSecurityException; -import java.net.URLConnection; -import java.net.URL; -import java.net.HttpURLConnection; -import java.io.IOException; -import java.io.InputStream; - /** * AliasSupportedTransportFactory */ Modified: ofbiz/trunk/framework/service/src/org/ofbiz/service/xmlrpc/XmlRpcClient.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/service/src/org/ofbiz/service/xmlrpc/XmlRpcClient.java?rev=959261&r1=959249&r2=959261&view=diff ============================================================================== --- ofbiz/trunk/framework/service/src/org/ofbiz/service/xmlrpc/XmlRpcClient.java (original) +++ ofbiz/trunk/framework/service/src/org/ofbiz/service/xmlrpc/XmlRpcClient.java Wed Jun 30 10:52:12 2010 @@ -17,7 +17,7 @@ under the License. */ -package org.ofbiz.webapp.xmlrpc; +package org.ofbiz.service.xmlrpc; import org.apache.xmlrpc.client.XmlRpcClientConfig; import org.apache.xmlrpc.client.XmlRpcTransportFactory; Modified: ofbiz/trunk/framework/service/testdef/servicetests.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/service/testdef/servicetests.xml?rev=959261&r1=959260&r2=959261&view=diff ============================================================================== --- ofbiz/trunk/framework/service/testdef/servicetests.xml (original) +++ ofbiz/trunk/framework/service/testdef/servicetests.xml Wed Jun 30 10:52:12 2010 @@ -65,4 +65,11 @@ under the License. <test-case case-name="service-eca-global-event-exec-assert-data"> <entity-xml action="assert" entity-xml-url="component://service/testdef/data/ServiceEcaGlobalEventAssertData.xml"/> </test-case> + + <test-case case-name="service-xml-rpc"> + <junit-test-suite class-name="org.ofbiz.service.test.XmlRpcTests"/> + </test-case> + <test-case case-name="service-xml-rpc-local-engine"> + <service-test service-name="testXmlRpcClientAdd"/> + </test-case> </test-suite> Modified: ofbiz/trunk/framework/webapp/testdef/webapptests.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webapp/testdef/webapptests.xml?rev=959261&r1=959260&r2=959261&view=diff ============================================================================== --- ofbiz/trunk/framework/webapp/testdef/webapptests.xml (original) +++ ofbiz/trunk/framework/webapp/testdef/webapptests.xml Wed Jun 30 10:52:12 2010 @@ -17,11 +17,8 @@ under the License. --> -<test-suite suite-name="webapptests" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:noNamespaceSchemaLocation="http://ofbiz.apache.org/dtds/test-suite.xsd"> - - <test-case case-name="webapp-tests"> - <junit-test-suite class-name="org.ofbiz.webapp.test.XmlRpcTests"/> - </test-case> -</test-suite> +<!--<test-suite suite-name="webapptests"--> +<!-- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"--> +<!-- xsi:noNamespaceSchemaLocation="http://ofbiz.apache.org/dtds/test-suite.xsd">--> +<!----> +<!--</test-suite>--> |
Free forum by Nabble | Edit this page |