Selon Upayavira <[EMAIL PROTECTED]>:So, on the server, you need something that'll read of an IPC message queue, and get Cocoon to do some processing, transforming some files. Well, once the file is on the server, you don't really need HTTP post. So you could simply do:
...
What do you mean by 'I get notified of their arrival'? Do you mean that they are sent by FTP to the server, and then the server is informed of their arrival?
That's it. The FTP server writes events into an IPC message queue.
Unfortunatly, without JNI it's hard to program something in Java that could communicate with IPC. So, a Perl script does the job. So far, the script does the XSLT too. But it is not flexible at all, that's why I'd like to send the raw XML files to by Cocoon, maybe via HTTP (or, at the begining at this thread I was thinking about some kind of MoM). But without JNI, I am compelled to write a Perl HTTP client to send the XML files to Cocoon :(
#!/usr/bin/perl
use LWP::UserAgent;
my $userAgent=LWP::UserAgent->new();
my $response=$userAgent->get("http://localhost:8080/cocoon/your_url");
open(out, ">file.txt");
print out $response->content;
close(out);Thus, you've asked perl to go get a page from Cocoon by HTTP, and then written it to disk. The pipeline can just look for the file where the FTP put it.
If you do want to post by HTTP, here's some code:
#!/usr/bin/perl
use LWP 5.64;
my $content = "<xml>Some XML</xml>";
my $request = HTTP::Request->new("POST");$request->header("Content-Type","text/xml");
$request->content($content);
$request->url("http://yourserver/cocoon/url");my $ua = LWP::UserAgent->new; my $response = $ua->request($request);
if ($response->is_success) {
print $response->content,"\n";
} else {
print "ERROR: ",$response->status_line,"\n";
}Does this help?
Regards, Upayavira
I would say, using some combination of flow, HTTP post, the StreamGenerator and processPipelineTo might do you nicely.
That way, whatever starts the process off posts the raw data to Cocoon, in XML, using HTTPPost. In flow, you use code like:
var fis = new java.io.FileInputStream(new java.io.File("yourfile.xml"));
cocoon.processPipelineTo("stream-pipeline", fis);
cocoon.sendPage("show-success");
That way, the contents of the stream are transformed in a pipeline and then written to disk.
Alternatively, you could use the SourceWritingTransformer to do it.
I would recommend using HTTP to transfer data, rather than FTP. FTP is an antiquated and complex protocol, and, as you have seen, has no capacity to notify of delivery. Whereas, when data arrives via HTTP, you are free to take that data and place it wherever you want.
Hope this helps.
Regards, Upayavira
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
