Hello All ,
Is it possible to direct the webservice call to a particular tenant using XMLRPC? I am referring to https://cwiki.apache.org/confluence/display/OFBIZ/Using+XMLRPC+as+an+alternative+to+SOAP consider the snippet ======================================================= XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl(); config.setServerURL(new URL(" http://127.0.0.1/webtools/control/xmlrpc" <http://127.0.0.1/webtools/control/xmlrpc>)); config.setEnabledForExceptions(true); config.setEnabledForExtensions(true); XmlRpcClient client = new XmlRpcClient(); client.setConfig(config); Map paramMap = new HashMap(); paramMap.put("login.username", "admin"); paramMap.put("login.password", "ofbiz"); paramMap.put("idToFind", "admin"); ======================================================================= I tried setting the host part of serverUrl to domain_name of tenant_domain_name . I find that the requests always work on the first tenant . i need to work with a specific tenant . Any help is solicited. regds mallah. |
Hi Rajesh,
It looks like the XmlRpcEventHandler class doesn't support this but it could easily be modified to do so. I'd suggest filing a ticket, and perhaps even providing a patch :-) The tenantId just needs to be derived from the url and then passed into the userLogin service in the OfbizRpcAuthHandler.isAuthorized(...) method. Regards Scott On 16 March 2018 at 00:22, Rajesh Mallah <[hidden email]> wrote: > Hello All , > > Is it possible to direct the webservice call to a particular tenant using > XMLRPC? > > I am referring to > > > https://cwiki.apache.org/confluence/display/OFBIZ/Using+XMLRPC+as+an+ > alternative+to+SOAP > > > consider the snippet > > ======================================================= > XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl(); > config.setServerURL(new URL(" > http://127.0.0.1/webtools/control/xmlrpc" > <http://127.0.0.1/webtools/control/xmlrpc>)); > config.setEnabledForExceptions(true); > config.setEnabledForExtensions(true); > > XmlRpcClient client = new XmlRpcClient(); > client.setConfig(config); > > Map paramMap = new HashMap(); > paramMap.put("login.username", "admin"); > paramMap.put("login.password", "ofbiz"); > paramMap.put("idToFind", "admin"); > ======================================================================= > I tried setting the host part of serverUrl to domain_name of > tenant_domain_name . > > I find that the requests always work on the first tenant . > i need to work with a specific tenant . > > Any help is solicited. > > regds > mallah. > |
Hey Thanks so much for taking the time and even suggesting a
to solution. BTW i saw that the SOAP handler does it well. I would definitely try. regds mallah. On Thu, Mar 15, 2018 at 9:51 PM, Scott Gray <[hidden email]> wrote: > Hi Rajesh, > > It looks like the XmlRpcEventHandler class doesn't support this but it > could easily be modified to do so. I'd suggest filing a ticket, and > perhaps even providing a patch :-) > > The tenantId just needs to be derived from the url and then passed into the > userLogin service in the OfbizRpcAuthHandler.isAuthorized(...) method. > > Regards > Scott > > On 16 March 2018 at 00:22, Rajesh Mallah <[hidden email]> wrote: > > > Hello All , > > > > Is it possible to direct the webservice call to a particular tenant using > > XMLRPC? > > > > I am referring to > > > > > > https://cwiki.apache.org/confluence/display/OFBIZ/Using+XMLRPC+as+an+ > > alternative+to+SOAP > > > > > > consider the snippet > > > > ======================================================= > > XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl(); > > config.setServerURL(new URL(" > > http://127.0.0.1/webtools/control/xmlrpc" > > <http://127.0.0.1/webtools/control/xmlrpc>)); > > config.setEnabledForExceptions(true); > > config.setEnabledForExtensions(true); > > > > XmlRpcClient client = new XmlRpcClient(); > > client.setConfig(config); > > > > Map paramMap = new HashMap(); > > paramMap.put("login.username", "admin"); > > paramMap.put("login.password", "ofbiz"); > > paramMap.put("idToFind", "admin"); > > ======================================================================= > > I tried setting the host part of serverUrl to domain_name of > > tenant_domain_name . > > > > I find that the requests always work on the first tenant . > > i need to work with a specific tenant . > > > > Any help is solicited. > > > > regds > > mallah. > > > |
In reply to this post by Scott Gray-3
Hi Scott ,
I could get it to work by setting dispatcher and delegator only. I referred SOAPEventHandler.java which handles tenants fine. I could not see userLogin handling tenantId as suggested by you, can you please see the below and tell if it is correct. Do we have test coverage to see if does not break anything else? $ diff -u5 XmlRpcEventHandler.java.orig XmlRpcEventHandler.java --- XmlRpcEventHandler.java.orig 2018-03-15 23:29:46.954352066 +0530 +++ XmlRpcEventHandler.java 2018-03-15 23:29:51.734435105 +0530 @@ -91,10 +91,12 @@ /** * @see org.apache.ofbiz.webapp.event.EventHandler#invoke(ConfigXMLReader.Event, ConfigXMLReader.RequestMap, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse) */ public String invoke(Event event, RequestMap requestMap, HttpServletRequest request, HttpServletResponse response) throws EventHandlerException { String report = request.getParameter("echo"); + dispatcher = (LocalDispatcher) request.getAttribute("dispatcher"); + delegator = (Delegator) request.getAttribute("delegator"); if (report != null) { BufferedReader reader = null; StringBuilder buf = new StringBuilder(); try { // read the inputstream buffer On Thu, Mar 15, 2018 at 9:51 PM, Scott Gray <[hidden email]> wrote: > Hi Rajesh, > > It looks like the XmlRpcEventHandler class doesn't support this but it > could easily be modified to do so. I'd suggest filing a ticket, and > perhaps even providing a patch :-) > > The tenantId just needs to be derived from the url and then passed into the > userLogin service in the OfbizRpcAuthHandler.isAuthorized(...) method. > > Regards > Scott > > On 16 March 2018 at 00:22, Rajesh Mallah <[hidden email]> wrote: > > > Hello All , > > > > Is it possible to direct the webservice call to a particular tenant using > > XMLRPC? > > > > I am referring to > > > > > > https://cwiki.apache.org/confluence/display/OFBIZ/Using+XMLRPC+as+an+ > > alternative+to+SOAP > > > > > > consider the snippet > > > > ======================================================= > > XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl(); > > config.setServerURL(new URL(" > > http://127.0.0.1/webtools/control/xmlrpc" > > <http://127.0.0.1/webtools/control/xmlrpc>)); > > config.setEnabledForExceptions(true); > > config.setEnabledForExtensions(true); > > > > XmlRpcClient client = new XmlRpcClient(); > > client.setConfig(config); > > > > Map paramMap = new HashMap(); > > paramMap.put("login.username", "admin"); > > paramMap.put("login.password", "ofbiz"); > > paramMap.put("idToFind", "admin"); > > ======================================================================= > > I tried setting the host part of serverUrl to domain_name of > > tenant_domain_name . > > > > I find that the requests always work on the first tenant . > > i need to work with a specific tenant . > > > > Any help is solicited. > > > > regds > > mallah. > > > |
You're completely right Rajesh, sorry, I jumped the gun without having a
proper look in my reply. Your fix looks correct except that we need to move dispatcher/delegator to local variables rather than instance fields. The EventHandler objects are singletons shared among all incoming requests so we don't want to store request-specific objects in fields that are accessed by all requests or the results will get pretty unpredictable for concurrent requests across multiple tenants. Regards Scott On 16 March 2018 at 07:01, Rajesh Mallah <[hidden email]> wrote: > Hi Scott , > > I could get it to work by setting dispatcher and delegator only. > I referred SOAPEventHandler.java which handles tenants fine. > > I could not see userLogin handling tenantId as suggested by you, > can you please see the below and tell if it is correct. > > Do we have test coverage to see if does not break anything else? > > $ diff -u5 XmlRpcEventHandler.java.orig XmlRpcEventHandler.java > --- XmlRpcEventHandler.java.orig 2018-03-15 23:29:46.954352066 +0530 > +++ XmlRpcEventHandler.java 2018-03-15 23:29:51.734435105 +0530 > @@ -91,10 +91,12 @@ > /** > * @see > org.apache.ofbiz.webapp.event.EventHandler#invoke(ConfigXMLReader.Event, > ConfigXMLReader.RequestMap, javax.servlet.http.HttpServletRequest, > javax.servlet.http.HttpServletResponse) > */ > public String invoke(Event event, RequestMap requestMap, > HttpServletRequest request, HttpServletResponse response) throws > EventHandlerException { > String report = request.getParameter("echo"); > + dispatcher = (LocalDispatcher) request.getAttribute(" > dispatcher"); > + delegator = (Delegator) request.getAttribute("delegator"); > if (report != null) { > BufferedReader reader = null; > StringBuilder buf = new StringBuilder(); > try { > // read the inputstream buffer > > > > On Thu, Mar 15, 2018 at 9:51 PM, Scott Gray <[hidden email]> > wrote: > > > Hi Rajesh, > > > > It looks like the XmlRpcEventHandler class doesn't support this but it > > could easily be modified to do so. I'd suggest filing a ticket, and > > perhaps even providing a patch :-) > > > > The tenantId just needs to be derived from the url and then passed into > the > > userLogin service in the OfbizRpcAuthHandler.isAuthorized(...) method. > > > > Regards > > Scott > > > > On 16 March 2018 at 00:22, Rajesh Mallah <[hidden email]> > wrote: > > > > > Hello All , > > > > > > Is it possible to direct the webservice call to a particular tenant > using > > > XMLRPC? > > > > > > I am referring to > > > > > > > > > https://cwiki.apache.org/confluence/display/OFBIZ/Using+XMLRPC+as+an+ > > > alternative+to+SOAP > > > > > > > > > consider the snippet > > > > > > ======================================================= > > > XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl(); > > > config.setServerURL(new URL(" > > > http://127.0.0.1/webtools/control/xmlrpc" > > > <http://127.0.0.1/webtools/control/xmlrpc>)); > > > config.setEnabledForExceptions(true); > > > config.setEnabledForExtensions(true); > > > > > > XmlRpcClient client = new XmlRpcClient(); > > > client.setConfig(config); > > > > > > Map paramMap = new HashMap(); > > > paramMap.put("login.username", "admin"); > > > paramMap.put("login.password", "ofbiz"); > > > paramMap.put("idToFind", "admin"); > > > ============================================================ > =========== > > > I tried setting the host part of serverUrl to domain_name of > > > tenant_domain_name . > > > > > > I find that the requests always work on the first tenant . > > > i need to work with a specific tenant . > > > > > > Any help is solicited. > > > > > > regds > > > mallah. > > > > > > |
>
> The EventHandler objects are > singletons shared among all incoming requests so we don't want to store > request-specific objects in fields that are accessed by all requests or the > results will get pretty unpredictable for concurrent requests across > multiple tenants. > Agreed and trying to see how the dispatcher and delegator can be got at per request basis. Thanks for the time/attention. regds mallah. On Fri, Mar 16, 2018 at 12:39 AM, Scott Gray <[hidden email]> wrote: > You're completely right Rajesh, sorry, I jumped the gun without having a > proper look in my reply. > > Your fix looks correct except that we need to move dispatcher/delegator to > local variables rather than instance fields. The EventHandler objects are > singletons shared among all incoming requests so we don't want to store > request-specific objects in fields that are accessed by all requests or the > results will get pretty unpredictable for concurrent requests across > multiple tenants. > > Regards > Scott > > > On 16 March 2018 at 07:01, Rajesh Mallah <[hidden email]> wrote: > > > Hi Scott , > > > > I could get it to work by setting dispatcher and delegator only. > > I referred SOAPEventHandler.java which handles tenants fine. > > > > I could not see userLogin handling tenantId as suggested by you, > > can you please see the below and tell if it is correct. > > > > Do we have test coverage to see if does not break anything else? > > > > $ diff -u5 XmlRpcEventHandler.java.orig XmlRpcEventHandler.java > > --- XmlRpcEventHandler.java.orig 2018-03-15 23:29:46.954352066 > +0530 > > +++ XmlRpcEventHandler.java 2018-03-15 23:29:51.734435105 +0530 > > @@ -91,10 +91,12 @@ > > /** > > * @see > > org.apache.ofbiz.webapp.event.EventHandler#invoke(ConfigXMLReader.Event, > > ConfigXMLReader.RequestMap, javax.servlet.http.HttpServletRequest, > > javax.servlet.http.HttpServletResponse) > > */ > > public String invoke(Event event, RequestMap requestMap, > > HttpServletRequest request, HttpServletResponse response) throws > > EventHandlerException { > > String report = request.getParameter("echo"); > > + dispatcher = (LocalDispatcher) request.getAttribute(" > > dispatcher"); > > + delegator = (Delegator) request.getAttribute("delegator"); > > if (report != null) { > > BufferedReader reader = null; > > StringBuilder buf = new StringBuilder(); > > try { > > // read the inputstream buffer > > > > > > > > On Thu, Mar 15, 2018 at 9:51 PM, Scott Gray < > [hidden email]> > > wrote: > > > > > Hi Rajesh, > > > > > > It looks like the XmlRpcEventHandler class doesn't support this but it > > > could easily be modified to do so. I'd suggest filing a ticket, and > > > perhaps even providing a patch :-) > > > > > > The tenantId just needs to be derived from the url and then passed into > > the > > > userLogin service in the OfbizRpcAuthHandler.isAuthorized(...) method. > > > > > > Regards > > > Scott > > > > > > On 16 March 2018 at 00:22, Rajesh Mallah <[hidden email]> > > wrote: > > > > > > > Hello All , > > > > > > > > Is it possible to direct the webservice call to a particular tenant > > using > > > > XMLRPC? > > > > > > > > I am referring to > > > > > > > > > > > > https://cwiki.apache.org/confluence/display/OFBIZ/ > Using+XMLRPC+as+an+ > > > > alternative+to+SOAP > > > > > > > > > > > > consider the snippet > > > > > > > > ======================================================= > > > > XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl(); > > > > config.setServerURL(new URL(" > > > > http://127.0.0.1/webtools/control/xmlrpc" > > > > <http://127.0.0.1/webtools/control/xmlrpc>)); > > > > config.setEnabledForExceptions(true); > > > > config.setEnabledForExtensions(true); > > > > > > > > XmlRpcClient client = new XmlRpcClient(); > > > > client.setConfig(config); > > > > > > > > Map paramMap = new HashMap(); > > > > paramMap.put("login.username", "admin"); > > > > paramMap.put("login.password", "ofbiz"); > > > > paramMap.put("idToFind", "admin"); > > > > ============================================================ > > =========== > > > > I tried setting the host part of serverUrl to domain_name of > > > > tenant_domain_name . > > > > > > > > I find that the requests always work on the first tenant . > > > > i need to work with a specific tenant . > > > > > > > > Any help is solicited. > > > > > > > > regds > > > > mallah. > > > > > > > > > > |
Hi Scott / Gurus! ,
in SOAPEventHandler dispatcher and delegator is being got from HttpServletRequest request. However in XmlRpcHttpServer the request is being eventually handled via a callback (handler) of class ServiceRpcHandler . I am not sure how the HttpServletRequest can be passed till execute function of ServiceRpcHandler any tips ? regds mallah. On Fri, Mar 16, 2018 at 7:33 PM, Rajesh Mallah <[hidden email]> wrote: > The EventHandler objects are >> singletons shared among all incoming requests so we don't want to store >> request-specific objects in fields that are accessed by all requests or >> the >> results will get pretty unpredictable for concurrent requests across >> multiple tenants. >> > > Agreed and trying to see how the dispatcher and delegator can be got > at per request basis. Thanks for the time/attention. > > regds > mallah. > > > > > > > > On Fri, Mar 16, 2018 at 12:39 AM, Scott Gray <[hidden email] > > wrote: > >> You're completely right Rajesh, sorry, I jumped the gun without having a >> proper look in my reply. >> >> Your fix looks correct except that we need to move dispatcher/delegator to >> local variables rather than instance fields. The EventHandler objects are >> singletons shared among all incoming requests so we don't want to store >> request-specific objects in fields that are accessed by all requests or >> the >> results will get pretty unpredictable for concurrent requests across >> multiple tenants. >> >> Regards >> Scott >> >> >> On 16 March 2018 at 07:01, Rajesh Mallah <[hidden email]> wrote: >> >> > Hi Scott , >> > >> > I could get it to work by setting dispatcher and delegator only. >> > I referred SOAPEventHandler.java which handles tenants fine. >> > >> > I could not see userLogin handling tenantId as suggested by you, >> > can you please see the below and tell if it is correct. >> > >> > Do we have test coverage to see if does not break anything else? >> > >> > $ diff -u5 XmlRpcEventHandler.java.orig XmlRpcEventHandler.java >> > --- XmlRpcEventHandler.java.orig 2018-03-15 23:29:46.954352066 >> +0530 >> > +++ XmlRpcEventHandler.java 2018-03-15 23:29:51.734435105 +0530 >> > @@ -91,10 +91,12 @@ >> > /** >> > * @see >> > org.apache.ofbiz.webapp.event.EventHandler#invoke(ConfigXMLR >> eader.Event, >> > ConfigXMLReader.RequestMap, javax.servlet.http.HttpServletRequest, >> > javax.servlet.http.HttpServletResponse) >> > */ >> > public String invoke(Event event, RequestMap requestMap, >> > HttpServletRequest request, HttpServletResponse response) throws >> > EventHandlerException { >> > String report = request.getParameter("echo"); >> > + dispatcher = (LocalDispatcher) request.getAttribute(" >> > dispatcher"); >> > + delegator = (Delegator) request.getAttribute("delegator"); >> > if (report != null) { >> > BufferedReader reader = null; >> > StringBuilder buf = new StringBuilder(); >> > try { >> > // read the inputstream buffer >> > >> > >> > >> > On Thu, Mar 15, 2018 at 9:51 PM, Scott Gray < >> [hidden email]> >> > wrote: >> > >> > > Hi Rajesh, >> > > >> > > It looks like the XmlRpcEventHandler class doesn't support this but it >> > > could easily be modified to do so. I'd suggest filing a ticket, and >> > > perhaps even providing a patch :-) >> > > >> > > The tenantId just needs to be derived from the url and then passed >> into >> > the >> > > userLogin service in the OfbizRpcAuthHandler.isAuthorized(...) >> method. >> > > >> > > Regards >> > > Scott >> > > >> > > On 16 March 2018 at 00:22, Rajesh Mallah <[hidden email]> >> > wrote: >> > > >> > > > Hello All , >> > > > >> > > > Is it possible to direct the webservice call to a particular tenant >> > using >> > > > XMLRPC? >> > > > >> > > > I am referring to >> > > > >> > > > >> > > > https://cwiki.apache.org/confluence/display/OFBIZ/Using+ >> XMLRPC+as+an+ >> > > > alternative+to+SOAP >> > > > >> > > > >> > > > consider the snippet >> > > > >> > > > ======================================================= >> > > > XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl(); >> > > > config.setServerURL(new URL(" >> > > > http://127.0.0.1/webtools/control/xmlrpc" >> > > > <http://127.0.0.1/webtools/control/xmlrpc>)); >> > > > config.setEnabledForExceptions(true); >> > > > config.setEnabledForExtensions(true); >> > > > >> > > > XmlRpcClient client = new XmlRpcClient(); >> > > > client.setConfig(config); >> > > > >> > > > Map paramMap = new HashMap(); >> > > > paramMap.put("login.username", "admin"); >> > > > paramMap.put("login.password", "ofbiz"); >> > > > paramMap.put("idToFind", "admin"); >> > > > ============================================================ >> > =========== >> > > > I tried setting the host part of serverUrl to domain_name of >> > > > tenant_domain_name . >> > > > >> > > > I find that the requests always work on the first tenant . >> > > > i need to work with a specific tenant . >> > > > >> > > > Any help is solicited. >> > > > >> > > > regds >> > > > mallah. >> > > > >> > > >> > >> > > |
References:
SOAPEventHandler.java https://github.com/apache/ofbiz/blob/7ba7f3c2e16df6c8db0d8114e124957199cea1ff/framework/webapp/src/main/java/org/apache/ofbiz/webapp/event/SOAPEventHandler.java#L81 XmlRpcEventHandler.java: https://github.com/apache/ofbiz/blob/7ba7f3c2e16df6c8db0d8114e124957199cea1ff/framework/webapp/src/main/java/org/apache/ofbiz/webapp/event/XmlRpcEventHandler.java#L79 https://github.com/apache/ofbiz/blob/7ba7f3c2e16df6c8db0d8114e124957199cea1ff/framework/webapp/src/main/java/org/apache/ofbiz/webapp/event/XmlRpcEventHandler.java#L232 regds mallah. On Fri, Mar 16, 2018 at 9:11 PM, Rajesh Mallah <[hidden email]> wrote: > Hi Scott / Gurus! , > > in SOAPEventHandler dispatcher and delegator is being got > from HttpServletRequest request. > > However in XmlRpcHttpServer the request is being > eventually handled via a callback (handler) of class > ServiceRpcHandler . I am not sure how the HttpServletRequest > can be passed till execute function of ServiceRpcHandler > > any tips ? > > regds > mallah. > > > > On Fri, Mar 16, 2018 at 7:33 PM, Rajesh Mallah <[hidden email]> > wrote: > >> The EventHandler objects are >>> singletons shared among all incoming requests so we don't want to store >>> request-specific objects in fields that are accessed by all requests or >>> the >>> results will get pretty unpredictable for concurrent requests across >>> multiple tenants. >>> >> >> Agreed and trying to see how the dispatcher and delegator can be got >> at per request basis. Thanks for the time/attention. >> >> regds >> mallah. >> >> >> >> >> >> >> >> On Fri, Mar 16, 2018 at 12:39 AM, Scott Gray < >> [hidden email]> wrote: >> >>> You're completely right Rajesh, sorry, I jumped the gun without having a >>> proper look in my reply. >>> >>> Your fix looks correct except that we need to move dispatcher/delegator >>> to >>> local variables rather than instance fields. The EventHandler objects >>> are >>> singletons shared among all incoming requests so we don't want to store >>> request-specific objects in fields that are accessed by all requests or >>> the >>> results will get pretty unpredictable for concurrent requests across >>> multiple tenants. >>> >>> Regards >>> Scott >>> >>> >>> On 16 March 2018 at 07:01, Rajesh Mallah <[hidden email]> >>> wrote: >>> >>> > Hi Scott , >>> > >>> > I could get it to work by setting dispatcher and delegator only. >>> > I referred SOAPEventHandler.java which handles tenants fine. >>> > >>> > I could not see userLogin handling tenantId as suggested by you, >>> > can you please see the below and tell if it is correct. >>> > >>> > Do we have test coverage to see if does not break anything else? >>> > >>> > $ diff -u5 XmlRpcEventHandler.java.orig XmlRpcEventHandler.java >>> > --- XmlRpcEventHandler.java.orig 2018-03-15 23:29:46.954352066 >>> +0530 >>> > +++ XmlRpcEventHandler.java 2018-03-15 23:29:51.734435105 +0530 >>> > @@ -91,10 +91,12 @@ >>> > /** >>> > * @see >>> > org.apache.ofbiz.webapp.event.EventHandler#invoke(ConfigXMLR >>> eader.Event, >>> > ConfigXMLReader.RequestMap, javax.servlet.http.HttpServletRequest, >>> > javax.servlet.http.HttpServletResponse) >>> > */ >>> > public String invoke(Event event, RequestMap requestMap, >>> > HttpServletRequest request, HttpServletResponse response) throws >>> > EventHandlerException { >>> > String report = request.getParameter("echo"); >>> > + dispatcher = (LocalDispatcher) request.getAttribute(" >>> > dispatcher"); >>> > + delegator = (Delegator) request.getAttribute("delegator"); >>> > if (report != null) { >>> > BufferedReader reader = null; >>> > StringBuilder buf = new StringBuilder(); >>> > try { >>> > // read the inputstream buffer >>> > >>> > >>> > >>> > On Thu, Mar 15, 2018 at 9:51 PM, Scott Gray < >>> [hidden email]> >>> > wrote: >>> > >>> > > Hi Rajesh, >>> > > >>> > > It looks like the XmlRpcEventHandler class doesn't support this but >>> it >>> > > could easily be modified to do so. I'd suggest filing a ticket, and >>> > > perhaps even providing a patch :-) >>> > > >>> > > The tenantId just needs to be derived from the url and then passed >>> into >>> > the >>> > > userLogin service in the OfbizRpcAuthHandler.isAuthorized(...) >>> method. >>> > > >>> > > Regards >>> > > Scott >>> > > >>> > > On 16 March 2018 at 00:22, Rajesh Mallah <[hidden email]> >>> > wrote: >>> > > >>> > > > Hello All , >>> > > > >>> > > > Is it possible to direct the webservice call to a particular tenant >>> > using >>> > > > XMLRPC? >>> > > > >>> > > > I am referring to >>> > > > >>> > > > >>> > > > https://cwiki.apache.org/confluence/display/OFBIZ/Using+XMLR >>> PC+as+an+ >>> > > > alternative+to+SOAP >>> > > > >>> > > > >>> > > > consider the snippet >>> > > > >>> > > > ======================================================= >>> > > > XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl(); >>> > > > config.setServerURL(new URL(" >>> > > > http://127.0.0.1/webtools/control/xmlrpc" >>> > > > <http://127.0.0.1/webtools/control/xmlrpc>)); >>> > > > config.setEnabledForExceptions(true); >>> > > > config.setEnabledForExtensions(true); >>> > > > >>> > > > XmlRpcClient client = new XmlRpcClient(); >>> > > > client.setConfig(config); >>> > > > >>> > > > Map paramMap = new HashMap(); >>> > > > paramMap.put("login.username", "admin"); >>> > > > paramMap.put("login.password", "ofbiz"); >>> > > > paramMap.put("idToFind", "admin"); >>> > > > ============================================================ >>> > =========== >>> > > > I tried setting the host part of serverUrl to domain_name of >>> > > > tenant_domain_name . >>> > > > >>> > > > I find that the requests always work on the first tenant . >>> > > > i need to work with a specific tenant . >>> > > > >>> > > > Any help is solicited. >>> > > > >>> > > > regds >>> > > > mallah. >>> > > > >>> > > >>> > >>> >> >> > |
oops dunno how it's garbled. posting again:
https://github.com/apache/ofbiz/blob/7ba7f3c2e16df6c8db0d8114e124957199cea1ff/framework/webapp/src/main/java/org/apache/ofbiz/webapp/event/SOAPEventHandler.java#L81 https://github.com/apache/ofbiz/blob/7ba7f3c2e16df6c8db0d8114e124957199cea1ff/framework/webapp/src/main/java/org/apache/ofbiz/webapp/event/XmlRpcEventHandler.java#L79 https://github.com/apache/ofbiz/blob/7ba7f3c2e16df6c8db0d8114e124957199cea1ff/framework/webapp/src/main/java/org/apache/ofbiz/webapp/event/XmlRpcEventHandler.java#L232 On Fri, Mar 16, 2018 at 9:27 PM, Rajesh Mallah <[hidden email]> wrote: > References: > > > > > SOAPEventHandler.java > > > > https://github.com/apache/ofbiz/blob/7ba7f3c2e16df6c8db0d8114e12495 > 7199cea1ff/framework/webapp/src/main/java/org/apache/ofbiz/webapp/event/ > SOAPEventHandler.java#L81 > > > > > > > > > > > XmlRpcEventHandler.java: > > https://github.com/apache/ofbiz/blob/7ba7f3c2e16df6c8db0d8114e124957199cea1ff/framework/webapp/src/main/java/org/apache/ofbiz/webapp/event/XmlRpcEventHandler.java#L79 > > https://github.com/apache/ofbiz/blob/7ba7f3c2e16df6c8db0d8114e124957199cea1ff/framework/webapp/src/main/java/org/apache/ofbiz/webapp/event/XmlRpcEventHandler.java#L232 > > > regds > mallah. > > On Fri, Mar 16, 2018 at 9:11 PM, Rajesh Mallah <[hidden email]> > wrote: > >> Hi Scott / Gurus! , >> >> in SOAPEventHandler dispatcher and delegator is being got >> from HttpServletRequest request. >> >> However in XmlRpcHttpServer the request is being >> eventually handled via a callback (handler) of class >> ServiceRpcHandler . I am not sure how the HttpServletRequest >> can be passed till execute function of ServiceRpcHandler >> >> any tips ? >> >> regds >> mallah. >> >> >> >> On Fri, Mar 16, 2018 at 7:33 PM, Rajesh Mallah <[hidden email]> >> wrote: >> >>> The EventHandler objects are >>>> singletons shared among all incoming requests so we don't want to store >>>> request-specific objects in fields that are accessed by all requests or >>>> the >>>> results will get pretty unpredictable for concurrent requests across >>>> multiple tenants. >>>> >>> >>> Agreed and trying to see how the dispatcher and delegator can be got >>> at per request basis. Thanks for the time/attention. >>> >>> regds >>> mallah. >>> >>> >>> >>> >>> >>> >>> >>> On Fri, Mar 16, 2018 at 12:39 AM, Scott Gray < >>> [hidden email]> wrote: >>> >>>> You're completely right Rajesh, sorry, I jumped the gun without having a >>>> proper look in my reply. >>>> >>>> Your fix looks correct except that we need to move dispatcher/delegator >>>> to >>>> local variables rather than instance fields. The EventHandler objects >>>> are >>>> singletons shared among all incoming requests so we don't want to store >>>> request-specific objects in fields that are accessed by all requests or >>>> the >>>> results will get pretty unpredictable for concurrent requests across >>>> multiple tenants. >>>> >>>> Regards >>>> Scott >>>> >>>> >>>> On 16 March 2018 at 07:01, Rajesh Mallah <[hidden email]> >>>> wrote: >>>> >>>> > Hi Scott , >>>> > >>>> > I could get it to work by setting dispatcher and delegator only. >>>> > I referred SOAPEventHandler.java which handles tenants fine. >>>> > >>>> > I could not see userLogin handling tenantId as suggested by you, >>>> > can you please see the below and tell if it is correct. >>>> > >>>> > Do we have test coverage to see if does not break anything else? >>>> > >>>> > $ diff -u5 XmlRpcEventHandler.java.orig XmlRpcEventHandler.java >>>> > --- XmlRpcEventHandler.java.orig 2018-03-15 23:29:46.954352066 >>>> +0530 >>>> > +++ XmlRpcEventHandler.java 2018-03-15 23:29:51.734435105 +0530 >>>> > @@ -91,10 +91,12 @@ >>>> > /** >>>> > * @see >>>> > org.apache.ofbiz.webapp.event.EventHandler#invoke(ConfigXMLR >>>> eader.Event, >>>> > ConfigXMLReader.RequestMap, javax.servlet.http.HttpServletRequest, >>>> > javax.servlet.http.HttpServletResponse) >>>> > */ >>>> > public String invoke(Event event, RequestMap requestMap, >>>> > HttpServletRequest request, HttpServletResponse response) throws >>>> > EventHandlerException { >>>> > String report = request.getParameter("echo"); >>>> > + dispatcher = (LocalDispatcher) request.getAttribute(" >>>> > dispatcher"); >>>> > + delegator = (Delegator) request.getAttribute("delegator"); >>>> > if (report != null) { >>>> > BufferedReader reader = null; >>>> > StringBuilder buf = new StringBuilder(); >>>> > try { >>>> > // read the inputstream buffer >>>> > >>>> > >>>> > >>>> > On Thu, Mar 15, 2018 at 9:51 PM, Scott Gray < >>>> [hidden email]> >>>> > wrote: >>>> > >>>> > > Hi Rajesh, >>>> > > >>>> > > It looks like the XmlRpcEventHandler class doesn't support this but >>>> it >>>> > > could easily be modified to do so. I'd suggest filing a ticket, and >>>> > > perhaps even providing a patch :-) >>>> > > >>>> > > The tenantId just needs to be derived from the url and then passed >>>> into >>>> > the >>>> > > userLogin service in the OfbizRpcAuthHandler.isAuthorized(...) >>>> method. >>>> > > >>>> > > Regards >>>> > > Scott >>>> > > >>>> > > On 16 March 2018 at 00:22, Rajesh Mallah <[hidden email]> >>>> > wrote: >>>> > > >>>> > > > Hello All , >>>> > > > >>>> > > > Is it possible to direct the webservice call to a particular >>>> tenant >>>> > using >>>> > > > XMLRPC? >>>> > > > >>>> > > > I am referring to >>>> > > > >>>> > > > >>>> > > > https://cwiki.apache.org/confluence/display/OFBIZ/Using+XMLR >>>> PC+as+an+ >>>> > > > alternative+to+SOAP >>>> > > > >>>> > > > >>>> > > > consider the snippet >>>> > > > >>>> > > > ======================================================= >>>> > > > XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl(); >>>> > > > config.setServerURL(new URL(" >>>> > > > http://127.0.0.1/webtools/control/xmlrpc" >>>> > > > <http://127.0.0.1/webtools/control/xmlrpc>)); >>>> > > > config.setEnabledForExceptions(true); >>>> > > > config.setEnabledForExtensions(true); >>>> > > > >>>> > > > XmlRpcClient client = new XmlRpcClient(); >>>> > > > client.setConfig(config); >>>> > > > >>>> > > > Map paramMap = new HashMap(); >>>> > > > paramMap.put("login.username", "admin"); >>>> > > > paramMap.put("login.password", "ofbiz"); >>>> > > > paramMap.put("idToFind", "admin"); >>>> > > > ============================================================ >>>> > =========== >>>> > > > I tried setting the host part of serverUrl to domain_name of >>>> > > > tenant_domain_name . >>>> > > > >>>> > > > I find that the requests always work on the first tenant . >>>> > > > i need to work with a specific tenant . >>>> > > > >>>> > > > Any help is solicited. >>>> > > > >>>> > > > regds >>>> > > > mallah. >>>> > > > >>>> > > >>>> > >>>> >>> >>> >> > |
In reply to this post by Rajesh Mallah
Hi ,
I was giving this problem another shot but need help. The original problem is that , it is not possible to direct XML / RPC requests to specific tenants in a multi-tenant environment. This problem is significant as it forces us to have multiple instances of ofbiz running which are not utilized to fullest extent. The exact problem i am facing is that i need to get 'HttpServletRequest' object inside the handler that implements XmlRpcHandler. This is to create "local" copies of dispatcher and delegator on per - request basis as Scott suggested not to use the class level variables of the singleton due to concurrency concerns. pls refer: framework/webapp/src/main/java/org/apache/ofbiz/webapp/event/XmlRpcEventHandler.java if we are able to get HttpServletRequest inside the handler we could get the delegator and dispatcher as: ===================== dispatcher = (LocalDispatcher) request.getAttribute("dispatcher"); delegator = (Delegator) request.getAttribute("delegator"); ===================== A JIRA for the same was already filed: >> https://issues.apache.org/jira/browse/OFBIZ-10284 Someone else had also faced a similar situation here: https://coderanch.com/t/415677/java/remote-IP-Address-JAX-RPC Any suggestions is humbly solicited. regds mallah. |
Hello Everyone / Mr Scott , I have been able to churn out a patch finally. The request level dispatcher is being stored in a member variable of a class derived from XmlRpcHttpRequestConfigImpl . in the execute method of ServiceRpcHandler the dispatcher is being extracted from the config. This has been tested in a simulated concurrent scenario that was previously failing to provide correct results unless dispatcher was localized at request level. Kindly have a look at the attached patch. regds mallah On Tue, Aug 7, 2018 at 11:08 AM, Rajesh Mallah <[hidden email]> wrote:
XmlRpcEventHandler.java.patch (10K) Download Attachment |
Hi Rajesh,
We usually implement our work using JIRA [1]. So I recommend you apply your patch against the latest version of trunk over there and then ask for it to be committed. [1] https://issues.apache.org/jira/browse/OFBIZ On Tue, Aug 7, 2018 at 10:06 PM, Rajesh Mallah <[hidden email]> wrote: > > Hello Everyone / Mr Scott , > > I have been able to churn out a patch finally. > > The request level dispatcher is being stored in a member variable of > a class derived from XmlRpcHttpRequestConfigImpl . > > in the execute method of ServiceRpcHandler the dispatcher is being > extracted from the config. > > This has been tested in a simulated concurrent scenario that was > previously failing to provide correct results unless dispatcher was > localized at request level. > > Kindly have a look at the attached patch. > > regds > mallah > > > On Tue, Aug 7, 2018 at 11:08 AM, Rajesh Mallah <[hidden email]> > wrote: >> >> >> Hi , >> >> I was giving this problem another shot but need help. >> >> >> The original problem is that , it is not possible to direct >> XML / RPC requests to specific tenants in a multi-tenant >> environment. This problem is significant as it forces us to have >> multiple instances of ofbiz running which are not utilized to fullest >> extent. >> >> >> The exact problem i am facing is that i need to get 'HttpServletRequest' >> object inside the handler that implements XmlRpcHandler. This is to >> create "local" copies of dispatcher and delegator on per - request basis >> as Scott suggested not to use the class level variables of the singleton >> due to concurrency concerns. >> >> pls refer: >> framework/webapp/src/main/java/org/apache/ofbiz/webapp/event/XmlRpcEventHandler.java >> >> if we are able to get HttpServletRequest inside the handler >> we could get the delegator and dispatcher as: >> >> ===================== >> dispatcher = (LocalDispatcher) request.getAttribute("dispatcher"); >> delegator = (Delegator) request.getAttribute("delegator"); >> >> ===================== >> >> A JIRA for the same was already filed: >> >> >> https://issues.apache.org/jira/browse/OFBIZ-10284 >> >> Someone else had also faced a similar situation here: >> >> https://coderanch.com/t/415677/java/remote-IP-Address-JAX-RPC >> >> >> Any suggestions is humbly solicited. >> >> regds >> mallah. >> >> >> >> >> > |
Thanks Taher.
regds mallah. On Thu, Aug 9, 2018 at 3:30 PM, Taher Alkhateeb <[hidden email]> wrote: > Hi Rajesh, > > We usually implement our work using JIRA [1]. So I recommend you apply > your patch against the latest version of trunk over there and then ask > for it to be committed. > > [1] https://issues.apache.org/jira/browse/OFBIZ > > On Tue, Aug 7, 2018 at 10:06 PM, Rajesh Mallah <[hidden email]> > wrote: > > > > Hello Everyone / Mr Scott , > > > > I have been able to churn out a patch finally. > > > > The request level dispatcher is being stored in a member variable of > > a class derived from XmlRpcHttpRequestConfigImpl . > > > > in the execute method of ServiceRpcHandler the dispatcher is being > > extracted from the config. > > > > This has been tested in a simulated concurrent scenario that was > > previously failing to provide correct results unless dispatcher was > > localized at request level. > > > > Kindly have a look at the attached patch. > > > > regds > > mallah > > > > > > On Tue, Aug 7, 2018 at 11:08 AM, Rajesh Mallah <[hidden email]> > > wrote: > >> > >> > >> Hi , > >> > >> I was giving this problem another shot but need help. > >> > >> > >> The original problem is that , it is not possible to direct > >> XML / RPC requests to specific tenants in a multi-tenant > >> environment. This problem is significant as it forces us to have > >> multiple instances of ofbiz running which are not utilized to fullest > >> extent. > >> > >> > >> The exact problem i am facing is that i need to get 'HttpServletRequest' > >> object inside the handler that implements XmlRpcHandler. This is to > >> create "local" copies of dispatcher and delegator on per - request basis > >> as Scott suggested not to use the class level variables of the singleton > >> due to concurrency concerns. > >> > >> pls refer: > >> framework/webapp/src/main/java/org/apache/ofbiz/webapp/ > event/XmlRpcEventHandler.java > >> > >> if we are able to get HttpServletRequest inside the handler > >> we could get the delegator and dispatcher as: > >> > >> ===================== > >> dispatcher = (LocalDispatcher) request.getAttribute("dispatcher"); > >> delegator = (Delegator) request.getAttribute("delegator"); > >> > >> ===================== > >> > >> A JIRA for the same was already filed: > >> > >> >> https://issues.apache.org/jira/browse/OFBIZ-10284 > >> > >> Someone else had also faced a similar situation here: > >> > >> https://coderanch.com/t/415677/java/remote-IP-Address-JAX-RPC > >> > >> > >> Any suggestions is humbly solicited. > >> > >> regds > >> mallah. > >> > >> > >> > >> > >> > > > |
Free forum by Nabble | Edit this page |