You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ofbiz.apache.org by "Taher Alkhateeb (JIRA)" <ji...@apache.org> on 2018/06/12 17:07:00 UTC

[jira] [Comment Edited] (OFBIZ-10317) Allowing XML-RPC and SOAP to pass GenericValue objects to services as IN fields

    [ https://issues.apache.org/jira/browse/OFBIZ-10317?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16509887#comment-16509887 ] 

Taher Alkhateeb edited comment on OFBIZ-10317 at 6/12/18 5:06 PM:
------------------------------------------------------------------

Okay after thoroughly investigating this issue, I realized that the first step to attempt is to create a converter from a Map to GenericValue.

So I went ahead and implemented the code, the important part of which is listed below:
{code:java}
    public static class MapToGenericValue extends AbstractConverter<Map<String, Object>, GenericValue> {
        public MapToGenericValue() {
            super(Map.class, GenericValue.class);
        }

        public GenericValue convert(Map<String, Object> obj) throws ConversionException {
            GenericValue genericValue = new GenericValue();
            genericValue.putAll(UtilGenerics.checkMap(obj));
            return genericValue;
        }
    }{code}
The problem here of course is that the generic value is not linked to a ModelEntity. Why? Because we don't know what is the entity. We just received some data, we did not receive an actual Object. So if you run my above code, you will get an error:
{code:java}
java.lang.IllegalStateException: [GenericEntity.getModelEntity] could not find modelEntity for entityName null
{code}
So to convert XML-RPC data to a Java Object, we _must_ know what is the entity name (at the very least). In our example, the entity name is "Product" whereas the service parameter name is "product" which is not the same.

So, unless you have an idea for how to get the entity information for all existing services that take a GenericValue, I think this issue cannot be implemented successfully


was (Author: taher):
Okay after thoroughly investigating this issue, I realized that the first step to attempt is to create a converter from a Map to GenericValue.

So I went ahead and implemented the code, the important part of which is listed below:
{code:java}
public static class MapToGenericValue extends AbstractConverter<Map<String, Object>, GenericValue> {
        public MapToGenericValue() {
            super(Map.class, GenericValue.class);
        }

        public GenericValue convert(Map<String, Object> obj) throws ConversionException {
            GenericValue genericValue = new GenericValue();
            genericValue.putAll(UtilGenerics.checkMap(obj));
            return genericValue;
        }
    }{code}
The problem here of course is that the generic value is not linked to a ModelEntity. Why? Because we don't know what is the entity. We just received some data, we did not receive an actual Object. So if you run my above code, you will get an error:
{code:java}
java.lang.IllegalStateException: [GenericEntity.getModelEntity] could not find modelEntity for entityName null
{code}
So to convert XML-RPC data to a Java Object, we _must_ know what is the entity name (at the very least). In our example, the entity name is "Product" whereas the service parameter name is "product" which is not the same.

So, unless you have an idea for how to get the entity information for all existing services that take a GenericValue, I think this issue cannot be implemented successfully

> Allowing XML-RPC and SOAP to pass GenericValue objects to services as IN fields
> -------------------------------------------------------------------------------
>
>                 Key: OFBIZ-10317
>                 URL: https://issues.apache.org/jira/browse/OFBIZ-10317
>             Project: OFBiz
>          Issue Type: Improvement
>          Components: framework/webtools
>    Affects Versions: 16.11.04
>            Reporter: Rajesh Kumar Mallah
>            Priority: Major
>         Attachments: not-working.xml, working.xml
>
>
>  
> The existing framework allows invoking  various services via XMLRPC or SOAP 
> as per their argument expectations. However only basic types are handled
> like String , Boolean , Int etc. If a service is expecting a GenericValue eg: 'calculateProductPrice'   it is not possible to invoke it via SOAP or XMLRPC.
> The reason being SOAP or XMLRPC can support Map and that is the closest 
> it can provide in lieu of any custom Object that a Service might be expecting.
> A generic solution needs to be found so that the full potential of the plethora of 
> exportable services can be utilized by external systems that looks for integrating and 
> banking upon OfBiz via XMLRPC or SOAP.
> h6. related Threads:
> [How to pass org.apache.ofbiz.entity.GenericValue using XMLRPC]
> [https://markmail.org/message/dwako4nsu4h3zgmu] [ dev ]
> [https://markmail.org/message/iuffmakor3ru2yce] [user]
>  



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)