You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tuscany.apache.org by Luciano Resende <lu...@gmail.com> on 2010/02/26 19:50:32 UTC

Service Endpoint URI and it's behavior in Embedded versus Hosted Environment

Kelvin has identified a issue with store-webapp [1], and after some
investigation I  tried to summarize the current behavior in the
following wiki page [1]

Let's use this thread  to agree on what we think should be the proper
behavior, and then try to have a final solution to this issue, as
similar issues had come multiple times in the past [3][4]

[1] http://www.mail-archive.com/user@tuscany.apache.org/msg02268.html
[2] http://cwiki.apache.org/confluence/display/TUSCANYWIKI/Embedded+versus+Hosted+web+app+uri
[3] http://www.mail-archive.com/dev@tuscany.apache.org/msg10134.html
[4] http://www.mail-archive.com/dev@tuscany.apache.org/msg10284.html

-- 
Luciano Resende
http://people.apache.org/~lresende
http://twitter.com/lresende1975
http://lresende.blogspot.com/

Re: Service Endpoint URI and it's behavior in Embedded versus Hosted Environment

Posted by Luciano Resende <lu...@gmail.com>.
On Fri, Feb 26, 2010 at 2:13 PM, Raymond Feng <en...@gmail.com> wrote:
> Hi,
>
> Using a table is a good approach to document how the physical URI is
> constructed for a binding. I suggest that we add a few things:
>
> * A column for the base URI of the binding
> * Different rows to show the following:
>
> <binding.xyz/> <!-- no @uri -->
> <binding.xyz uri="http://example.com/ABC"/> <!-- absolute @uri -->
> <binding.xyz uri="ABC"/> <!-- relative URI not starting with / -->
> <binding.xyz uri="/ABC"/> <!-- relative URI starting with / -->
>

I have started a table in the expected behavior section [1], do we
thing we need any other info on that table ?

[1] http://cwiki.apache.org/confluence/display/TUSCANYWIKI/Embedded+versus+Hosted+web+app+uri

-- 
Luciano Resende
http://people.apache.org/~lresende
http://twitter.com/lresende1975
http://lresende.blogspot.com/

Re: Service Endpoint URI and it's behavior in Embedded versus Hosted Environment

Posted by Raymond Feng <en...@gmail.com>.
Hi,

Using a table is a good approach to document how the physical URI is 
constructed for a binding. I suggest that we add a few things:

* A column for the base URI of the binding
* Different rows to show the following:

<binding.xyz/> <!-- no @uri -->
<binding.xyz uri="http://example.com/ABC"/> <!-- absolute @uri -->
<binding.xyz uri="ABC"/> <!-- relative URI not starting with / -->
<binding.xyz uri="/ABC"/> <!-- relative URI starting with / -->

Thanks,
Raymond
--------------------------------------------------
From: "Luciano Resende" <lu...@gmail.com>
Sent: Friday, February 26, 2010 10:50 AM
To: "tuscany-dev" <de...@tuscany.apache.org>
Subject: Service Endpoint URI and it's behavior in Embedded versus Hosted 
Environment

> Kelvin has identified a issue with store-webapp [1], and after some
> investigation I  tried to summarize the current behavior in the
> following wiki page [1]
>
> Let's use this thread  to agree on what we think should be the proper
> behavior, and then try to have a final solution to this issue, as
> similar issues had come multiple times in the past [3][4]
>
> [1] http://www.mail-archive.com/user@tuscany.apache.org/msg02268.html
> [2] 
> http://cwiki.apache.org/confluence/display/TUSCANYWIKI/Embedded+versus+Hosted+web+app+uri
> [3] http://www.mail-archive.com/dev@tuscany.apache.org/msg10134.html
> [4] http://www.mail-archive.com/dev@tuscany.apache.org/msg10284.html
>
> -- 
> Luciano Resende
> http://people.apache.org/~lresende
> http://twitter.com/lresende1975
> http://lresende.blogspot.com/ 


Re: Service Endpoint URI and it's behavior in Embedded versus Hosted Environment

