How do you use "URL must contain string" in a REST Service

If you have questions or if you want to share your opinion about Aware IM post your message on this forum
Post Reply
BobK
Posts: 544
Joined: Thu Jan 31, 2008 2:14 pm
Location: Cincinnati, Ohio, USA

How do you use "URL must contain string" in a REST Service

Post by BobK »

How do you use "URL must contain string" when exposing a REST Service?

I have a BSV named Test
A Service that exposes a REST service called TestInURL
This service accepts 1 piece of Plain Text data into an attribute called TheData

Without "URL must contain string"
The URL: http://localhost:8080/AwareIM/REST/Test ... input+data
works.

If I add "HI/BOB" to the "URL must contain string"
and put a text file called rest.props into the AwareIM/bin directory
and the text file contains DOMAIN=Test
The following URL does not work:

http://localhost:8080/AwareIM/HI/BOB?Th ... input+data
The following error was returned:
HTTP Status 404 – Not Found
Type Status Report
Message /AwareIM/HI/BOB
Description The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.


I also tried the following URLs which also did not work:

http://localhost:8080/AwareIM/HI/BOB/Te ... input+data
the following error was returned:
HTTP Status 404 – Not Found
Type Status Report
Message /AwareIM/HI/BOB/TestInUrl
Description The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.


http://localhost:8080/AwareIM/REST/HI/B ... input+data
the following error was returned:
HTTP Status 500 – Internal Server Error
Type Exception Report
Message com.bas.connectionserver.server.AccessDeniedException
Description The server encountered an unexpected condition that prevented it from fulfilling the request.
Bob
aware_support
Posts: 7523
Joined: Sun Apr 24, 2005 12:36 am
Contact:

Re: How do you use "URL must contain string" in a REST Servi

Post by aware_support »

It's probably a deficiency of the documentation. The URL that contains your string should also contain REST in the path, so in your case the path should be:
http://localhost:8080/AwareIM/REST/HI/B ... input+data
Aware IM Support Team
BobK
Posts: 544
Joined: Thu Jan 31, 2008 2:14 pm
Location: Cincinnati, Ohio, USA

Re: How do you use "URL must contain string" in a REST Servi

Post by BobK »

Still not working using build 2718

URL
http://localhost:8080/AwareIM/REST/HI/B ... input+data

Generates in the Server Output
Unable to determine business space version for user

Tomcat output
REST Servlet (GET) called
Connecting to server localhost at port 9000
com.bas.connectionserver.server.AccessDeniedException
at com.bas.connectionserver.server.ConnectionFactory.createLocalSocketConnection(ConnectionFactory.java:148)
at com.bas.webapp.common.WebAppUtils.logonToServer(Unknown Source)
at com.bas.webapp.common.WebAppUtils.A(Unknown Source)
at com.bas.webapp.common.WebAppUtils.logon(Unknown Source)
at com.bas.webapp.common.WebAppUtils.logon(Unknown Source)
at com.bas.webapp.thin.servlets.RESTServlet.A(Unknown Source)
at com.bas.webapp.thin.servlets.RESTServlet.doGet(Unknown Source)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:635)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:504)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:650)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:803)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:790)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1459)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:745)
Mar 09, 2020 12:28:56 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [RESTServlet] in context with path [/AwareIM] threw exception [com.bas.connectionserver.server.AccessDeniedException] with root cause
com.bas.connectionserver.server.AccessDeniedException
at com.bas.connectionserver.server.ConnectionFactory.createLocalSocketConnection(ConnectionFactory.java:148)
at com.bas.webapp.common.WebAppUtils.logonToServer(Unknown Source)
at com.bas.webapp.common.WebAppUtils.A(Unknown Source)
at com.bas.webapp.common.WebAppUtils.logon(Unknown Source)
at com.bas.webapp.common.WebAppUtils.logon(Unknown Source)
at com.bas.webapp.thin.servlets.RESTServlet.A(Unknown Source)
at com.bas.webapp.thin.servlets.RESTServlet.doGet(Unknown Source)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:635)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:504)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:650)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:803)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:790)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1459)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:745)
Bob
Jaymer
Posts: 2430
Joined: Tue Jan 13, 2015 10:58 am
Location: Tampa, FL
Contact:

