Can someone give examples of having java sending REST request to DCS?

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Can someone give examples of having java sending REST request to DCS?

savannah_beckett
People have provided Ruby, PHP, CSharp examples on how to send REST request to DCS; but I am completely surprised that no one has provided any example to do it in JAVA.  WHY?!!!!!!!  

I have spent entire week trying to use java to send REST request to DCS, so far no luck.  First, I tried to use JAX-WS, but it turns out that JAX-WS can't change content-type.  So now, I switch to a combination of URLConnection and OutputStreamWriter, and I am still getting HTTP code 400.  

I googled for hours, and there is no java example of doing this neither.

I am actually considering abandoning Carrot2.  Waste of time.
Reply | Threaded
Open this post in threaded view
|

Re: Can someone give examples of having java sending REST request to DCS?

Stanislaw Osinski
Administrator
> People have provided Ruby, PHP, CSharp examples on how to send REST request
> to DCS; but I am completely surprised that no one has provided any example
> to do it in JAVA.  WHY?!!!!!!!

As there's only two people contributing their free time to develop
Carrot2, we're forced to postpone development of some features /
examples until someone needs them. You were the first peron to ask for
a Java DCS example, that's probably why it's still not in the
distribution.

I'll try to commit an example for you hopefully today.

Cheers,

S.

------------------------------------------------------------------------------
Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
easily build your RIAs with Flex Builder, the Eclipse(TM)based development
software that enables intelligent coding and step-through debugging.
Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
_______________________________________________
Carrot2-developers mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/carrot2-developers
Reply | Threaded
Open this post in threaded view
|

Re: Can someone give examples of having java sending REST request to DCS?

Dawid Weiss-2
In reply to this post by savannah_beckett

> I have spent entire week trying to use java to send REST request to DCS, so

It's really hard to believe you've spent a week on something this simple...

> far no luck.  First, I tried to use JAX-WS, but it turns out that JAX-WS

Try Apache HTTP components -- they come with examples and should be easier to
understand.

> I am actually considering abandoning Carrot2.  Waste of time.

Like Staszek mentioned, we have very limited time for this. Also, note that
writing such examples is a waste of time -- we'd rather focus on bugs and
pending features.

In any case, we will add such an example of course.

Dawid

------------------------------------------------------------------------------
Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
easily build your RIAs with Flex Builder, the Eclipse(TM)based development
software that enables intelligent coding and step-through debugging.
Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
_______________________________________________
Carrot2-developers mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/carrot2-developers
Reply | Threaded
Open this post in threaded view
|

Re: Can someone give examples of having java sending REST request to DCS?

savannah_beckett
Most of my time were spent on JAX-WS because somehow it always uses text/xml instead of multipart/form-data even when I told it to do so.  Maybe it's a JAX-WS bug.  And I was new in JAX-WS.

In your java examples, would you show how to send DOMSource xml directly to DCS instead of a file?  I think that this method is more of a real world situation because no one is going to save temp data into a xml file then send it to DCS in production environment.

Thanks.

JIRA dawid.weiss@cs.put.poznan.pl wrote
> I have spent entire week trying to use java to send REST request to DCS, so

It's really hard to believe you've spent a week on something this simple...

> far no luck.  First, I tried to use JAX-WS, but it turns out that JAX-WS

Try Apache HTTP components -- they come with examples and should be easier to
understand.

> I am actually considering abandoning Carrot2.  Waste of time.

Like Staszek mentioned, we have very limited time for this. Also, note that
writing such examples is a waste of time -- we'd rather focus on bugs and
pending features.

In any case, we will add such an example of course.

Dawid

------------------------------------------------------------------------------
Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
easily build your RIAs with Flex Builder, the Eclipse(TM)based development
software that enables intelligent coding and step-through debugging.
Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
_______________________________________________
Carrot2-developers mailing list
Carrot2-developers@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/carrot2-developers
Reply | Threaded
Open this post in threaded view
|

Re: Can someone give examples of having java sending REST request to DCS?

Dawid Weiss-2

You should serialize DOM into a byte stream and then push it to the DCS using
plain HTTP POST with multipart content encoding.

Look here: http://hc.apache.org/httpclient-3.x/methods/multipartpost.html

If you serialize the input XML into ByteArrayPartSource, for example, the rest
should be trivial.

Serialization is always an overhead so if you can avoid it, better for you
(that's why we don't have an example in Java -- if you're using Java, it's much
better to embed clustering in your process directly).

D.

dealmaker wrote:

> Most of my time were spent on JAX-WS because somehow it always uses text/xml
> instead of multipart/form-data even when I told it to do so.  Maybe it's a
> JAX-WS bug.  And I was new in JAX-WS.
>
> In your java examples, would you show how to send DOMSource xml directly to
> DCS instead of a file?  I think that this method is more of a real world
> situation because no one is going to save temp data into a xml file then
> send it to DCS in production environment.
>
> Thanks.
>
>
> JIRA [hidden email] wrote:
>>
>>> I have spent entire week trying to use java to send REST request to DCS,
>>> so
>> It's really hard to believe you've spent a week on something this
>> simple...
>>
>>> far no luck.  First, I tried to use JAX-WS, but it turns out that JAX-WS
>> Try Apache HTTP components -- they come with examples and should be easier
>> to
>> understand.
>>
>>> I am actually considering abandoning Carrot2.  Waste of time.
>> Like Staszek mentioned, we have very limited time for this. Also, note
>> that
>> writing such examples is a waste of time -- we'd rather focus on bugs and
>> pending features.
>>
>> In any case, we will add such an example of course.
>>
>> Dawid
>>
>> ------------------------------------------------------------------------------
>> Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
>> powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
>> easily build your RIAs with Flex Builder, the Eclipse(TM)based development
>> software that enables intelligent coding and step-through debugging.
>> Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
>> _______________________________________________
>> Carrot2-developers mailing list
>> [hidden email]
>> https://lists.sourceforge.net/lists/listinfo/carrot2-developers
>>
>>
>