Posted by Luciano Resende <lu...@gmail.com>.
On Fri, Feb 26, 2010 at 11:35 AM, Simon Laws <si...@googlemail.com> wrote:
> So this seems to come down to how we interpret "/Catalog" in two
> different places.
>
> 1/ In javascript
> 2/ In an SCA (JSONRPC) binding URI
>
> I think it should be interpreted, in both of these places, in a way
> that is consistent with the specification of relative URIs in RFC2396
> [1].
>
> In the browser /Catalog will be interpreted as a root relative URL. In
> your case you have http://localhost:8080/Catalog.
>

Yes, this is the browser expectation.

> In the SCA binding we are indicating that we want the Catalog service
> made available at the URI "/Catalog". In lieu of a absolute path
> wouldn't we expect the runtime to interpret this a URI relative to the
> base URL with no path element, i.e. http://localhost:8080/Catalog?
>

Yes, that is my expectation as well, but it's not what's happening
when using host webapp in 2.x, where a service with URI /Catalog is
being registered relatively to the web application context root and is
available as http://localhost:9090/sample-store-webapp/Catalog

> Another way to look at this is to ask  how would you configure the
> binding if you did want the service to appear below the context root
> (which is possibly a reasonable, and safer, thing to do)?
>

This is a good question, and seems like a reasonable thing,
particularly if we want to scope the service to your application and
have multiple different versions of the same service provided form
different applications.... but if we can make the scenarios above
working, then, as long as the binding uri is properly configured,
things should work one way or another.

> If the binding uri were "Catalog" then the current code I believe adds
> the structural URI in front of the relative URI giving something like.
>  http://localhost:8080/context/component/service/Catalog. Which seems
> OK to me. In this case we've just constructed the base URI to which
> the binding URI is considered to be relative. As long as users
> understand this then can get any particular effect by manipulating the
> relative URI that they specify.
>

Yes, correct...
>
> [1] http://www.w3.org/TR/xmlschema-2/#RFC2396
>



-- 
Luciano Resende
http://people.apache.org/~lresende
http://twitter.com/lresende1975
http://lresende.blogspot.com/

Re: Service Endpoint URI and it's behavior in Embedded versus Hosted Environment

Posted by Simon Laws <si...@googlemail.com>.
So this seems to come down to how we interpret "/Catalog" in two
different places.

1/ In javascript
2/ In an SCA (JSONRPC) binding URI

I think it should be interpreted, in both of these places, in a way
that is consistent with the specification of relative URIs in RFC2396
[1].

In the browser /Catalog will be interpreted as a root relative URL. In
your case you have http://localhost:8080/Catalog.

In the SCA binding we are indicating that we want the Catalog service
made available at the URI "/Catalog". In lieu of a absolute path
wouldn't we expect the runtime to interpret this a URI relative to the
base URL with no path element, i.e. http://localhost:8080/Catalog?

Another way to look at this is to ask  how would you configure the
binding if you did want the service to appear below the context root
(which is possibly a reasonable, and safer, thing to do)?

If the binding uri were "Catalog" then the current code I believe adds
the structural URI in front of the relative URI giving something like.
 http://localhost:8080/context/component/service/Catalog. Which seems
OK to me. In this case we've just constructed the base URI to which
the binding URI is considered to be relative. As long as users
understand this then can get any particular effect by manipulating the
relative URI that they specify.

Regards

Simon

[1] http://www.w3.org/TR/xmlschema-2/#RFC2396

Re: Service Endpoint URI and it's behavior in Embedded versus Hosted Environment

Posted by Simon Laws <si...@googlemail.com>.
On Thu, Mar 4, 2010 at 8:54 PM, ant elder <an...@apache.org> wrote:
> An off-list comment in case you're not aware its happening - all the
> text of the emailing you're replying to is getting deleted these days
> so it can make it really hard to see what you commenting on,
> especially in gmail which just has a flat list of emails order by the
> time sent.
>
>   ...ant
>