Re: How do you use "URL must contain string" in a REST Servi

Post by Jaymer »

BobK.... have to ask, you're NOT trying this under Test right?
Click Here to see a collection of my tips & hacks on this forum. Or search for "JaymerTip" in the search bar at the top.

Jaymer
Aware Programming & Consulting - Tampa FL
BobK
Posts: 544
Joined: Thu Jan 31, 2008 2:14 pm
Location: Cincinnati, Ohio, USA

Re: How do you use "URL must contain string" in a REST Servi

Post by BobK »

Jaymer wrote:BobK.... have to ask, you're NOT trying this under Test right?
The BSV is NOT under Test.
Bob
aware_support
Posts: 7523
Joined: Sun Apr 24, 2005 12:36 am
Contact:

Re: How do you use "URL must contain string" in a REST Servi

Post by aware_support »

This can only indicate a problem in determining the business space of the request. Are you sure that you have the correct property file and that the business space has a published version?
Aware IM Support Team
BobK
Posts: 544
Joined: Thu Jan 31, 2008 2:14 pm
Location: Cincinnati, Ohio, USA

Re: How do you use "URL must contain string" in a REST Servi

Post by BobK »

aware_support wrote:This can only indicate a problem in determining the business space of the request. Are you sure that you have the correct property file and that the business space has a published version?
Yes I am sure the BSV is published an the property file is correct.
Bob
aware_support
Posts: 7523
Joined: Sun Apr 24, 2005 12:36 am
Contact:

Re: How do you use "URL must contain string" in a REST Servi

Post by aware_support »

rest.props file must be in the wrong location. Try to put it into AwareIM/CP/eclipse directory
Aware IM Support Team
BobK
Posts: 544
Joined: Thu Jan 31, 2008 2:14 pm
Location: Cincinnati, Ohio, USA

Re: How do you use "URL must contain string" in a REST Servi

Post by BobK »

After moving the rest.props file to AwareIM/CP/eclipse directory, I get the same errors as above.

BUT

If I remove the /REST from the URL and add extension .json like
http://localhost:8080/AwareIM/HI/BOB.js ... ta=TryThis

This worked and I got the expected results.
Bob
Jaymer
Posts: 2430
Joined: Tue Jan 13, 2015 10:58 am
Location: Tampa, FL
Contact:

Re: How do you use "URL must contain string" in a REST Servi

Post by Jaymer »

Dang Bobk, great job.
Tell me, what uses this type of syntax? It’s very obtuse.
Click Here to see a collection of my tips & hacks on this forum. Or search for "JaymerTip" in the search bar at the top.

Jaymer
Aware Programming & Consulting - Tampa FL
BobK
Posts: 544
Joined: Thu Jan 31, 2008 2:14 pm
Location: Cincinnati, Ohio, USA

Re: How do you use "URL must contain string" in a REST Servi

Post by BobK »

Jaymer,

I am working on integrating with a third party and data is being passed in both directions.

When I send data to this third party, their URL is something like
https://server/path/<account number>
with json data in the body of the request.

My application is multi tenant, so the account number could be one of several possible values.
I have no problem building that type of URL for sending them data. The problem is that I did not know how to create a service in AwareIM, that this third party would be sending data to, where some part of the URL would contain one of several different possible values (depending upon which one of my tenants the data was for).

In another post, AwareIM Support suggested using the "URL must contain string" option in the REST settings of exposed services.

HI/BOB was just the required string I was using in my investigation of how this option works. In production I would create a service for each of my clients and replace HI/BOB with their account number.

When I could not get this option to work, I created this thread.
Bob
BobK
Posts: 544
Joined: Thu Jan 31, 2008 2:14 pm
Location: Cincinnati, Ohio, USA

Re: How do you use "URL must contain string" in a REST Servi

Post by BobK »

It turns out that I do not need this functionality, and I guess no one else does either.
But if this functionality is going to be provided by AwareIM, it should work as advertised.

If the URL must contain the string: "someName1/someName2", The User Guide states to use a URL like:
[url]http://ServerName:port/AwareIM/someName1/someName2?parameters[/url]
This does not work and the Client receives:
HTTP Status 404 – Not Found
The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.


