Hi,
Yes I checked it. I also have implemented some codes that use the
deployment service but it has exception and I worked the whole week but I
could not solve the problem.
I have basically two classes: deploymentconnection.java
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import org.apache.axiom.om.OMAbstractFactory;
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMFactory;
import org.apache.axiom.om.OMNamespace;
import org.apache.axiom.om.OMText;
import org.apache.axiom.om.util.Base64;
import org.apache.axis2.AxisFault;
import org.apache.ode.axis2.service.ServiceClientUtil;
import org.apache.ode.utils.Namespaces;
public class DeploymentConnection {
private final String _url;
private OMFactory _factory;
private ServiceClientUtil _client;
private final OMNamespace _pmapi;
public DeploymentConnection(String url) {
_url = url;
_factory = OMAbstractFactory.getOMFactory();
_client = new ServiceClientUtil();
_pmapi = _factory.createOMNamespace("http://www.apache.org/ode/pmapi",
"pmapi");
}
public void deploy(File archive, String name) throws
FileNotFoundException, IOException {
// Use the factory to create three elements
OMElement root = _factory.createOMElement("deploy", _pmapi);
OMElement namePart = _factory.createOMElement("name", null);
namePart.setText(name);
OMElement zipPart = _factory.createOMElement("package", null);
OMElement zipElmt = _factory.createOMElement("zip", null);
InputStream is = new FileInputStream(archive.getPath());
ByteArrayOutputStream outputStream = new
ByteArrayOutputStream((int) archive.length());
byte[] buffer = new byte[4096];
int len;
while ((len = is.read(buffer)) >= 0) {
outputStream.write(buffer, 0, len);
}
String base64Enc = Base64.encode(outputStream.toByteArray());
OMText zipContent =
_factory.createOMText(base64Enc,"application/zip", true);
root.addChild(namePart);
root.addChild(zipPart);
zipPart.addChild(zipElmt);
zipElmt.addChild(zipContent);
sendToDeployment(root);
}
public void undeploy(String packageName) throws IOException {
// Prepare undeploy message
OMNamespace pmapi =
_factory.createOMNamespace(Namespaces.ODE_PMAPI,"deployapi");
OMElement root = _factory.createOMElement("undeploy", pmapi);
OMElement part = _factory.createOMElement("packageName", null);
part.setText(packageName);
root.addChild(part);
if (packageName != null) {
part.setText(packageName);
root.addChild(part);
sendToDeployment(root);
}
}
private OMElement sendToDeployment(OMElement msg) throws AxisFault {
return _client.send(msg, this._url);
}
}
and my main class which uses ServiceClientUtil class for sending the
message to Axis2 for calling the deploy function. ServiceClientUtil is the
class which I found it on Github and this is an interface for making it
easier to use the API : main.java
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
public class Main {
public static void main(String[] args) throws FileNotFoundException {
DeploymentConnection con = new DeploymentConnection("
http://localhost:8080/ode/processes/DeploymentService");
try {
con.deploy(new File("C:\\temp\\DynPartner.zip"), "DynPartner");
} catch (IOException ex) {
//Logger.getLogger(Main.class.getName()).log(Level.SEVERE,
null,ex);
ex.printStackTrace();
}}}
I do appreciate if someone can help me. It makes me crazy and I was working
the last 2 weeks on it.
On Sun, Feb 1, 2015 at 4:15 AM, Sathwik B P <[email protected]> wrote:
> Did you check fileupload.jsp
>
> On Sat, Jan 31, 2015 at 8:19 PM, Marzie Dehghanipour <
> [email protected]> wrote:
>
> > Dear Sathwik,
> >
> > Thanks a lot for your answer. I know already the concept. but I need some
> > implementation sample.
> >
> > Thanks
> >
> > On Sat, Jan 31, 2015 at 2:29 PM, Sathwik B P <[email protected]>
> wrote:
> >
> > > Hi Marzie,
> > >
> > > You basically need to read the process artifact (zip file) and encode
> it
> > > with Base64 and use it as the payload contents for deploy operation of
> > > Deployment Service.
> > >
> > > Have a look at fileupload.jsp under ODE webapp.
> > >
> > > regards,
> > > sathwik
> > >
> > > On Sat, Jan 31, 2015 at 6:42 PM, Marzie Dehghanipour <
> > > [email protected]> wrote:
> > >
> > > > Hi,
> > > > I am looking for sample implementation of deploying a process on
> Apache
> > > ODE
> > > > engine using deployment service API. I want to use the deployment API
> > > > exposed by ODE. This allows for transferring deployment units (zip
> > files
> > > > containing BPELs, WSDLs, DDs) via SOAP to ODE and starting the
> > > deployment.
> > > >
> > > > Any help in this regard would be appreciated.
> > > >
> > >
> >
>