You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomee.apache.org by tonywestonuk <to...@totspics.com> on 2016/04/21 11:14:47 UTC

Make REST call to an app running in a different context

Hi,

I have Tomee running two applications, a and b, in different contexts.

I would like a to make a REST call to b.  I could just use UrlConnection to
do this, however b has basic authentication enabled so it makes things more
tricky...

I was wondering if there is a way, maybe enabling crosscontext="true", That
I could make a REST call directly to the other context, rather than going
via HTTP?

Any ideas?
Thanks.



--
View this message in context: http://tomee-openejb.979440.n4.nabble.com/Make-REST-call-to-an-app-running-in-a-different-context-tp4678180.html
Sent from the TomEE Users mailing list archive at Nabble.com.

Re: Make REST call to an app running in a different context

Posted by Romain Manni-Bucau <rm...@gmail.com>.
well probably the wrong forum ;)

CORS is relevant for inter domain browser based calls in general. For
server to server calls you can do something else and the client rarely
enforce the domain validation.


Romain Manni-Bucau
@rmannibucau <https://twitter.com/rmannibucau> |  Blog
<http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> |
LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
<http://www.tomitribe.com> | JavaEE Factory
<https://javaeefactory-rmannibucau.rhcloud.com>

2016-04-26 12:35 GMT+02:00 mauro2java2011 <ma...@gmail.com>:

> But a example for when use corse?
>
> All rest resources are    callable from any client.
> So when use rest resources cross context?
>
> Into netbeans corse is for test rest resources from the ide.
> But for a use real ?
>
>
>
>
>
> --
> View this message in context:
> http://tomee-openejb.979440.n4.nabble.com/Make-REST-call-to-an-app-running-in-a-different-context-tp4678180p4678268.html
> Sent from the TomEE Users mailing list archive at Nabble.com.
>

Re: Make REST call to an app running in a different context

Posted by mauro2java2011 <ma...@gmail.com>.
But a example for when use corse? 

All rest resources are    callable from any client. 
So when use rest resources cross context?

Into netbeans corse is for test rest resources from the ide. 
But for a use real ?





--
View this message in context: http://tomee-openejb.979440.n4.nabble.com/Make-REST-call-to-an-app-running-in-a-different-context-tp4678180p4678268.html
Sent from the TomEE Users mailing list archive at Nabble.com.

Re: Make REST call to an app running in a different context

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Thanks, note tomee/tomcat provides one filter OOTB:
https://tomcat.apache.org/tomcat-7.0-doc/config/filter.html#CORS_Filter


Romain Manni-Bucau
@rmannibucau <https://twitter.com/rmannibucau> |  Blog
<http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> |
LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
<http://www.tomitribe.com> | JavaEE Factory
<https://javaeefactory-rmannibucau.rhcloud.com>

2016-04-26 10:49 GMT+02:00 mauro2java2011 <ma...@gmail.com>:

> the solution it is at the following link?
>
> http://stackoverflow.com/questions/10343892/glassfish-how-to-set-access-control-allow-origin-header
>
>
>
> --
> View this message in context:
> http://tomee-openejb.979440.n4.nabble.com/Make-REST-call-to-an-app-running-in-a-different-context-tp4678180p4678263.html
> Sent from the TomEE Users mailing list archive at Nabble.com.
>

Re: Make REST call to an app running in a different context

Posted by mauro2java2011 <ma...@gmail.com>.
the solution it is at the following link?
http://stackoverflow.com/questions/10343892/glassfish-how-to-set-access-control-allow-origin-header



--
View this message in context: http://tomee-openejb.979440.n4.nabble.com/Make-REST-call-to-an-app-running-in-a-different-context-tp4678180p4678263.html
Sent from the TomEE Users mailing list archive at Nabble.com.

Re: Make REST call to an app running in a different context

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Hi Mauro, this is a question for netbeans.


@tony: using WebClient (CXF API) or ClientBuilder for TomEE 7 you can add
the header pretty easily (otherwise it is doable with httpurlconnection
using setrequestproperty). Alternative is to use some internals to switch
of context but I think you don't want to go this way. If both apps are the
"same" maybe merging them in a single war can make sense too. Depends your
overall use case.



Romain Manni-Bucau
@rmannibucau <https://twitter.com/rmannibucau> |  Blog
<http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> |
LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
<http://www.tomitribe.com> | JavaEE Factory
<https://javaeefactory-rmannibucau.rhcloud.com>

2016-04-26 10:40 GMT+02:00 mauro2java2011 <ma...@gmail.com>:

> hi .
> I have noted on netbeans that into categories web services is present a
> wizard called
>
> CrossOriginResourceSharingFilter .
>
> it Creates Cross-Origin Resource Sharing filter for RESTful service which
> allows to access resources from different domains.
> But into the wizard i get :
>
> REST is not configured. Create some REST resource first.
>
> but i have before creted the REST services,..
>
> Help me.
>
>
>
>
> --
> View this message in context:
> http://tomee-openejb.979440.n4.nabble.com/Make-REST-call-to-an-app-running-in-a-different-context-tp4678180p4678261.html
> Sent from the TomEE Users mailing list archive at Nabble.com.
>

Re: Make REST call to an app running in a different context

Posted by mauro2java2011 <ma...@gmail.com>.
hi . 
I have noted on netbeans that into categories web services is present a
wizard called 

CrossOriginResourceSharingFilter .

it Creates Cross-Origin Resource Sharing filter for RESTful service which
allows to access resources from different domains.
But into the wizard i get :

REST is not configured. Create some REST resource first.

but i have before creted the REST services,..

Help me.




--
View this message in context: http://tomee-openejb.979440.n4.nabble.com/Make-REST-call-to-an-app-running-in-a-different-context-tp4678180p4678261.html
Sent from the TomEE Users mailing list archive at Nabble.com.