Earlier in this thread, support stated:
aware_support wrote:It's probably a deficiency of the documentation. The URL that contains your string should also contain REST in the path
So, I tried:
[url]http://ServerName:port/AwareIM/REST/someName1/someName2?parameters[/url]
This also did not work and the Client received:
HTTP Status 500 – Internal Server Error
The server encountered an unexpected condition that prevented it from fulfilling the request.

Server log also contained:
Unable to determine business space version for user


I also tried adding the extension .json for a URL something like:
[url]http://ServerName:port/AwareIM/someName1/someName2.json?parameters[/url]
This Worked but is not documented anywhere. I only stumbled upon this format because of some experimentation and I knew where to look because of my prior experience in web development.

Since using a .json extension works, that proves that I have everything else set up correctly.
So, the question is: why do the documented URLs (the first 2 above) not work?
Bob
BobK
Posts: 544
Joined: Thu Jan 31, 2008 2:14 pm
Location: Cincinnati, Ohio, USA

Re: How do you use "URL must contain string" in a REST Servi

Post by BobK »

From the changelog for build 2722:
5. "URL must contain string" option in REST services didn't work properly
:D

Sadly, it still does not work. :cry:


A URL like [url]http://ServerName:port/AwareIM/someName1/someName2?parameters[/url]
Nothing displays in any of the logs.
The following us returned to the client
HTTP Status 404 – Not Found
The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.



A URL like [url]http://ServerName:port/AwareIM/REST/someName1/someName2?parameters[/url]
The Server Output contains
Unable to determine business space version for user

The Tomcat Output contains
REST Servlet (GET) called
Connecting to server localhost at port 9000
com.bas.connectionserver.server.AccessDeniedException
at com.bas.connectionserver.server.ConnectionFactory.createLocalSocketConnection(ConnectionFactory.java:148)
at com.bas.webapp.common.WebAppUtils.logonToServer(Unknown Source)
at com.bas.webapp.common.WebAppUtils.A(Unknown Source)
at com.bas.webapp.common.WebAppUtils.logon(Unknown Source)
at com.bas.webapp.common.WebAppUtils.logon(Unknown Source)
at com.bas.webapp.thin.servlets.RESTServlet.A(Unknown Source)
at com.bas.webapp.thin.servlets.RESTServlet.doGet(Unknown Source)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:635)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:504)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:650)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:803)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:790)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1459)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:745)
May 12, 2020 3:45:38 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [RESTServlet] in context with path [/AwareIM] threw exception [com.bas.connectionserver.server.AccessDeniedException] with root cause
com.bas.connectionserver.server.AccessDeniedException
at com.bas.connectionserver.server.ConnectionFactory.createLocalSocketConnection(ConnectionFactory.java:148)
at com.bas.webapp.common.WebAppUtils.logonToServer(Unknown Source)
at com.bas.webapp.common.WebAppUtils.A(Unknown Source)
at com.bas.webapp.common.WebAppUtils.logon(Unknown Source)
at com.bas.webapp.common.WebAppUtils.logon(Unknown Source)
at com.bas.webapp.thin.servlets.RESTServlet.A(Unknown Source)
at com.bas.webapp.thin.servlets.RESTServlet.doGet(Unknown Source)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:635)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:504)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:650)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:803)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:790)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1459)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:745)
Last edited by BobK on Wed May 13, 2020 7:15 pm, edited 1 time in total.
Bob
Jaymer
Posts: 2430
Joined: Tue Jan 13, 2015 10:58 am
Location: Tampa, FL
Contact:

Re: How do you use "URL must contain string" in a REST Servi

Post by Jaymer »

I don’t think the first one will ever work. Nothing to “activate” the rest servlet. That’s why it’s has to be in \REST
Click Here to see a collection of my tips & hacks on this forum. Or search for "JaymerTip" in the search bar at the top.

Jaymer
Aware Programming & Consulting - Tampa FL
BobK
Posts: 544
Joined: Thu Jan 31, 2008 2:14 pm
Location: Cincinnati, Ohio, USA

Re: How do you use "URL must contain string" in a REST Servi

Post by BobK »

Jaymer wrote:I don’t think the first one will ever work. Nothing to “activate” the rest servlet. That’s why it’s has to be in \REST
I totally agree, but that is the format described in the Users Guide.
Bob
Post Reply