Was this intended for me? Can you be a bit more specific and tell me
what I'm doing wrong? I can't parse you're comment.

Simon

Re: Service Endpoint URI and it's behavior in Embedded versus Hosted Environment

Posted by ant elder <an...@apache.org>.
An off-list comment in case you're not aware its happening - all the
text of the emailing you're replying to is getting deleted these days
so it can make it really hard to see what you commenting on,
especially in gmail which just has a flat list of emails order by the
time sent.

   ...ant

On Thu, Mar 4, 2010 at 12:10 AM, Simon Laws <si...@googlemail.com> wrote:
> And what URI is specified in the binding in this case, or is not URI specified?
>
> Simon
>

Re: Service Endpoint URI and it's behavior in Embedded versus Hosted Environment

Posted by Simon Laws <si...@googlemail.com>.
And what URI is specified in the binding in this case, or is not URI specified?

Simon

Re: Service Endpoint URI and it's behavior in Embedded versus Hosted Environment

Posted by ant elder <an...@apache.org>.
On Wed, Mar 3, 2010 at 9:56 PM, Simon Laws <si...@googlemail.com> wrote:
> A comment I don't understand marked below...
>
>>
>> 1 - when Tuscany is running embedded inside a webapp all the SCA
>> services will be registered at URLs relative to the URL that the
>> Tuscany ServletFilter is registered at, usually we register the filter
>> at /* so the SCA service URLs will be relative to the context path of
>> the webapp, which in Tomcat defaults to the webapp name. Eg for a
>> webapp named sample-store-webapp running on a server at localhost port
>> 8080 and an SCA service URI of Catalog the absolute URL to the service
>> would be http://localhost:8080/sample-store-webapp/Catalog
>>
>> 2 - from a browser a relative URL that doesn't start with a slash
>> character (/) will be relative to base URL of the page. Eg for
>> http://localhost:8080/sample-store-webapp/store.html the base url is
>> http://localhost:8080/sample-store-webapp so then using a relative URL
>> "Catalog" the absolute URL used would be
>> http://localhost:8080/sample-store-webapp/Catalog
>>
>> 3 - a relative URL starting with a slash character will be relative to
>> the base URL with the entire path removed. So in an HTML page if the
>> base url is http://localhost:8080/sample-store-webapp and the SCA
>> service URI is /Catalog the absolute URL would
>> http://localhost:8080/Catalog which from the above example wont work
>> as thats not where the service is at.
>>
>
> You've made a leap here and lost me. "from the above example wont work
> as thats not where the service is at.". Which example are you
> referring to?
>
> I think what you're saying is that the Javascript uses "/Catalog"
> while the service binding uses "Catalog". Is that what your mean?
>

I meant the example from point 1, so yes, the Javascript used
"/Catalog" so that ends up going to http://localhost:8080/Catalog but
the service is at http://localhost:8080/sample-store-webapp/Catalog

   ...ant

Re: Service Endpoint URI and it's behavior in Embedded versus Hosted Environment

Posted by Simon Laws <si...@googlemail.com>.
A comment I don't understand marked below...

>
> 1 - when Tuscany is running embedded inside a webapp all the SCA
> services will be registered at URLs relative to the URL that the
> Tuscany ServletFilter is registered at, usually we register the filter
> at /* so the SCA service URLs will be relative to the context path of
> the webapp, which in Tomcat defaults to the webapp name. Eg for a
> webapp named sample-store-webapp running on a server at localhost port
> 8080 and an SCA service URI of Catalog the absolute URL to the service
> would be http://localhost:8080/sample-store-webapp/Catalog
>
> 2 - from a browser a relative URL that doesn't start with a slash
> character (/) will be relative to base URL of the page. Eg for
> http://localhost:8080/sample-store-webapp/store.html the base url is
> http://localhost:8080/sample-store-webapp so then using a relative URL
> "Catalog" the absolute URL used would be
> http://localhost:8080/sample-store-webapp/Catalog
>
> 3 - a relative URL starting with a slash character will be relative to
> the base URL with the entire path removed. So in an HTML page if the
> base url is http://localhost:8080/sample-store-webapp and the SCA
> service URI is /Catalog the absolute URL would
> http://localhost:8080/Catalog which from the above example wont work
> as thats not where the service is at.
>

You've made a leap here and lost me. "from the above example wont work
as thats not where the service is at.". Which example are you
referring to?

I think what you're saying is that the Javascript uses "/Catalog"
while the service binding uses "Catalog". Is that what your mean?

Simon

Re: Service Endpoint URI and it's behavior in Embedded versus Hosted Environment

Posted by ant elder <an...@apache.org>.
On Mon, Mar 29, 2010 at 5:53 PM, Luciano Resende <lu...@gmail.com> wrote:
> On Mon, Mar 29, 2010 at 1:31 AM, ant elder <an...@apache.org> wrote:
>>
>> Hi Luciano, you've just reverted this change without any explanation,
>> would you say more?
>>
>>   ...ant
>>
>
> I'm experimenting with tweaking the generated widget js to handle
> this... as I didn't want to loose some of the functionality that you
> removed with these changes...
>
> but also, I thought this was just an experiment from you... based on [1]
>
> [1] http://tuscany.markmail.org/thread/t52jqjkr55unte2i
>

The changes did fix all the samples so removing them has now broken
the store-webapp sample. Fine if you think you can fix it some other
way but wouldn't it be better to wait till you have done that new fix
before taking out the old fix?

   ...ant

Re: Service Endpoint URI and it's behavior in Embedded versus Hosted Environment

Posted by Luciano Resende <lu...@gmail.com>.
On Mon, Mar 29, 2010 at 1:31 AM, ant elder <an...@apache.org> wrote:
>
> Hi Luciano, you've just reverted this change without any explanation,
> would you say more?
>
>   ...ant
>

I'm experimenting with tweaking the generated widget js to handle
this... as I didn't want to loose some of the functionality that you
removed with these changes...

but also, I thought this was just an experiment from you... based on [1]

[1] http://tuscany.markmail.org/thread/t52jqjkr55unte2i


-- 
Luciano Resende
http://people.apache.org/~lresende
http://twitter.com/lresende1975
http://lresende.blogspot.com/

Re: Service Endpoint URI and it's behavior in Embedded versus Hosted Environment

Posted by ant elder <an...@apache.org>.
On Tue, Mar 2, 2010 at 11:21 PM, ant elder <an...@apache.org> wrote:
> On Wed, Mar 3, 2010 at 11:14 AM, Luciano Resende <lu...@gmail.com> wrote:
>> On Tue, Mar 2, 2010 at 1:58 PM, ant elder <an...@gmail.com> wrote:
>>> On Sat, Feb 27, 2010 at 7:50 AM, Luciano Resende <lu...@gmail.com> wrote:
>>>> Kelvin has identified a issue with store-webapp [1], and after some
>>>> investigation I  tried to summarize the current behavior in the
>>>> following wiki page [1]
>>>>
>>>> Let's use this thread  to agree on what we think should be the proper
>>>> behavior, and then try to have a final solution to this issue, as
>>>> similar issues had come multiple times in the past [3][4]
>>>>
>>>> [1] http://www.mail-archive.com/user@tuscany.apache.org/msg02268.html
>>>> [2] http://cwiki.apache.org/confluence/display/TUSCANYWIKI/Embedded+versus+Hosted+web+app+uri
>>>> [3] http://www.mail-archive.com/dev@tuscany.apache.org/msg10134.html
>>>> [4] http://www.mail-archive.com/dev@tuscany.apache.org/msg10284.html
>>>>
>>>> --
>>>> Luciano Resende
>>>> http://people.apache.org/~lresende
>>>> http://twitter.com/lresende1975
>>>> http://lresende.blogspot.com/
>>>>
>>>
>>> Luciano chatted to me off list about this so i had a look whats going on:
>>>
>>> 1 - when Tuscany is running embedded inside a webapp all the SCA
>>> services will be registered at URLs relative to the URL that the
>>> Tuscany ServletFilter is registered at, usually we register the filter
>>> at /* so the SCA service URLs will be relative to the context path of
>>> the webapp, which in Tomcat defaults to the webapp name. Eg for a
>>> webapp named sample-store-webapp running on a server at localhost port
>>> 8080 and an SCA service URI of Catalog the absolute URL to the service
>>> would be http://localhost:8080/sample-store-webapp/Catalog
>>>
>>> 2 - from a browser a relative URL that doesn't start with a slash
>>> character (/) will be relative to base URL of the page. Eg for
>>> http://localhost:8080/sample-store-webapp/store.html the base url is
>>> http://localhost:8080/sample-store-webapp so then using a relative URL
>>> "Catalog" the absolute URL used would be
>>> http://localhost:8080/sample-store-webapp/Catalog
>>>
>>> 3 - a relative URL starting with a slash character will be relative to
>>> the base URL with the entire path removed. So in an HTML page if the
>>> base url is http://localhost:8080/sample-store-webapp and the SCA
>>> service URI is /Catalog the absolute URL would
>>> http://localhost:8080/Catalog which from the above example wont work
>>> as thats not where the service is at.
>>>
>>> 4 - when running in the Tuscany standalone runtime all the above still
>>> applies but there is no webapp context path and the base URL path is
>>> usually left empty, eg just http://localhost:8080, (but it is possible
>>> to define a path on the HTTP base URL via the Tuscany APIs).
>>>
>>> So, from the above item 3 browser JavaScript probably shouldn't be
>>> using relative URLs starting with a slash, which for
>>> implementation.widget means that the JavascriptProxyFactory impls
>>> should be either removing the leading slash in the targetPath when
>>> generating the JavaScript code or else taking account of the base URL
>>> and manually adding that to the targetPath.
>>>
>>> Doing the simple fix of just removing the leading slash gets the
>>> store-webapp sample working, but it breaks the standalone store
>>> sample. Thats because the standalone sample uses a binding.http with a
>>> uri of "/store", so the Store.html page has a base URL of
>>> http://localhost:8080/store and thats used by the generated JavaScript
>>> as the base URL for the SCA services, eg
>>> http://localhost:8080/store/Catalog but the services are registered at
>>> http://localhost:8080/Catalog. Changing the binding.http to not use
>>> the URI attribute doesn't seem to work which seems like a bug in the
>>> http binding code but using a uri of "/" does work and then both the
>>> standalone and webapp based store samples run ok for me.
>>>
>>> I could check these three changes in as it seems to get everything
>>> working but it does seem a little fragile, if anyone does ever use a
>>> uri in the http binding or change the base uri then it would break
>>> again.I wonder if the Tuscany binding.http should really be trying to
>>> do all this, if anyone wants to have a full blown web application it
>>> might be easier to just use a real JEE webapp.
>>>
>>>   ...ant
>>>
>>
>> Thanks for double checking... could you send a patch of your changes
>> so I can take a quick look.
>>
>
> Was easier to just check them in so did that in 918221 - 918223 so you
> can see what i meant, feel free to revert or modify. The build does go
> through cleanly like this.
>
>   ...ant
>

Hi Luciano, you've just reverted this change without any explanation,
would you say more?

   ...ant

Re: Service Endpoint URI and it's behavior in Embedded versus Hosted Environment

Posted by ant elder <an...@apache.org>.
On Wed, Mar 3, 2010 at 11:14 AM, Luciano Resende <lu...@gmail.com> wrote:
> On Tue, Mar 2, 2010 at 1:58 PM, ant elder <an...@gmail.com> wrote:
>> On Sat, Feb 27, 2010 at 7:50 AM, Luciano Resende <lu...@gmail.com> wrote:
>>> Kelvin has identified a issue with store-webapp [1], and after some
>>> investigation I  tried to summarize the current behavior in the
>>> following wiki page [1]
>>>
>>> Let's use this thread  to agree on what we think should be the proper
>>> behavior, and then try to have a final solution to this issue, as
>>> similar issues had come multiple times in the past [3][4]
>>>
>>> [1] http://www.mail-archive.com/user@tuscany.apache.org/msg02268.html
>>> [2] http://cwiki.apache.org/confluence/display/TUSCANYWIKI/Embedded+versus+Hosted+web+app+uri
>>> [3] http://www.mail-archive.com/dev@tuscany.apache.org/msg10134.html
>>> [4] http://www.mail-archive.com/dev@tuscany.apache.org/msg10284.html
>>>
>>> --
>>> Luciano Resende
>>> http://people.apache.org/~lresende
>>> http://twitter.com/lresende1975
>>> http://lresende.blogspot.com/
>>>
>>
>> Luciano chatted to me off list about this so i had a look whats going on:
>>
>> 1 - when Tuscany is running embedded inside a webapp all the SCA
>> services will be registered at URLs relative to the URL that the
>> Tuscany ServletFilter is registered at, usually we register the filter
>> at /* so the SCA service URLs will be relative to the context path of
>> the webapp, which in Tomcat defaults to the webapp name. Eg for a
>> webapp named sample-store-webapp running on a server at localhost port
>> 8080 and an SCA service URI of Catalog the absolute URL to the service
>> would be http://localhost:8080/sample-store-webapp/Catalog
>>
>> 2 - from a browser a relative URL that doesn't start with a slash
>> character (/) will be relative to base URL of the page. Eg for
>> http://localhost:8080/sample-store-webapp/store.html the base url is
>> http://localhost:8080/sample-store-webapp so then using a relative URL
>> "Catalog" the absolute URL used would be
>> http://localhost:8080/sample-store-webapp/Catalog
>>
>> 3 - a relative URL starting with a slash character will be relative to
>> the base URL with the entire path removed. So in an HTML page if the
>> base url is http://localhost:8080/sample-store-webapp and the SCA
>> service URI is /Catalog the absolute URL would
>> http://localhost:8080/Catalog which from the above example wont work
>> as thats not where the service is at.
>>
>> 4 - when running in the Tuscany standalone runtime all the above still
>> applies but there is no webapp context path and the base URL path is
>> usually left empty, eg just http://localhost:8080, (but it is possible
>> to define a path on the HTTP base URL via the Tuscany APIs).
>>
>> So, from the above item 3 browser JavaScript probably shouldn't be
>> using relative URLs starting with a slash, which for
>> implementation.widget means that the JavascriptProxyFactory impls
>> should be either removing the leading slash in the targetPath when
>> generating the JavaScript code or else taking account of the base URL
>> and manually adding that to the targetPath.
>>
>> Doing the simple fix of just removing the leading slash gets the
>> store-webapp sample working, but it breaks the standalone store
>> sample. Thats because the standalone sample uses a binding.http with a
>> uri of "/store", so the Store.html page has a base URL of
>> http://localhost:8080/store and thats used by the generated JavaScript
>> as the base URL for the SCA services, eg
>> http://localhost:8080/store/Catalog but the services are registered at
>> http://localhost:8080/Catalog. Changing the binding.http to not use
>> the URI attribute doesn't seem to work which seems like a bug in the
>> http binding code but using a uri of "/" does work and then both the
>> standalone and webapp based store samples run ok for me.
>>
>> I could check these three changes in as it seems to get everything
>> working but it does seem a little fragile, if anyone does ever use a
>> uri in the http binding or change the base uri then it would break
>> again.I wonder if the Tuscany binding.http should really be trying to
>> do all this, if anyone wants to have a full blown web application it
>> might be easier to just use a real JEE webapp.
>>
>>   ...ant
>>
>
> Thanks for double checking... could you send a patch of your changes
> so I can take a quick look.
>

Was easier to just check them in so did that in 918221 - 918223 so you
can see what i meant, feel free to revert or modify. The build does go
through cleanly like this.

   ...ant

Re: Service Endpoint URI and it's behavior in Embedded versus Hosted Environment

Posted by Luciano Resende <lu...@gmail.com>.
On Tue, Mar 2, 2010 at 1:58 PM, ant elder <an...@gmail.com> wrote:
> On Sat, Feb 27, 2010 at 7:50 AM, Luciano Resende <lu...@gmail.com> wrote:
>> Kelvin has identified a issue with store-webapp [1], and after some
>> investigation I  tried to summarize the current behavior in the
>> following wiki page [1]
>>
>> Let's use this thread  to agree on what we think should be the proper
>> behavior, and then try to have a final solution to this issue, as
>> similar issues had come multiple times in the past [3][4]
>>
>> [1] http://www.mail-archive.com/user@tuscany.apache.org/msg02268.html
>> [2] http://cwiki.apache.org/confluence/display/TUSCANYWIKI/Embedded+versus+Hosted+web+app+uri
>> [3] http://www.mail-archive.com/dev@tuscany.apache.org/msg10134.html
>> [4] http://www.mail-archive.com/dev@tuscany.apache.org/msg10284.html
>>
>> --
>> Luciano Resende
>> http://people.apache.org/~lresende
>> http://twitter.com/lresende1975
>> http://lresende.blogspot.com/
>>
>
> Luciano chatted to me off list about this so i had a look whats going on:
>
> 1 - when Tuscany is running embedded inside a webapp all the SCA
> services will be registered at URLs relative to the URL that the
> Tuscany ServletFilter is registered at, usually we register the filter
> at /* so the SCA service URLs will be relative to the context path of
> the webapp, which in Tomcat defaults to the webapp name. Eg for a
> webapp named sample-store-webapp running on a server at localhost port
> 8080 and an SCA service URI of Catalog the absolute URL to the service
> would be http://localhost:8080/sample-store-webapp/Catalog
>
> 2 - from a browser a relative URL that doesn't start with a slash
> character (/) will be relative to base URL of the page. Eg for
> http://localhost:8080/sample-store-webapp/store.html the base url is
> http://localhost:8080/sample-store-webapp so then using a relative URL
> "Catalog" the absolute URL used would be
> http://localhost:8080/sample-store-webapp/Catalog
>
> 3 - a relative URL starting with a slash character will be relative to
> the base URL with the entire path removed. So in an HTML page if the
> base url is http://localhost:8080/sample-store-webapp and the SCA
> service URI is /Catalog the absolute URL would
> http://localhost:8080/Catalog which from the above example wont work
> as thats not where the service is at.
>
> 4 - when running in the Tuscany standalone runtime all the above still
> applies but there is no webapp context path and the base URL path is
> usually left empty, eg just http://localhost:8080, (but it is possible
> to define a path on the HTTP base URL via the Tuscany APIs).
>
> So, from the above item 3 browser JavaScript probably shouldn't be
> using relative URLs starting with a slash, which for
> implementation.widget means that the JavascriptProxyFactory impls
> should be either removing the leading slash in the targetPath when
> generating the JavaScript code or else taking account of the base URL
> and manually adding that to the targetPath.
>
> Doing the simple fix of just removing the leading slash gets the
> store-webapp sample working, but it breaks the standalone store
> sample. Thats because the standalone sample uses a binding.http with a
> uri of "/store", so the Store.html page has a base URL of
> http://localhost:8080/store and thats used by the generated JavaScript
> as the base URL for the SCA services, eg
> http://localhost:8080/store/Catalog but the services are registered at
> http://localhost:8080/Catalog. Changing the binding.http to not use
> the URI attribute doesn't seem to work which seems like a bug in the
> http binding code but using a uri of "/" does work and then both the
> standalone and webapp based store samples run ok for me.
>
> I could check these three changes in as it seems to get everything
> working but it does seem a little fragile, if anyone does ever use a
> uri in the http binding or change the base uri then it would break
> again.I wonder if the Tuscany binding.http should really be trying to
> do all this, if anyone wants to have a full blown web application it
> might be easier to just use a real JEE webapp.
>
>   ...ant
>

Thanks for double checking... could you send a patch of your changes
so I can take a quick look.

-- 
Luciano Resende
http://people.apache.org/~lresende
http://twitter.com/lresende1975
http://lresende.blogspot.com/

Re: Service Endpoint URI and it's behavior in Embedded versus Hosted Environment

Posted by ant elder <an...@gmail.com>.
On Sat, Feb 27, 2010 at 7:50 AM, Luciano Resende <lu...@gmail.com> wrote:
> Kelvin has identified a issue with store-webapp [1], and after some
> investigation I  tried to summarize the current behavior in the
> following wiki page [1]
>
> Let's use this thread  to agree on what we think should be the proper
> behavior, and then try to have a final solution to this issue, as
> similar issues had come multiple times in the past [3][4]
>
> [1] http://www.mail-archive.com/user@tuscany.apache.org/msg02268.html
> [2] http://cwiki.apache.org/confluence/display/TUSCANYWIKI/Embedded+versus+Hosted+web+app+uri
> [3] http://www.mail-archive.com/dev@tuscany.apache.org/msg10134.html
> [4] http://www.mail-archive.com/dev@tuscany.apache.org/msg10284.html
>
> --
> Luciano Resende
> http://people.apache.org/~lresende
> http://twitter.com/lresende1975
> http://lresende.blogspot.com/
>

Luciano chatted to me off list about this so i had a look whats going on:

1 - when Tuscany is running embedded inside a webapp all the SCA
services will be registered at URLs relative to the URL that the
Tuscany ServletFilter is registered at, usually we register the filter
at /* so the SCA service URLs will be relative to the context path of
the webapp, which in Tomcat defaults to the webapp name. Eg for a
webapp named sample-store-webapp running on a server at localhost port
8080 and an SCA service URI of Catalog the absolute URL to the service
would be http://localhost:8080/sample-store-webapp/Catalog

2 - from a browser a relative URL that doesn't start with a slash
character (/) will be relative to base URL of the page. Eg for
http://localhost:8080/sample-store-webapp/store.html the base url is
http://localhost:8080/sample-store-webapp so then using a relative URL
"Catalog" the absolute URL used would be
http://localhost:8080/sample-store-webapp/Catalog

3 - a relative URL starting with a slash character will be relative to
the base URL with the entire path removed. So in an HTML page if the
base url is http://localhost:8080/sample-store-webapp and the SCA
service URI is /Catalog the absolute URL would
http://localhost:8080/Catalog which from the above example wont work
as thats not where the service is at.

4 - when running in the Tuscany standalone runtime all the above still
applies but there is no webapp context path and the base URL path is
usually left empty, eg just http://localhost:8080, (but it is possible
to define a path on the HTTP base URL via the Tuscany APIs).

So, from the above item 3 browser JavaScript probably shouldn't be
using relative URLs starting with a slash, which for
implementation.widget means that the JavascriptProxyFactory impls
should be either removing the leading slash in the targetPath when
generating the JavaScript code or else taking account of the base URL
and manually adding that to the targetPath.

Doing the simple fix of just removing the leading slash gets the
store-webapp sample working, but it breaks the standalone store
sample. Thats because the standalone sample uses a binding.http with a
uri of "/store", so the Store.html page has a base URL of
http://localhost:8080/store and thats used by the generated JavaScript
as the base URL for the SCA services, eg
http://localhost:8080/store/Catalog but the services are registered at
http://localhost:8080/Catalog. Changing the binding.http to not use
the URI attribute doesn't seem to work which seems like a bug in the
http binding code but using a uri of "/" does work and then both the
standalone and webapp based store samples run ok for me.

I could check these three changes in as it seems to get everything
working but it does seem a little fragile, if anyone does ever use a
uri in the http binding or change the base uri then it would break
again.I wonder if the Tuscany binding.http should really be trying to
do all this, if anyone wants to have a full blown web application it
might be easier to just use a real JEE webapp.

   ...ant