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 <[email protected]>
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 <[email protected]>
> 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 <
>> [email protected]> 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 <[email protected]>
>>> 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 <
>>> [email protected]>
>>> > 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 <[email protected]>
>>> > 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.
>>> > > >
>>> > >
>>> >
>>>
>>
>>
>

Reply via email to