How to pass org.apache.ofbiz.entity.GenericValue using XMLRPC ?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

How to pass org.apache.ofbiz.entity.GenericValue using XMLRPC ?

Rajesh Mallah
 Hi ,

I had been using XMLRPC regularly for invoking OFBiz functions and getting
results.
However with below function calculateProductPrice I am facing problem in
passing the
"product" param . I am getting the error below:

Service: calculateProductPrice faultString:Type check failed for field
[calculateProductPrice.product]; expected type is
[org.apache.ofbiz.entity.GenericValue]; actual type is [java.util.HashMap]

my question is how/what do i send using XMLRPC so that the casting of
"GenericValue" works.


regds
mallah.


================> Defination of function calculateProductPrice
<=============================================
public static Map<String, Object> calculateProductPrice(DispatchContext
dctx, Map<String, ? extends Object> context) {
        Delegator delegator = dctx.getDelegator();
        LocalDispatcher dispatcher = dctx.getDispatcher();
        Map<String, Object> result = new HashMap<String, Object>();
        Timestamp nowTimestamp = UtilDateTime.nowTimestamp();

        GenericValue product = (GenericValue) context.get("product");
        String productId = product.getString("productId");
        String prodCatalogId = (String) context.get("prodCatalogId");
        String webSiteId = (String) context.get("webSiteId");
        String checkIncludeVat = (String) context.get("checkIncludeVat");
        String surveyResponseId = (String) context.get("surveyResponseId");
        Map<String, Object> customAttributes =
UtilGenerics.checkMap(context.get("customAttributes"));

        String findAllQuantityPricesStr = (String)
context.get("findAllQuantityPrices");
        boolean findAllQuantityPrices =
"Y".equals(findAllQuantityPricesStr);
        boolean optimizeForLargeRuleSet =
"Y".equals(context.get("optimizeForLargeRuleSet"));

        String agreementId = (String) context.get("agreementId");

        String productStoreId = (String) context.get("productStoreId");
        String productStoreGroupId = (String)
context.get("productStoreGroupId");
        Locale locale = (Locale) context.get("locale");

        GenericValue productStore = null;
Reply | Threaded
Open this post in threaded view
|

Re: How to pass org.apache.ofbiz.entity.GenericValue using XMLRPC ?

Rajesh Mallah
As per

https://cwiki.apache.org/confluence/display/OFBIZ/Using+XMLRPC+with+Flex+client

In OFBiz the limitations are simple types. GenericValue object will
> convert to Maps and be supported as Structs in XMLRPC, besides that
> you should limit your parameters to simple types (string, double,
> integer, map, list, etc). There is a xmlrpc event in webtools
> (controller.xml) which allows you to call any service which has
> export="true" specified.
>


i think the above para is commenting about the output/response formatting.
the concern is that XMLRPC  supports types as mentioned in

https://ws.apache.org/xmlrpc/types.html

which covers only the basic types , i guess there is nothing in
xmlrpc that can directly convert to genericvalue that OFBiz is
expecting . I guess we need a procedure to convert incoming
map (or nested maps) to OFBiz genericvalue.

regds
mallah.











On Fri, Mar 23, 2018 at 1:10 AM, Rajesh Mallah <[hidden email]>
wrote:

>  Hi ,
>
> I had been using XMLRPC regularly for invoking OFBiz functions and getting
> results.
> However with below function calculateProductPrice I am facing problem in
> passing the
> "product" param . I am getting the error below:
>
> Service: calculateProductPrice faultString:Type check failed for field
> [calculateProductPrice.product]; expected type is
> [org.apache.ofbiz.entity.GenericValue]; actual type is [java.util.HashMap]
>
> my question is how/what do i send using XMLRPC so that the casting of
> "GenericValue" works.
>
>
> regds
> mallah.
>
>
> ================> Defination of function calculateProductPrice
> <=============================================
> public static Map<String, Object> calculateProductPrice(DispatchContext
> dctx, Map<String, ? extends Object> context) {
>         Delegator delegator = dctx.getDelegator();
>         LocalDispatcher dispatcher = dctx.getDispatcher();
>         Map<String, Object> result = new HashMap<String, Object>();
>         Timestamp nowTimestamp = UtilDateTime.nowTimestamp();
>
>         GenericValue product = (GenericValue) context.get("product");
>         String productId = product.getString("productId");
>         String prodCatalogId = (String) context.get("prodCatalogId");
>         String webSiteId = (String) context.get("webSiteId");
>         String checkIncludeVat = (String) context.get("checkIncludeVat");
>         String surveyResponseId = (String) context.get("surveyResponseId"
> );
>         Map<String, Object> customAttributes =
> UtilGenerics.checkMap(context.get("customAttributes"));
>
>         String findAllQuantityPricesStr = (String) context.get("
> findAllQuantityPrices");
>         boolean findAllQuantityPrices = "Y".equals(
> findAllQuantityPricesStr);
>         boolean optimizeForLargeRuleSet = "Y".equals(context.get("
> optimizeForLargeRuleSet"));
>
>         String agreementId = (String) context.get("agreementId");
>
>         String productStoreId = (String) context.get("productStoreId");
>         String productStoreGroupId = (String) context.get("
> productStoreGroupId");
>         Locale locale = (Locale) context.get("locale");
>
>         GenericValue productStore = null;
>
>
Reply | Threaded
Open this post in threaded view
|

Re: How to pass org.apache.ofbiz.entity.GenericValue using XMLRPC ?

Jacques Le Roux
Administrator
Le 23/03/2018 à 05:00, Rajesh Mallah a écrit :
> I guess we need a procedure to convert incoming
> map (or nested maps) to OFBiz genericvalue.
That's SOAP ;)

Jacques

Reply | Threaded
Open this post in threaded view
|

Re: How to pass org.apache.ofbiz.entity.GenericValue using XMLRPC ?

Rajesh Mallah
Hi Jacques ,
Thanks for the reply .

I have almost hit the wall with this current issue :-(

Do you mean to say it may work if i use SOAP ?


regds
mallah.


On Fri, Mar 23, 2018 at 2:13 PM, Jacques Le Roux <
[hidden email]> wrote:

> Le 23/03/2018 à 05:00, Rajesh Mallah a écrit :
>
>> I guess we need a procedure to convert incoming
>> map (or nested maps) to OFBiz genericvalue.
>>
> That's SOAP ;)
>
> Jacques
>
>
Reply | Threaded
Open this post in threaded view
|

Re: How to pass org.apache.ofbiz.entity.GenericValue using XMLRPC ?

taher
Hi Rajesh,

Actually If I were you I would avoid SOAP. Maybe that is too complex
and an overkill for your problem. I never liked soap for anything
other than washing hands anyway :)

I also think there might be multiple issues with the whole design of
this service, why pass a generic value in the first place!

So anyway, what is a quick solution for you? Well, a very quick one
for example could be to create a new service that takes all the
arguments that "calculateProductPrice" takes but the product is a Map.
Then, you simply convert the Map to a GenericValue, and then pass
everything to "calculateProductPrice"

The better solution IMO, is to completely refactor this service,
because DAMN, 485 lines of code! It hurts my eyes just to look at that
jumble of code

On Fri, Mar 23, 2018 at 11:54 AM, Rajesh Mallah <[hidden email]> wrote:

> Hi Jacques ,
> Thanks for the reply .
>
> I have almost hit the wall with this current issue :-(
>
> Do you mean to say it may work if i use SOAP ?
>
>
> regds
> mallah.
>
>
> On Fri, Mar 23, 2018 at 2:13 PM, Jacques Le Roux <
> [hidden email]> wrote:
>
>> Le 23/03/2018 à 05:00, Rajesh Mallah a écrit :
>>
>>> I guess we need a procedure to convert incoming
>>> map (or nested maps) to OFBiz genericvalue.
>>>
>> That's SOAP ;)
>>
>> Jacques
>>
>>
Reply | Threaded
Open this post in threaded view
|

Re: How to pass org.apache.ofbiz.entity.GenericValue using XMLRPC ?

Rajesh Mallah
Hi Taher ,

Thanks for the attention.

Its not just a matter of one service. I dunno when again i would
face the same with a different service. A glance over the service
references suggest that there is use of GenericValue all over the
places.


I don't mind using SOAP it gets me out of this soup ;-)
I know XMLRPC is lightweight and faster.


regds
mallah.














On Fri, Mar 23, 2018 at 2:40 PM, Taher Alkhateeb <[hidden email]
> wrote:

> Hi Rajesh,
>
> Actually If I were you I would avoid SOAP. Maybe that is too complex
> and an overkill for your problem. I never liked soap for anything
> other than washing hands anyway :)
>
> I also think there might be multiple issues with the whole design of
> this service, why pass a generic value in the first place!
>
> So anyway, what is a quick solution for you? Well, a very quick one
> for example could be to create a new service that takes all the
> arguments that "calculateProductPrice" takes but the product is a Map.
> Then, you simply convert the Map to a GenericValue, and then pass
> everything to "calculateProductPrice"
>
> The better solution IMO, is to completely refactor this service,
> because DAMN, 485 lines of code! It hurts my eyes just to look at that
> jumble of code
>
> On Fri, Mar 23, 2018 at 11:54 AM, Rajesh Mallah <[hidden email]>
> wrote:
> > Hi Jacques ,
> > Thanks for the reply .
> >
> > I have almost hit the wall with this current issue :-(
> >
> > Do you mean to say it may work if i use SOAP ?
> >
> >
> > regds
> > mallah.
> >
> >
> > On Fri, Mar 23, 2018 at 2:13 PM, Jacques Le Roux <
> > [hidden email]> wrote:
> >
> >> Le 23/03/2018 à 05:00, Rajesh Mallah a écrit :
> >>
> >>> I guess we need a procedure to convert incoming
> >>> map (or nested maps) to OFBiz genericvalue.
> >>>
> >> That's SOAP ;)
> >>
> >> Jacques
> >>
> >>
>
Reply | Threaded
Open this post in threaded view
|

Re: How to pass org.apache.ofbiz.entity.GenericValue using XMLRPC ?

taher
Yeah well .. you know .. I'm not quite convinced of passing specific
objects to services. It should be either values or generic data
structures (maps, lists, etc ...)

Did you construct your GenericValue as a struct? Do you mind sharing
the code to take a closer look? Also, wouldn't this be more
appropriate in user@?

On Fri, Mar 23, 2018 at 12:24 PM, Rajesh Mallah <[hidden email]> wrote:

> Hi Taher ,
>
> Thanks for the attention.
>
> Its not just a matter of one service. I dunno when again i would
> face the same with a different service. A glance over the service
> references suggest that there is use of GenericValue all over the
> places.
>
>
> I don't mind using SOAP it gets me out of this soup ;-)
> I know XMLRPC is lightweight and faster.
>
>
> regds
> mallah.
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> On Fri, Mar 23, 2018 at 2:40 PM, Taher Alkhateeb <[hidden email]
>> wrote:
>
>> Hi Rajesh,
>>
>> Actually If I were you I would avoid SOAP. Maybe that is too complex
>> and an overkill for your problem. I never liked soap for anything
>> other than washing hands anyway :)
>>
>> I also think there might be multiple issues with the whole design of
>> this service, why pass a generic value in the first place!
>>
>> So anyway, what is a quick solution for you? Well, a very quick one
>> for example could be to create a new service that takes all the
>> arguments that "calculateProductPrice" takes but the product is a Map.
>> Then, you simply convert the Map to a GenericValue, and then pass
>> everything to "calculateProductPrice"
>>
>> The better solution IMO, is to completely refactor this service,
>> because DAMN, 485 lines of code! It hurts my eyes just to look at that
>> jumble of code
>>
>> On Fri, Mar 23, 2018 at 11:54 AM, Rajesh Mallah <[hidden email]>
>> wrote:
>> > Hi Jacques ,
>> > Thanks for the reply .
>> >
>> > I have almost hit the wall with this current issue :-(
>> >
>> > Do you mean to say it may work if i use SOAP ?
>> >
>> >
>> > regds
>> > mallah.
>> >
>> >
>> > On Fri, Mar 23, 2018 at 2:13 PM, Jacques Le Roux <
>> > [hidden email]> wrote:
>> >
>> >> Le 23/03/2018 à 05:00, Rajesh Mallah a écrit :
>> >>
>> >>> I guess we need a procedure to convert incoming
>> >>> map (or nested maps) to OFBiz genericvalue.
>> >>>
>> >> That's SOAP ;)
>> >>
>> >> Jacques
>> >>
>> >>
>>
Reply | Threaded
Open this post in threaded view
|

Re: How to pass org.apache.ofbiz.entity.GenericValue using XMLRPC ?

Rajesh Mallah
>
> Yeah well .. you know .. I'm not quite convinced of passing specific
> objects to services. It should be either values or generic data
> structures (maps, lists, etc ...)
>

Agreed here as it makes things more inter operable.


>
> Did you construct your GenericValue as a struct? Do you mind sharing
> the code to take a closer look?


Yes the GenericValue was constructed as struct which gets maped to java Map
in OFBiz end.

Yes i would share a minimal snippet that manifests  the issue along with the
transport level exchanges.



> Also, wouldn't this be more
> appropriate in user@?
>
i would shift it to user@  , in next transaction.

regds
mallah.



On Fri, Mar 23, 2018 at 3:06 PM, Taher Alkhateeb <[hidden email]
> wrote:

> Yeah well .. you know .. I'm not quite convinced of passing specific
> objects to services. It should be either values or generic data
> structures (maps, lists, etc ...)
>
> Did you construct your GenericValue as a struct? Do you mind sharing
> the code to take a closer look? Also, wouldn't this be more
> appropriate in user@?
>
> On Fri, Mar 23, 2018 at 12:24 PM, Rajesh Mallah <[hidden email]>
> wrote:
> > Hi Taher ,
> >
> > Thanks for the attention.
> >
> > Its not just a matter of one service. I dunno when again i would
> > face the same with a different service. A glance over the service
> > references suggest that there is use of GenericValue all over the
> > places.
> >
> >
> > I don't mind using SOAP it gets me out of this soup ;-)
> > I know XMLRPC is lightweight and faster.
> >
> >
> > regds
> > mallah.
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > On Fri, Mar 23, 2018 at 2:40 PM, Taher Alkhateeb <
> [hidden email]
> >> wrote:
> >
> >> Hi Rajesh,
> >>
> >> Actually If I were you I would avoid SOAP. Maybe that is too complex
> >> and an overkill for your problem. I never liked soap for anything
> >> other than washing hands anyway :)
> >>
> >> I also think there might be multiple issues with the whole design of
> >> this service, why pass a generic value in the first place!
> >>
> >> So anyway, what is a quick solution for you? Well, a very quick one
> >> for example could be to create a new service that takes all the
> >> arguments that "calculateProductPrice" takes but the product is a Map.
> >> Then, you simply convert the Map to a GenericValue, and then pass
> >> everything to "calculateProductPrice"
> >>
> >> The better solution IMO, is to completely refactor this service,
> >> because DAMN, 485 lines of code! It hurts my eyes just to look at that
> >> jumble of code
> >>
> >> On Fri, Mar 23, 2018 at 11:54 AM, Rajesh Mallah <
> [hidden email]>
> >> wrote:
> >> > Hi Jacques ,
> >> > Thanks for the reply .
> >> >
> >> > I have almost hit the wall with this current issue :-(
> >> >
> >> > Do you mean to say it may work if i use SOAP ?
> >> >
> >> >
> >> > regds
> >> > mallah.
> >> >
> >> >
> >> > On Fri, Mar 23, 2018 at 2:13 PM, Jacques Le Roux <
> >> > [hidden email]> wrote:
> >> >
> >> >> Le 23/03/2018 à 05:00, Rajesh Mallah a écrit :
> >> >>
> >> >>> I guess we need a procedure to convert incoming
> >> >>> map (or nested maps) to OFBiz genericvalue.
> >> >>>
> >> >> That's SOAP ;)
> >> >>
> >> >> Jacques
> >> >>
> >> >>
> >>
>