------------------------------------------------------------------------------
Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
easily build your RIAs with Flex Builder, the Eclipse(TM)based development
software that enables intelligent coding and step-through debugging.
Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
_______________________________________________
Carrot2-developers mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/carrot2-developers
Reply | Threaded
Open this post in threaded view
|

Re: Can someone give examples of having java sending REST request to DCS?

savannah_beckett
Thanks.  In that case, would u show how to embed the clustering api directly into a process in the java examples?  I realized that the api changed quite a lot from 2.1 to 3.0.  I was reading the code, and I was still trying to figure out where to look in carrot2 files.

Thanks.

JIRA dawid.weiss@cs.put.poznan.pl wrote
You should serialize DOM into a byte stream and then push it to the DCS using
plain HTTP POST with multipart content encoding.

Look here: http://hc.apache.org/httpclient-3.x/methods/multipartpost.html

If you serialize the input XML into ByteArrayPartSource, for example, the rest
should be trivial.

Serialization is always an overhead so if you can avoid it, better for you
(that's why we don't have an example in Java -- if you're using Java, it's much
better to embed clustering in your process directly).

D.

dealmaker wrote:
> Most of my time were spent on JAX-WS because somehow it always uses text/xml
> instead of multipart/form-data even when I told it to do so.  Maybe it's a
> JAX-WS bug.  And I was new in JAX-WS.
>
> In your java examples, would you show how to send DOMSource xml directly to
> DCS instead of a file?  I think that this method is more of a real world
> situation because no one is going to save temp data into a xml file then
> send it to DCS in production environment.
>
> Thanks.
>
>
> JIRA dawid.weiss@cs.put.poznan.pl wrote:
>>
>>> I have spent entire week trying to use java to send REST request to DCS,
>>> so
>> It's really hard to believe you've spent a week on something this
>> simple...
>>
>>> far no luck.  First, I tried to use JAX-WS, but it turns out that JAX-WS
>> Try Apache HTTP components -- they come with examples and should be easier
>> to
>> understand.
>>
>>> I am actually considering abandoning Carrot2.  Waste of time.
>> Like Staszek mentioned, we have very limited time for this. Also, note
>> that
>> writing such examples is a waste of time -- we'd rather focus on bugs and
>> pending features.
>>
>> In any case, we will add such an example of course.
>>
>> Dawid
>>
>> ------------------------------------------------------------------------------
>> Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
>> powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
>> easily build your RIAs with Flex Builder, the Eclipse(TM)based development
>> software that enables intelligent coding and step-through debugging.
>> Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
>> _______________________________________________
>> Carrot2-developers mailing list
>> Carrot2-developers@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/carrot2-developers
>>
>>
>

------------------------------------------------------------------------------
Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
easily build your RIAs with Flex Builder, the Eclipse(TM)based development
software that enables intelligent coding and step-through debugging.
Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
_______________________________________________
Carrot2-developers mailing list
Carrot2-developers@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/carrot2-developers
Reply | Threaded
Open this post in threaded view
|

Re: Can someone give examples of having java sending REST request to DCS?

Stanislaw Osinski
Administrator
Thanks.  In that case, would u show how to embed the clustering api directly
into a process in the java examples?  I realized that the api changed quite
a lot from 2.1 to 3.0.  I was reading the code, and I was still trying to
figure out where to look in carrot2 files.

Have you seen the examples distributed in:

http://download.carrot2.org/head/carrot2-java-api-3.1-dev.zip (or the stable version if you prefer)

The API is much simpler now, with just a few lines you should be up and running (you'd need JDK 1.5+ though).

S.

PS. I've just committed the Java DCS example, but I'll need to get webtests to run before the new dev distribution gets built.

------------------------------------------------------------------------------
Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
easily build your RIAs with Flex Builder, the Eclipse(TM)based development
software that enables intelligent coding and step-through debugging.
Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
_______________________________________________
Carrot2-developers mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/carrot2-developers
Reply | Threaded
Open this post in threaded view
|

Re: Can someone give examples of having java sending REST request to DCS?

Stanislaw Osinski
Administrator
PS. I've just committed the Java DCS example, but I'll need to get webtests to run before the new dev distribution gets built.

FYI: the examples should be available in the 3.1-dev distribution:

http://download.carrot2.org/head/carrot2-dcs-3.1-dev.zip

s.

------------------------------------------------------------------------------
Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
easily build your RIAs with Flex Builder, the Eclipse(TM)based development
software that enables intelligent coding and step-through debugging.
Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
_______________________________________________
Carrot2-developers mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/carrot2-developers