Introduction
italic Note: The following Integration Guide is aimed at OFBiz Developers with a Basic Knowledge of the actual System.
Integration StepsSteps
1)
(Skip if a service.xml file is already existent) create a new service.xml file in your appication directory (i created it in an extra folder: servicedef) and add the very same to the ofbizcomponent.xml file --> e.g. by adding:
<service-resource type="model" loader="main" location="servicedef/services.xml"/>
2) open the service.xml file and add:
[...]
<!-- CMS Services -->
<service name="runCMSQuery" engine="java"
transaction-timeout="72000"
location="org.brandsparadise.cms.Magnolia"
invoke="runCMSQuery" debug="true" validate="true">
<description>Run a query on CMS and return the results</description>
<attribute mode="IN" name="query" optional="false"
type="String" />
<attribute name="queryResult" type="String" mode="OUT" optional="true"/>
</service>
[...]
(take a look at any other service.xml file on the exact layout of a service.xml file)
3) create a new src folder and load the sources via ofbiz-component.xml:
<classpath type="dir" location="src/*" />
4) Create a new package and call it any name you like (I called mine: org.brandsparadise.cms). Add a class to it (i called mine: Magnolia.java) and add something along the line of :
package org.brandsparadise.cms;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.util.Map;
import java.net.*;
import junit.framework.TestCase;
import org.ofbiz.service.DispatchContext;
import org.ofbiz.service.ServiceUtil;
/**
- Base class for OFBiz Test Tools test case implementations.
*/
public abstract class Magnolia extends TestCase {
public static final String module = Magnolia.class.getName();
public static String cmsUrl = "http://www.google.com";
/**
- runs a query on a url and return the results
*
*/
public static Map runCMSQuery(DispatchContext dctx, Map context) {
try {
// get Connection
StringBuilder result = new StringBuilder();
byte[] buffer = new byte[8192];
InputStream s;
URL url = new URL(cmsUrl + context.get("query").toString());
s = url.openStream();
int size = 0;
do
while (size != -1);
context = ServiceUtil.returnSuccess();
context.put("queryResult", result.toString());
} catch (MalformedURLException e)
catch (IOException e)
// Debug.log("Query Result: "+results.toString());
return context;
}
public static void main(String[] args)
}