You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ofbiz.apache.org by Rajesh Mallah <ma...@gmail.com> on 2018/03/22 19:40:24 UTC

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

 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;

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

Posted by Rishi Solanki <ri...@gmail.com>.
Taher,

What I was suggesting to have generic solution so that all the classes can
be mapped from Map. In our current discussion it is GenericValue ... it may
be ShoppingCart in future. So an method should be smart enough to convert
the map object to target class. The only requirement is to have the map
keys mapped to class attributes.

And yes on thinking more, agree with you that right candidate to have this
method should be ModelService, so that service it self take care of her
object if possible as it is doing right now in other situations except soap
calls.

Hopefully we would conclude and get right solution in the jira ticket
Rajesh just filed.

Thanks!


Rishi Solanki
Sr Manager, Enterprise Software Development
HotWax Systems Pvt. Ltd.
Direct: +91-9893287847
http://www.hotwaxsystems.com
www.hotwax.co

On Sat, Mar 24, 2018 at 3:18 PM, Rajesh Mallah <ma...@gmail.com>
wrote:

> Hi Taher ,
>
> I filed a JIRA   https://issues.apache.org/jira/browse/OFBIZ-10317
>
> Oh, and I'm still interested in your invoke mechanism which I asked
> earlier?
>
>
> Are you referring to your suggestion of refactoring calculateProductPrice?
> i have lost the context.
>
> for me XMLRPC  / SOAP were the only/primary methods of communicating with
> OFBiz , OOTB was just for verification and creation of control datapoints .
>
> regds
> mallah.
>
>
> On Sat, Mar 24, 2018 at 2:51 PM, Taher Alkhateeb <
> slidingfilaments@gmail.com
> > wrote:
>
> > I think maybe the best thing to do is create a JIRA with a topic like
> > "Allowing XML-RPC and SOAP to pass GenericValue objects to services as
> > IN fields". We can then collaborate together on making a solution. I'm
> > interested in helping if you like that.
> >
> > Oh, and I'm still interested in your invoke mechanism which I asked
> > earlier?
> >
> > On Sat, Mar 24, 2018 at 12:12 PM, Rajesh Mallah <mallah.rajesh@gmail.com
> >
> > wrote:
> > > Hello Rishi / Jacques /Taher ,
> > >
> > > Thanks for the responses.
> > >
> > > I feel a generic solution should be devised and  I want to  put some
> > effort
> > > so that an incoming Map is converted to a GenericValue .
> > > Which is a more appropriate place ModelService or XmlRpcEventHandler
> > > and where can the change be done in a relatively easier fashion ?
> > >
> > >
> > > regds
> > > mallah
> > >
> > >
> > >
> > > On Sat, Mar 24, 2018 at 2:32 PM, Taher Alkhateeb <
> > slidingfilaments@gmail.com
> > >> wrote:
> > >
> > >> Thinking out loud, maybe one solution in here is to update the logic
> > >> in ModelService such that a map is automatically casted to a
> > >> GenericValue, or any object that is "instanceOf" would pass through.
> > >> The problem of course is how to carry "state" in these objects, which
> > >> is the reason why I dislike passing objects to services.
> > >>
> > >> So another question, I see both SOAP and XML-RPC messages here, but
> > >> how are you invoking them? Is it just a simple URL or what?
> > >>
> > >> On Sat, Mar 24, 2018 at 11:51 AM, Rishi Solanki <
> > rishisolankii@gmail.com>
> > >> wrote:
> > >> > Hi Rajesh,
> > >> > SOAP request or XMLRPC request both uses the standard format
> > conversion
> > >> > basic/regular java supports. That means if you are sending bunch of
> > key
> > >> > value pair wrt a key ... in your case key is product. Then it will
> > always
> > >> > convert it into the Map. So what general practices followed for xml
> > data
> > >> > exchange is already exists.
> > >> >
> > >> > To have generic value or any other class value in your service IN
> > >> > parameter, you may need to add converter before passing it to
> service
> > for
> > >> > invoke. That means, your checkMap method must be enabled for this
> > type of
> > >> > conversion. Also this method will be invoked on IN parameter type.
> > Please
> > >> > see XmlRpcEventHandler.getContext() for more details.
> > >> >
> > >> > This should be quick one and should resolve your problem, which
> enable
> > >> the
> > >> > conversion of target type. A generic approach also welcome for
> > >> > contribution. :-)
> > >> >
> > >> > HTH!
> > >> >
> > >> > Regards,
> > >> > --
> > >> >
> > >> > Rishi Solanki
> > >> > Sr Manager, Enterprise Software Development
> > >> > HotWax Systems Pvt. Ltd.
> > >> > Direct: +91-9893287847
> > >> > http://www.hotwaxsystems.com
> > >> > www.hotwax.co
> > >> >
> > >> > On Sat, Mar 24, 2018 at 12:17 AM, Rajesh Mallah <
> > mallah.rajesh@gmail.com
> > >> >
> > >> > wrote:
> > >> >
> > >> >> Hi Jacques / List  ,
> > >> >>
> > >> >> I face the very same problem with SOAP too , pls have a look if the
> > SOAP
> > >> >> message is OK. Please suggest any edits to the SOAP message which i
> > may
> > >> >> try.
> > >> >>
> > >> >>
> > >> >> <!-- start of soap -->
> > >> >>
> > >> >> <?xml version="1.0" encoding="UTF-8"?>
> > >> >> <soap:Envelope soap:encodingStyle="http://
> schemas.xmlsoap.org/soap/
> > >> >> encoding/"
> > >> >> xmlns:ns1="http://ofbiz.apache.org/service/" xmlns:soap="
> > >> >> http://schemas.xmlsoap.org/soap/envelope/" xmlns:soapenc="
> > >> >> http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="
> > >> >> http://www.w3.org/2001/XMLSchema" xmlns:xsi="
> > >> >> http://www.w3.org/2001/XMLSchema-instance">
> > >> >>     <soap:Body>
> > >> >>         <ns1:calculateProductPrice>
> > >> >>             <ns1:map-Map soapenc:arrayType="soapenc:Array[3]"
> > >> >> xsi:type="soapenc:Array">
> > >> >>                 <ns1:map-Entry soapenc:arrayType="xsd:anyType[2]"
> > >> >> xsi:type="soapenc:Array">
> > >> >>                     <ns1:map-Key>
> > >> >>                         <ns1:std-String value="login.username" />
> > >> >>                     </ns1:map-Key>
> > >> >>                     <ns1:map-Value>
> > >> >>                         <ns1:std-String value="admin" />
> > >> >>                     </ns1:map-Value>
> > >> >>                 </ns1:map-Entry>
> > >> >>                 <ns1:map-Entry soapenc:arrayType="xsd:anyType[2]"
> > >> >> xsi:type="soapenc:Array">
> > >> >>                     <ns1:map-Key>
> > >> >>                         <ns1:std-String value="login.password" />
> > >> >>                     </ns1:map-Key>
> > >> >>                     <ns1:map-Value>
> > >> >>                         <ns1:std-String value="ofbiz" />
> > >> >>                     </ns1:map-Value>
> > >> >>                 </ns1:map-Entry>
> > >> >>                 <ns1:map-Entry soapenc:arrayType="xsd:anyType[2]"
> > >> >> xsi:type="soapenc:Array">
> > >> >>                     <ns1:map-Key>
> > >> >>                         <ns1:std-String value="product" />
> > >> >>                     </ns1:map-Key>
> > >> >>                     <ns1:map-Value>
> > >> >>                         <ns1:map-Map>
> > >> >>                             <ns1:map-Entry
> > >> >> soapenc:arrayType="xsd:anyType[2]" xsi:type="soapenc:Array">
> > >> >>                                 <ns1:map-Key>
> > >> >>                                     <ns1:std-String
> > value="productId" />
> > >> >>                                 </ns1:map-Key>
> > >> >>                                 <ns1:map-Value>
> > >> >>                                     <ns1:std-String
> > >> value="PROD_SY87B9B8MY"
> > >> >> />
> > >> >>                                 </ns1:map-Value>
> > >> >>                             </ns1:map-Entry>
> > >> >>                         </ns1:map-Map>
> > >> >>                     </ns1:map-Value>
> > >> >>                 </ns1:map-Entry>
> > >> >>             </ns1:map-Map>
> > >> >>         </ns1:calculateProductPrice>
> > >> >>     </soap:Body>
> > >> >> </soap:Envelope>
> > >> >>
> > >> >> <!-- end of soap -->
> > >> >>
> > >> >> 2018-03-24 00:08:15,421 |http-nio-8443-exec-2
> > >> >> |ModelService                  |E| [ModelService.validate] :
> > >> >> {calculateProductPrice} : (IN) Required test error:
> > >> >> org.apache.ofbiz.service.ServiceValidationException: Type check
> > failed
> > >> for
> > >> >> field [calculateProductPrice.product]; expected type is
> > >> >> [org.apache.ofbiz.entity.GenericValue]; actual type is
> > >> [java.util.HashMap]
> > >> >> 2018-03-24 00:08:15,421 |http-nio-8443-exec-2
> > >> >> |ServiceDispatcher             |E| Incoming context (in runSync :
> > >> >> calculateProductPrice) does not match expected requirements
> > >> >> org.apache.ofbiz.service.ServiceValidationException: Type check
> > failed
> > >> for
> > >> >> field [calculateProductPrice.product]; expected type is
> > >> >> [org.apache.ofbiz.entity.GenericValue]; actual type is
> > >> [java.util.HashMap]
> > >> >>
> > >> >>
> > >> >>
> > >> >> regds
> > >> >> mallah.
> > >> >>
> > >> >>
> > >> >>
> > >> >> On Fri, Mar 23, 2018 at 3:43 PM, Rajesh Mallah <
> > mallah.rajesh@gmail.com
> > >> >
> > >> >> wrote:
> > >> >>
> > >> >> >
> > >> >> > Hello Taher ,
> > >> >> >
> > >> >> > As suggested i shifted this discussion to the user list from dev.
> > >> >> >
> > >> >> > As you expected the product key has a value which is a
> > >> >> > struct. This maps to java.util.HashMap but the validator
> > >> >> > expects it to be a GenericValue and hence it does not hands it
> over
> > >> >> > to the service.
> > >> >> >
> > >> >> >
> > >> >> > $ ./007-get-price.pl  PROD_SY87B9B8MY
> > >> >> > 2018/03/23 15:34:31 ------------------------------
> > >> >> > --------------------------------------------------
> > >> >> > 2018/03/23 15:34:31 REQ  >>>>>>>>>   <?xml version="1.0"
> > >> >> encoding="UTF-8"?>
> > >> >> > REQ  >>>>>>>>>   <methodCall>
> > >> >> > REQ  >>>>>>>>>     <methodName>calculateProductPrice</
> methodName>
> > >> >> > REQ  >>>>>>>>>     <params>
> > >> >> > REQ  >>>>>>>>>       <param>
> > >> >> > REQ  >>>>>>>>>         <value>
> > >> >> > REQ  >>>>>>>>>          <struct>
> > >> >> > REQ  >>>>>>>>>            <member>
> > >> >> > REQ  >>>>>>>>>              <name>login.password</name>
> > >> >> > REQ  >>>>>>>>>              <value>
> > >> >> > REQ  >>>>>>>>>                <string><![CDATA[ofbiz]]></string>
> > >> >> > REQ  >>>>>>>>>              </value>
> > >> >> > REQ  >>>>>>>>>            </member>
> > >> >> > REQ  >>>>>>>>>            <member>
> > >> >> > REQ  >>>>>>>>>              <name>product</name>
> > >> >> > REQ  >>>>>>>>>              <value>
> > >> >> > REQ  >>>>>>>>>                <struct>
> > >> >> > REQ  >>>>>>>>>                  <member>
> > >> >> > REQ  >>>>>>>>>                    <name>productId</name>
> > >> >> > REQ  >>>>>>>>>                    <value>
> > >> >> > REQ  >>>>>>>>>                      <string><![CDATA[PROD_
> > >> >> > SY87B9B8MY]]></string>
> > >> >> > REQ  >>>>>>>>>                    </value>
> > >> >> > REQ  >>>>>>>>>                  </member>
> > >> >> > REQ  >>>>>>>>>                </struct>
> > >> >> > REQ  >>>>>>>>>              </value>
> > >> >> > REQ  >>>>>>>>>            </member>
> > >> >> > REQ  >>>>>>>>>            <member>
> > >> >> > REQ  >>>>>>>>>              <name>login.username</name>
> > >> >> > REQ  >>>>>>>>>              <value>
> > >> >> > REQ  >>>>>>>>>                <string><![CDATA[admin]]></string>
> > >> >> > REQ  >>>>>>>>>              </value>
> > >> >> > REQ  >>>>>>>>>            </member>
> > >> >> > REQ  >>>>>>>>>          </struct>
> > >> >> > REQ  >>>>>>>>>         </value>
> > >> >> > REQ  >>>>>>>>>       </param>
> > >> >> > REQ  >>>>>>>>>     </params>
> > >> >> > REQ  >>>>>>>>>   </methodCall>
> > >> >> > 2018/03/23 15:34:31 ------------------------------
> > >> >> > --------------------------------------------------
> > >> >> > 2018/03/23 15:34:31 ------------------------------
> > >> >> > --------------------------------------------------
> > >> >> > 2018/03/23 15:34:31 RES  <<<<<<<<<   <?xml version="1.0"
> > >> >> encoding="UTF-8"?>
> > >> >> > RES  <<<<<<<<<   <methodResponse
> > >> >> > RES  <<<<<<<<<     xmlns:ex="http://ws.apache.
> > org/xmlrpc/namespaces/
> > >> >> > extensions">
> > >> >> > RES  <<<<<<<<<     <fault>
> > >> >> > RES  <<<<<<<<<       <value>
> > >> >> > RES  <<<<<<<<<         <struct>
> > >> >> > RES  <<<<<<<<<          <member>
> > >> >> > RES  <<<<<<<<<            <name>faultCode</name>
> > >> >> > RES  <<<<<<<<<            <value>
> > >> >> > RES  <<<<<<<<<              <i4>0</i4>
> > >> >> > RES  <<<<<<<<<            </value>
> > >> >> > RES  <<<<<<<<<          </member>
> > >> >> > RES  <<<<<<<<<          <member>
> > >> >> > RES  <<<<<<<<<            <name>faultString</name>
> > >> >> > RES  <<<<<<<<<            <value>Type check failed for field
> > >> >> > RES  <<<<<<<<<              [calculateProductPrice.product];
> > expected
> > >> >> > type is
> > >> >> > RES  <<<<<<<<<              [org.apache.ofbiz.entity.
> > GenericValue];
> > >> >> > actual type is
> > >> >> > RES  <<<<<<<<<              [java.util.HashMap]</value>
> > >> >> > RES  <<<<<<<<<          </member>
> > >> >> > RES  <<<<<<<<<         </struct>
> > >> >> > RES  <<<<<<<<<       </value>
> > >> >> > RES  <<<<<<<<<     </fault>
> > >> >> > RES  <<<<<<<<<   </methodResponse>
> > >> >> > 2018/03/23 15:34:31 ------------------------------
> > >> >> > --------------------------------------------------
> > >> >> > Service: calculateProductPrice faultString:Type check failed for
> > field
> > >> >> > [calculateProductPrice.product]; expected type is
> > >> >> > [org.apache.ofbiz.entity.GenericValue]; actual type is
> > >> >> [java.util.HashMap]
> > >> >> >
> > >> >> > ========================================
> > >> >> > $ cat 007-get-price.pl
> > >> >> >
> > >> >> > #!/usr/bin/perl
> > >> >> >
> > >> >> > use OFBizClient;
> > >> >> >
> > >> >> > my $ofbiz_client = OFBizClient->new(
> > >> >> >                                 url => '
> https://your_ofbiz_server_
> > >> >> > here/webtools/control/xmlrpc' ,
> > >> >> >                                 username=>'admin'  ,
> > >> >> >                                 password => 'ofbiz'
> > >> >> > );
> > >> >> >
> > >> >> > my $productId = 'PROD_SY87B9B8MY';
> > >> >> > $ofbiz_client->call('calculateProductPrice' , { product => {
> > >> productId
> > >> >> > =>  $productId }   } );
> > >> >> >
> > >> >> > ========================================
> > >> >> >
> > >> >> >
> > >> >> >
> > >> >>
> > >>
> >
>

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

Posted by Rajesh Mallah <ma...@gmail.com>.
Hi Taher ,

I filed a JIRA   https://issues.apache.org/jira/browse/OFBIZ-10317

Oh, and I'm still interested in your invoke mechanism which I asked earlier?


Are you referring to your suggestion of refactoring calculateProductPrice?
i have lost the context.

for me XMLRPC  / SOAP were the only/primary methods of communicating with
OFBiz , OOTB was just for verification and creation of control datapoints .

regds
mallah.


On Sat, Mar 24, 2018 at 2:51 PM, Taher Alkhateeb <slidingfilaments@gmail.com
> wrote:

> I think maybe the best thing to do is create a JIRA with a topic like
> "Allowing XML-RPC and SOAP to pass GenericValue objects to services as
> IN fields". We can then collaborate together on making a solution. I'm
> interested in helping if you like that.
>
> Oh, and I'm still interested in your invoke mechanism which I asked
> earlier?
>
> On Sat, Mar 24, 2018 at 12:12 PM, Rajesh Mallah <ma...@gmail.com>
> wrote:
> > Hello Rishi / Jacques /Taher ,
> >
> > Thanks for the responses.
> >
> > I feel a generic solution should be devised and  I want to  put some
> effort
> > so that an incoming Map is converted to a GenericValue .
> > Which is a more appropriate place ModelService or XmlRpcEventHandler
> > and where can the change be done in a relatively easier fashion ?
> >
> >
> > regds
> > mallah
> >
> >
> >
> > On Sat, Mar 24, 2018 at 2:32 PM, Taher Alkhateeb <
> slidingfilaments@gmail.com
> >> wrote:
> >
> >> Thinking out loud, maybe one solution in here is to update the logic
> >> in ModelService such that a map is automatically casted to a
> >> GenericValue, or any object that is "instanceOf" would pass through.
> >> The problem of course is how to carry "state" in these objects, which
> >> is the reason why I dislike passing objects to services.
> >>
> >> So another question, I see both SOAP and XML-RPC messages here, but
> >> how are you invoking them? Is it just a simple URL or what?
> >>
> >> On Sat, Mar 24, 2018 at 11:51 AM, Rishi Solanki <
> rishisolankii@gmail.com>
> >> wrote:
> >> > Hi Rajesh,
> >> > SOAP request or XMLRPC request both uses the standard format
> conversion
> >> > basic/regular java supports. That means if you are sending bunch of
> key
> >> > value pair wrt a key ... in your case key is product. Then it will
> always
> >> > convert it into the Map. So what general practices followed for xml
> data
> >> > exchange is already exists.
> >> >
> >> > To have generic value or any other class value in your service IN
> >> > parameter, you may need to add converter before passing it to service
> for
> >> > invoke. That means, your checkMap method must be enabled for this
> type of
> >> > conversion. Also this method will be invoked on IN parameter type.
> Please
> >> > see XmlRpcEventHandler.getContext() for more details.
> >> >
> >> > This should be quick one and should resolve your problem, which enable
> >> the
> >> > conversion of target type. A generic approach also welcome for
> >> > contribution. :-)
> >> >
> >> > HTH!
> >> >
> >> > Regards,
> >> > --
> >> >
> >> > Rishi Solanki
> >> > Sr Manager, Enterprise Software Development
> >> > HotWax Systems Pvt. Ltd.
> >> > Direct: +91-9893287847
> >> > http://www.hotwaxsystems.com
> >> > www.hotwax.co
> >> >
> >> > On Sat, Mar 24, 2018 at 12:17 AM, Rajesh Mallah <
> mallah.rajesh@gmail.com
> >> >
> >> > wrote:
> >> >
> >> >> Hi Jacques / List  ,
> >> >>
> >> >> I face the very same problem with SOAP too , pls have a look if the
> SOAP
> >> >> message is OK. Please suggest any edits to the SOAP message which i
> may
> >> >> try.
> >> >>
> >> >>
> >> >> <!-- start of soap -->
> >> >>
> >> >> <?xml version="1.0" encoding="UTF-8"?>
> >> >> <soap:Envelope soap:encodingStyle="http://schemas.xmlsoap.org/soap/
> >> >> encoding/"
> >> >> xmlns:ns1="http://ofbiz.apache.org/service/" xmlns:soap="
> >> >> http://schemas.xmlsoap.org/soap/envelope/" xmlns:soapenc="
> >> >> http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="
> >> >> http://www.w3.org/2001/XMLSchema" xmlns:xsi="
> >> >> http://www.w3.org/2001/XMLSchema-instance">
> >> >>     <soap:Body>
> >> >>         <ns1:calculateProductPrice>
> >> >>             <ns1:map-Map soapenc:arrayType="soapenc:Array[3]"
> >> >> xsi:type="soapenc:Array">
> >> >>                 <ns1:map-Entry soapenc:arrayType="xsd:anyType[2]"
> >> >> xsi:type="soapenc:Array">
> >> >>                     <ns1:map-Key>
> >> >>                         <ns1:std-String value="login.username" />
> >> >>                     </ns1:map-Key>
> >> >>                     <ns1:map-Value>
> >> >>                         <ns1:std-String value="admin" />
> >> >>                     </ns1:map-Value>
> >> >>                 </ns1:map-Entry>
> >> >>                 <ns1:map-Entry soapenc:arrayType="xsd:anyType[2]"
> >> >> xsi:type="soapenc:Array">
> >> >>                     <ns1:map-Key>
> >> >>                         <ns1:std-String value="login.password" />
> >> >>                     </ns1:map-Key>
> >> >>                     <ns1:map-Value>
> >> >>                         <ns1:std-String value="ofbiz" />
> >> >>                     </ns1:map-Value>
> >> >>                 </ns1:map-Entry>
> >> >>                 <ns1:map-Entry soapenc:arrayType="xsd:anyType[2]"
> >> >> xsi:type="soapenc:Array">
> >> >>                     <ns1:map-Key>
> >> >>                         <ns1:std-String value="product" />
> >> >>                     </ns1:map-Key>
> >> >>                     <ns1:map-Value>
> >> >>                         <ns1:map-Map>
> >> >>                             <ns1:map-Entry
> >> >> soapenc:arrayType="xsd:anyType[2]" xsi:type="soapenc:Array">
> >> >>                                 <ns1:map-Key>
> >> >>                                     <ns1:std-String
> value="productId" />
> >> >>                                 </ns1:map-Key>
> >> >>                                 <ns1:map-Value>
> >> >>                                     <ns1:std-String
> >> value="PROD_SY87B9B8MY"
> >> >> />
> >> >>                                 </ns1:map-Value>
> >> >>                             </ns1:map-Entry>
> >> >>                         </ns1:map-Map>
> >> >>                     </ns1:map-Value>
> >> >>                 </ns1:map-Entry>
> >> >>             </ns1:map-Map>
> >> >>         </ns1:calculateProductPrice>
> >> >>     </soap:Body>
> >> >> </soap:Envelope>
> >> >>
> >> >> <!-- end of soap -->
> >> >>
> >> >> 2018-03-24 00:08:15,421 |http-nio-8443-exec-2
> >> >> |ModelService                  |E| [ModelService.validate] :
> >> >> {calculateProductPrice} : (IN) Required test error:
> >> >> org.apache.ofbiz.service.ServiceValidationException: Type check
> failed
> >> for
> >> >> field [calculateProductPrice.product]; expected type is
> >> >> [org.apache.ofbiz.entity.GenericValue]; actual type is
> >> [java.util.HashMap]
> >> >> 2018-03-24 00:08:15,421 |http-nio-8443-exec-2
> >> >> |ServiceDispatcher             |E| Incoming context (in runSync :
> >> >> calculateProductPrice) does not match expected requirements
> >> >> org.apache.ofbiz.service.ServiceValidationException: Type check
> failed
> >> for
> >> >> field [calculateProductPrice.product]; expected type is
> >> >> [org.apache.ofbiz.entity.GenericValue]; actual type is
> >> [java.util.HashMap]
> >> >>
> >> >>
> >> >>
> >> >> regds
> >> >> mallah.
> >> >>
> >> >>
> >> >>
> >> >> On Fri, Mar 23, 2018 at 3:43 PM, Rajesh Mallah <
> mallah.rajesh@gmail.com
> >> >
> >> >> wrote:
> >> >>
> >> >> >
> >> >> > Hello Taher ,
> >> >> >
> >> >> > As suggested i shifted this discussion to the user list from dev.
> >> >> >
> >> >> > As you expected the product key has a value which is a
> >> >> > struct. This maps to java.util.HashMap but the validator
> >> >> > expects it to be a GenericValue and hence it does not hands it over
> >> >> > to the service.
> >> >> >
> >> >> >
> >> >> > $ ./007-get-price.pl  PROD_SY87B9B8MY
> >> >> > 2018/03/23 15:34:31 ------------------------------
> >> >> > --------------------------------------------------
> >> >> > 2018/03/23 15:34:31 REQ  >>>>>>>>>   <?xml version="1.0"
> >> >> encoding="UTF-8"?>
> >> >> > REQ  >>>>>>>>>   <methodCall>
> >> >> > REQ  >>>>>>>>>     <methodName>calculateProductPrice</methodName>
> >> >> > REQ  >>>>>>>>>     <params>
> >> >> > REQ  >>>>>>>>>       <param>
> >> >> > REQ  >>>>>>>>>         <value>
> >> >> > REQ  >>>>>>>>>          <struct>
> >> >> > REQ  >>>>>>>>>            <member>
> >> >> > REQ  >>>>>>>>>              <name>login.password</name>
> >> >> > REQ  >>>>>>>>>              <value>
> >> >> > REQ  >>>>>>>>>                <string><![CDATA[ofbiz]]></string>
> >> >> > REQ  >>>>>>>>>              </value>
> >> >> > REQ  >>>>>>>>>            </member>
> >> >> > REQ  >>>>>>>>>            <member>
> >> >> > REQ  >>>>>>>>>              <name>product</name>
> >> >> > REQ  >>>>>>>>>              <value>
> >> >> > REQ  >>>>>>>>>                <struct>
> >> >> > REQ  >>>>>>>>>                  <member>
> >> >> > REQ  >>>>>>>>>                    <name>productId</name>
> >> >> > REQ  >>>>>>>>>                    <value>
> >> >> > REQ  >>>>>>>>>                      <string><![CDATA[PROD_
> >> >> > SY87B9B8MY]]></string>
> >> >> > REQ  >>>>>>>>>                    </value>
> >> >> > REQ  >>>>>>>>>                  </member>
> >> >> > REQ  >>>>>>>>>                </struct>
> >> >> > REQ  >>>>>>>>>              </value>
> >> >> > REQ  >>>>>>>>>            </member>
> >> >> > REQ  >>>>>>>>>            <member>
> >> >> > REQ  >>>>>>>>>              <name>login.username</name>
> >> >> > REQ  >>>>>>>>>              <value>
> >> >> > REQ  >>>>>>>>>                <string><![CDATA[admin]]></string>
> >> >> > REQ  >>>>>>>>>              </value>
> >> >> > REQ  >>>>>>>>>            </member>
> >> >> > REQ  >>>>>>>>>          </struct>
> >> >> > REQ  >>>>>>>>>         </value>
> >> >> > REQ  >>>>>>>>>       </param>
> >> >> > REQ  >>>>>>>>>     </params>
> >> >> > REQ  >>>>>>>>>   </methodCall>
> >> >> > 2018/03/23 15:34:31 ------------------------------
> >> >> > --------------------------------------------------
> >> >> > 2018/03/23 15:34:31 ------------------------------
> >> >> > --------------------------------------------------
> >> >> > 2018/03/23 15:34:31 RES  <<<<<<<<<   <?xml version="1.0"
> >> >> encoding="UTF-8"?>
> >> >> > RES  <<<<<<<<<   <methodResponse
> >> >> > RES  <<<<<<<<<     xmlns:ex="http://ws.apache.
> org/xmlrpc/namespaces/
> >> >> > extensions">
> >> >> > RES  <<<<<<<<<     <fault>
> >> >> > RES  <<<<<<<<<       <value>
> >> >> > RES  <<<<<<<<<         <struct>
> >> >> > RES  <<<<<<<<<          <member>
> >> >> > RES  <<<<<<<<<            <name>faultCode</name>
> >> >> > RES  <<<<<<<<<            <value>
> >> >> > RES  <<<<<<<<<              <i4>0</i4>
> >> >> > RES  <<<<<<<<<            </value>
> >> >> > RES  <<<<<<<<<          </member>
> >> >> > RES  <<<<<<<<<          <member>
> >> >> > RES  <<<<<<<<<            <name>faultString</name>
> >> >> > RES  <<<<<<<<<            <value>Type check failed for field
> >> >> > RES  <<<<<<<<<              [calculateProductPrice.product];
> expected
> >> >> > type is
> >> >> > RES  <<<<<<<<<              [org.apache.ofbiz.entity.
> GenericValue];
> >> >> > actual type is
> >> >> > RES  <<<<<<<<<              [java.util.HashMap]</value>
> >> >> > RES  <<<<<<<<<          </member>
> >> >> > RES  <<<<<<<<<         </struct>
> >> >> > RES  <<<<<<<<<       </value>
> >> >> > RES  <<<<<<<<<     </fault>
> >> >> > RES  <<<<<<<<<   </methodResponse>
> >> >> > 2018/03/23 15:34:31 ------------------------------
> >> >> > --------------------------------------------------
> >> >> > Service: calculateProductPrice faultString:Type check failed for
> field
> >> >> > [calculateProductPrice.product]; expected type is
> >> >> > [org.apache.ofbiz.entity.GenericValue]; actual type is
> >> >> [java.util.HashMap]
> >> >> >
> >> >> > ========================================
> >> >> > $ cat 007-get-price.pl
> >> >> >
> >> >> > #!/usr/bin/perl
> >> >> >
> >> >> > use OFBizClient;
> >> >> >
> >> >> > my $ofbiz_client = OFBizClient->new(
> >> >> >                                 url => 'https://your_ofbiz_server_
> >> >> > here/webtools/control/xmlrpc' ,
> >> >> >                                 username=>'admin'  ,
> >> >> >                                 password => 'ofbiz'
> >> >> > );
> >> >> >
> >> >> > my $productId = 'PROD_SY87B9B8MY';
> >> >> > $ofbiz_client->call('calculateProductPrice' , { product => {
> >> productId
> >> >> > =>  $productId }   } );
> >> >> >
> >> >> > ========================================
> >> >> >
> >> >> >
> >> >> >
> >> >>
> >>
>

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

Posted by Taher Alkhateeb <sl...@gmail.com>.
I think maybe the best thing to do is create a JIRA with a topic like
"Allowing XML-RPC and SOAP to pass GenericValue objects to services as
IN fields". We can then collaborate together on making a solution. I'm
interested in helping if you like that.

Oh, and I'm still interested in your invoke mechanism which I asked earlier?

On Sat, Mar 24, 2018 at 12:12 PM, Rajesh Mallah <ma...@gmail.com> wrote:
> Hello Rishi / Jacques /Taher ,
>
> Thanks for the responses.
>
> I feel a generic solution should be devised and  I want to  put some effort
> so that an incoming Map is converted to a GenericValue .
> Which is a more appropriate place ModelService or XmlRpcEventHandler
> and where can the change be done in a relatively easier fashion ?
>
>
> regds
> mallah
>
>
>
> On Sat, Mar 24, 2018 at 2:32 PM, Taher Alkhateeb <slidingfilaments@gmail.com
>> wrote:
>
>> Thinking out loud, maybe one solution in here is to update the logic
>> in ModelService such that a map is automatically casted to a
>> GenericValue, or any object that is "instanceOf" would pass through.
>> The problem of course is how to carry "state" in these objects, which
>> is the reason why I dislike passing objects to services.
>>
>> So another question, I see both SOAP and XML-RPC messages here, but
>> how are you invoking them? Is it just a simple URL or what?
>>
>> On Sat, Mar 24, 2018 at 11:51 AM, Rishi Solanki <ri...@gmail.com>
>> wrote:
>> > Hi Rajesh,
>> > SOAP request or XMLRPC request both uses the standard format conversion
>> > basic/regular java supports. That means if you are sending bunch of key
>> > value pair wrt a key ... in your case key is product. Then it will always
>> > convert it into the Map. So what general practices followed for xml data
>> > exchange is already exists.
>> >
>> > To have generic value or any other class value in your service IN
>> > parameter, you may need to add converter before passing it to service for
>> > invoke. That means, your checkMap method must be enabled for this type of
>> > conversion. Also this method will be invoked on IN parameter type. Please
>> > see XmlRpcEventHandler.getContext() for more details.
>> >
>> > This should be quick one and should resolve your problem, which enable
>> the
>> > conversion of target type. A generic approach also welcome for
>> > contribution. :-)
>> >
>> > HTH!
>> >
>> > Regards,
>> > --
>> >
>> > Rishi Solanki
>> > Sr Manager, Enterprise Software Development
>> > HotWax Systems Pvt. Ltd.
>> > Direct: +91-9893287847
>> > http://www.hotwaxsystems.com
>> > www.hotwax.co
>> >
>> > On Sat, Mar 24, 2018 at 12:17 AM, Rajesh Mallah <mallah.rajesh@gmail.com
>> >
>> > wrote:
>> >
>> >> Hi Jacques / List  ,
>> >>
>> >> I face the very same problem with SOAP too , pls have a look if the SOAP
>> >> message is OK. Please suggest any edits to the SOAP message which i may
>> >> try.
>> >>
>> >>
>> >> <!-- start of soap -->
>> >>
>> >> <?xml version="1.0" encoding="UTF-8"?>
>> >> <soap:Envelope soap:encodingStyle="http://schemas.xmlsoap.org/soap/
>> >> encoding/"
>> >> xmlns:ns1="http://ofbiz.apache.org/service/" xmlns:soap="
>> >> http://schemas.xmlsoap.org/soap/envelope/" xmlns:soapenc="
>> >> http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="
>> >> http://www.w3.org/2001/XMLSchema" xmlns:xsi="
>> >> http://www.w3.org/2001/XMLSchema-instance">
>> >>     <soap:Body>
>> >>         <ns1:calculateProductPrice>
>> >>             <ns1:map-Map soapenc:arrayType="soapenc:Array[3]"
>> >> xsi:type="soapenc:Array">
>> >>                 <ns1:map-Entry soapenc:arrayType="xsd:anyType[2]"
>> >> xsi:type="soapenc:Array">
>> >>                     <ns1:map-Key>
>> >>                         <ns1:std-String value="login.username" />
>> >>                     </ns1:map-Key>
>> >>                     <ns1:map-Value>
>> >>                         <ns1:std-String value="admin" />
>> >>                     </ns1:map-Value>
>> >>                 </ns1:map-Entry>
>> >>                 <ns1:map-Entry soapenc:arrayType="xsd:anyType[2]"
>> >> xsi:type="soapenc:Array">
>> >>                     <ns1:map-Key>
>> >>                         <ns1:std-String value="login.password" />
>> >>                     </ns1:map-Key>
>> >>                     <ns1:map-Value>
>> >>                         <ns1:std-String value="ofbiz" />
>> >>                     </ns1:map-Value>
>> >>                 </ns1:map-Entry>
>> >>                 <ns1:map-Entry soapenc:arrayType="xsd:anyType[2]"
>> >> xsi:type="soapenc:Array">
>> >>                     <ns1:map-Key>
>> >>                         <ns1:std-String value="product" />
>> >>                     </ns1:map-Key>
>> >>                     <ns1:map-Value>
>> >>                         <ns1:map-Map>
>> >>                             <ns1:map-Entry
>> >> soapenc:arrayType="xsd:anyType[2]" xsi:type="soapenc:Array">
>> >>                                 <ns1:map-Key>
>> >>                                     <ns1:std-String value="productId" />
>> >>                                 </ns1:map-Key>
>> >>                                 <ns1:map-Value>
>> >>                                     <ns1:std-String
>> value="PROD_SY87B9B8MY"
>> >> />
>> >>                                 </ns1:map-Value>
>> >>                             </ns1:map-Entry>
>> >>                         </ns1:map-Map>
>> >>                     </ns1:map-Value>
>> >>                 </ns1:map-Entry>
>> >>             </ns1:map-Map>
>> >>         </ns1:calculateProductPrice>
>> >>     </soap:Body>
>> >> </soap:Envelope>
>> >>
>> >> <!-- end of soap -->
>> >>
>> >> 2018-03-24 00:08:15,421 |http-nio-8443-exec-2
>> >> |ModelService                  |E| [ModelService.validate] :
>> >> {calculateProductPrice} : (IN) Required test error:
>> >> org.apache.ofbiz.service.ServiceValidationException: Type check failed
>> for
>> >> field [calculateProductPrice.product]; expected type is
>> >> [org.apache.ofbiz.entity.GenericValue]; actual type is
>> [java.util.HashMap]
>> >> 2018-03-24 00:08:15,421 |http-nio-8443-exec-2
>> >> |ServiceDispatcher             |E| Incoming context (in runSync :
>> >> calculateProductPrice) does not match expected requirements
>> >> org.apache.ofbiz.service.ServiceValidationException: Type check failed
>> for
>> >> field [calculateProductPrice.product]; expected type is
>> >> [org.apache.ofbiz.entity.GenericValue]; actual type is
>> [java.util.HashMap]
>> >>
>> >>
>> >>
>> >> regds
>> >> mallah.
>> >>
>> >>
>> >>
>> >> On Fri, Mar 23, 2018 at 3:43 PM, Rajesh Mallah <mallah.rajesh@gmail.com
>> >
>> >> wrote:
>> >>
>> >> >
>> >> > Hello Taher ,
>> >> >
>> >> > As suggested i shifted this discussion to the user list from dev.
>> >> >
>> >> > As you expected the product key has a value which is a
>> >> > struct. This maps to java.util.HashMap but the validator
>> >> > expects it to be a GenericValue and hence it does not hands it over
>> >> > to the service.
>> >> >
>> >> >
>> >> > $ ./007-get-price.pl  PROD_SY87B9B8MY
>> >> > 2018/03/23 15:34:31 ------------------------------
>> >> > --------------------------------------------------
>> >> > 2018/03/23 15:34:31 REQ  >>>>>>>>>   <?xml version="1.0"
>> >> encoding="UTF-8"?>
>> >> > REQ  >>>>>>>>>   <methodCall>
>> >> > REQ  >>>>>>>>>     <methodName>calculateProductPrice</methodName>
>> >> > REQ  >>>>>>>>>     <params>
>> >> > REQ  >>>>>>>>>       <param>
>> >> > REQ  >>>>>>>>>         <value>
>> >> > REQ  >>>>>>>>>          <struct>
>> >> > REQ  >>>>>>>>>            <member>
>> >> > REQ  >>>>>>>>>              <name>login.password</name>
>> >> > REQ  >>>>>>>>>              <value>
>> >> > REQ  >>>>>>>>>                <string><![CDATA[ofbiz]]></string>
>> >> > REQ  >>>>>>>>>              </value>
>> >> > REQ  >>>>>>>>>            </member>
>> >> > REQ  >>>>>>>>>            <member>
>> >> > REQ  >>>>>>>>>              <name>product</name>
>> >> > REQ  >>>>>>>>>              <value>
>> >> > REQ  >>>>>>>>>                <struct>
>> >> > REQ  >>>>>>>>>                  <member>
>> >> > REQ  >>>>>>>>>                    <name>productId</name>
>> >> > REQ  >>>>>>>>>                    <value>
>> >> > REQ  >>>>>>>>>                      <string><![CDATA[PROD_
>> >> > SY87B9B8MY]]></string>
>> >> > REQ  >>>>>>>>>                    </value>
>> >> > REQ  >>>>>>>>>                  </member>
>> >> > REQ  >>>>>>>>>                </struct>
>> >> > REQ  >>>>>>>>>              </value>
>> >> > REQ  >>>>>>>>>            </member>
>> >> > REQ  >>>>>>>>>            <member>
>> >> > REQ  >>>>>>>>>              <name>login.username</name>
>> >> > REQ  >>>>>>>>>              <value>
>> >> > REQ  >>>>>>>>>                <string><![CDATA[admin]]></string>
>> >> > REQ  >>>>>>>>>              </value>
>> >> > REQ  >>>>>>>>>            </member>
>> >> > REQ  >>>>>>>>>          </struct>
>> >> > REQ  >>>>>>>>>         </value>
>> >> > REQ  >>>>>>>>>       </param>
>> >> > REQ  >>>>>>>>>     </params>
>> >> > REQ  >>>>>>>>>   </methodCall>
>> >> > 2018/03/23 15:34:31 ------------------------------
>> >> > --------------------------------------------------
>> >> > 2018/03/23 15:34:31 ------------------------------
>> >> > --------------------------------------------------
>> >> > 2018/03/23 15:34:31 RES  <<<<<<<<<   <?xml version="1.0"
>> >> encoding="UTF-8"?>
>> >> > RES  <<<<<<<<<   <methodResponse
>> >> > RES  <<<<<<<<<     xmlns:ex="http://ws.apache.org/xmlrpc/namespaces/
>> >> > extensions">
>> >> > RES  <<<<<<<<<     <fault>
>> >> > RES  <<<<<<<<<       <value>
>> >> > RES  <<<<<<<<<         <struct>
>> >> > RES  <<<<<<<<<          <member>
>> >> > RES  <<<<<<<<<            <name>faultCode</name>
>> >> > RES  <<<<<<<<<            <value>
>> >> > RES  <<<<<<<<<              <i4>0</i4>
>> >> > RES  <<<<<<<<<            </value>
>> >> > RES  <<<<<<<<<          </member>
>> >> > RES  <<<<<<<<<          <member>
>> >> > RES  <<<<<<<<<            <name>faultString</name>
>> >> > RES  <<<<<<<<<            <value>Type check failed for field
>> >> > RES  <<<<<<<<<              [calculateProductPrice.product]; expected
>> >> > type is
>> >> > RES  <<<<<<<<<              [org.apache.ofbiz.entity.GenericValue];
>> >> > actual type is
>> >> > RES  <<<<<<<<<              [java.util.HashMap]</value>
>> >> > RES  <<<<<<<<<          </member>
>> >> > RES  <<<<<<<<<         </struct>
>> >> > RES  <<<<<<<<<       </value>
>> >> > RES  <<<<<<<<<     </fault>
>> >> > RES  <<<<<<<<<   </methodResponse>
>> >> > 2018/03/23 15:34:31 ------------------------------
>> >> > --------------------------------------------------
>> >> > Service: calculateProductPrice faultString:Type check failed for field
>> >> > [calculateProductPrice.product]; expected type is
>> >> > [org.apache.ofbiz.entity.GenericValue]; actual type is
>> >> [java.util.HashMap]
>> >> >
>> >> > ========================================
>> >> > $ cat 007-get-price.pl
>> >> >
>> >> > #!/usr/bin/perl
>> >> >
>> >> > use OFBizClient;
>> >> >
>> >> > my $ofbiz_client = OFBizClient->new(
>> >> >                                 url => 'https://your_ofbiz_server_
>> >> > here/webtools/control/xmlrpc' ,
>> >> >                                 username=>'admin'  ,
>> >> >                                 password => 'ofbiz'
>> >> > );
>> >> >
>> >> > my $productId = 'PROD_SY87B9B8MY';
>> >> > $ofbiz_client->call('calculateProductPrice' , { product => {
>> productId
>> >> > =>  $productId }   } );
>> >> >
>> >> > ========================================
>> >> >
>> >> >
>> >> >
>> >>
>>

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

Posted by Rajesh Mallah <ma...@gmail.com>.
Hello Rishi / Jacques /Taher ,

Thanks for the responses.

I feel a generic solution should be devised and  I want to  put some effort
so that an incoming Map is converted to a GenericValue .
Which is a more appropriate place ModelService or XmlRpcEventHandler
and where can the change be done in a relatively easier fashion ?


regds
mallah



On Sat, Mar 24, 2018 at 2:32 PM, Taher Alkhateeb <slidingfilaments@gmail.com
> wrote:

> Thinking out loud, maybe one solution in here is to update the logic
> in ModelService such that a map is automatically casted to a
> GenericValue, or any object that is "instanceOf" would pass through.
> The problem of course is how to carry "state" in these objects, which
> is the reason why I dislike passing objects to services.
>
> So another question, I see both SOAP and XML-RPC messages here, but
> how are you invoking them? Is it just a simple URL or what?
>
> On Sat, Mar 24, 2018 at 11:51 AM, Rishi Solanki <ri...@gmail.com>
> wrote:
> > Hi Rajesh,
> > SOAP request or XMLRPC request both uses the standard format conversion
> > basic/regular java supports. That means if you are sending bunch of key
> > value pair wrt a key ... in your case key is product. Then it will always
> > convert it into the Map. So what general practices followed for xml data
> > exchange is already exists.
> >
> > To have generic value or any other class value in your service IN
> > parameter, you may need to add converter before passing it to service for
> > invoke. That means, your checkMap method must be enabled for this type of
> > conversion. Also this method will be invoked on IN parameter type. Please
> > see XmlRpcEventHandler.getContext() for more details.
> >
> > This should be quick one and should resolve your problem, which enable
> the
> > conversion of target type. A generic approach also welcome for
> > contribution. :-)
> >
> > HTH!
> >
> > Regards,
> > --
> >
> > Rishi Solanki
> > Sr Manager, Enterprise Software Development
> > HotWax Systems Pvt. Ltd.
> > Direct: +91-9893287847
> > http://www.hotwaxsystems.com
> > www.hotwax.co
> >
> > On Sat, Mar 24, 2018 at 12:17 AM, Rajesh Mallah <mallah.rajesh@gmail.com
> >
> > wrote:
> >
> >> Hi Jacques / List  ,
> >>
> >> I face the very same problem with SOAP too , pls have a look if the SOAP
> >> message is OK. Please suggest any edits to the SOAP message which i may
> >> try.
> >>
> >>
> >> <!-- start of soap -->
> >>
> >> <?xml version="1.0" encoding="UTF-8"?>
> >> <soap:Envelope soap:encodingStyle="http://schemas.xmlsoap.org/soap/
> >> encoding/"
> >> xmlns:ns1="http://ofbiz.apache.org/service/" xmlns:soap="
> >> http://schemas.xmlsoap.org/soap/envelope/" xmlns:soapenc="
> >> http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="
> >> http://www.w3.org/2001/XMLSchema" xmlns:xsi="
> >> http://www.w3.org/2001/XMLSchema-instance">
> >>     <soap:Body>
> >>         <ns1:calculateProductPrice>
> >>             <ns1:map-Map soapenc:arrayType="soapenc:Array[3]"
> >> xsi:type="soapenc:Array">
> >>                 <ns1:map-Entry soapenc:arrayType="xsd:anyType[2]"
> >> xsi:type="soapenc:Array">
> >>                     <ns1:map-Key>
> >>                         <ns1:std-String value="login.username" />
> >>                     </ns1:map-Key>
> >>                     <ns1:map-Value>
> >>                         <ns1:std-String value="admin" />
> >>                     </ns1:map-Value>
> >>                 </ns1:map-Entry>
> >>                 <ns1:map-Entry soapenc:arrayType="xsd:anyType[2]"
> >> xsi:type="soapenc:Array">
> >>                     <ns1:map-Key>
> >>                         <ns1:std-String value="login.password" />
> >>                     </ns1:map-Key>
> >>                     <ns1:map-Value>
> >>                         <ns1:std-String value="ofbiz" />
> >>                     </ns1:map-Value>
> >>                 </ns1:map-Entry>
> >>                 <ns1:map-Entry soapenc:arrayType="xsd:anyType[2]"
> >> xsi:type="soapenc:Array">
> >>                     <ns1:map-Key>
> >>                         <ns1:std-String value="product" />
> >>                     </ns1:map-Key>
> >>                     <ns1:map-Value>
> >>                         <ns1:map-Map>
> >>                             <ns1:map-Entry
> >> soapenc:arrayType="xsd:anyType[2]" xsi:type="soapenc:Array">
> >>                                 <ns1:map-Key>
> >>                                     <ns1:std-String value="productId" />
> >>                                 </ns1:map-Key>
> >>                                 <ns1:map-Value>
> >>                                     <ns1:std-String
> value="PROD_SY87B9B8MY"
> >> />
> >>                                 </ns1:map-Value>
> >>                             </ns1:map-Entry>
> >>                         </ns1:map-Map>
> >>                     </ns1:map-Value>
> >>                 </ns1:map-Entry>
> >>             </ns1:map-Map>
> >>         </ns1:calculateProductPrice>
> >>     </soap:Body>
> >> </soap:Envelope>
> >>
> >> <!-- end of soap -->
> >>
> >> 2018-03-24 00:08:15,421 |http-nio-8443-exec-2
> >> |ModelService                  |E| [ModelService.validate] :
> >> {calculateProductPrice} : (IN) Required test error:
> >> org.apache.ofbiz.service.ServiceValidationException: Type check failed
> for
> >> field [calculateProductPrice.product]; expected type is
> >> [org.apache.ofbiz.entity.GenericValue]; actual type is
> [java.util.HashMap]
> >> 2018-03-24 00:08:15,421 |http-nio-8443-exec-2
> >> |ServiceDispatcher             |E| Incoming context (in runSync :
> >> calculateProductPrice) does not match expected requirements
> >> org.apache.ofbiz.service.ServiceValidationException: Type check failed
> for
> >> field [calculateProductPrice.product]; expected type is
> >> [org.apache.ofbiz.entity.GenericValue]; actual type is
> [java.util.HashMap]
> >>
> >>
> >>
> >> regds
> >> mallah.
> >>
> >>
> >>
> >> On Fri, Mar 23, 2018 at 3:43 PM, Rajesh Mallah <mallah.rajesh@gmail.com
> >
> >> wrote:
> >>
> >> >
> >> > Hello Taher ,
> >> >
> >> > As suggested i shifted this discussion to the user list from dev.
> >> >
> >> > As you expected the product key has a value which is a
> >> > struct. This maps to java.util.HashMap but the validator
> >> > expects it to be a GenericValue and hence it does not hands it over
> >> > to the service.
> >> >
> >> >
> >> > $ ./007-get-price.pl  PROD_SY87B9B8MY
> >> > 2018/03/23 15:34:31 ------------------------------
> >> > --------------------------------------------------
> >> > 2018/03/23 15:34:31 REQ  >>>>>>>>>   <?xml version="1.0"
> >> encoding="UTF-8"?>
> >> > REQ  >>>>>>>>>   <methodCall>
> >> > REQ  >>>>>>>>>     <methodName>calculateProductPrice</methodName>
> >> > REQ  >>>>>>>>>     <params>
> >> > REQ  >>>>>>>>>       <param>
> >> > REQ  >>>>>>>>>         <value>
> >> > REQ  >>>>>>>>>          <struct>
> >> > REQ  >>>>>>>>>            <member>
> >> > REQ  >>>>>>>>>              <name>login.password</name>
> >> > REQ  >>>>>>>>>              <value>
> >> > REQ  >>>>>>>>>                <string><![CDATA[ofbiz]]></string>
> >> > REQ  >>>>>>>>>              </value>
> >> > REQ  >>>>>>>>>            </member>
> >> > REQ  >>>>>>>>>            <member>
> >> > REQ  >>>>>>>>>              <name>product</name>
> >> > REQ  >>>>>>>>>              <value>
> >> > REQ  >>>>>>>>>                <struct>
> >> > REQ  >>>>>>>>>                  <member>
> >> > REQ  >>>>>>>>>                    <name>productId</name>
> >> > REQ  >>>>>>>>>                    <value>
> >> > REQ  >>>>>>>>>                      <string><![CDATA[PROD_
> >> > SY87B9B8MY]]></string>
> >> > REQ  >>>>>>>>>                    </value>
> >> > REQ  >>>>>>>>>                  </member>
> >> > REQ  >>>>>>>>>                </struct>
> >> > REQ  >>>>>>>>>              </value>
> >> > REQ  >>>>>>>>>            </member>
> >> > REQ  >>>>>>>>>            <member>
> >> > REQ  >>>>>>>>>              <name>login.username</name>
> >> > REQ  >>>>>>>>>              <value>
> >> > REQ  >>>>>>>>>                <string><![CDATA[admin]]></string>
> >> > REQ  >>>>>>>>>              </value>
> >> > REQ  >>>>>>>>>            </member>
> >> > REQ  >>>>>>>>>          </struct>
> >> > REQ  >>>>>>>>>         </value>
> >> > REQ  >>>>>>>>>       </param>
> >> > REQ  >>>>>>>>>     </params>
> >> > REQ  >>>>>>>>>   </methodCall>
> >> > 2018/03/23 15:34:31 ------------------------------
> >> > --------------------------------------------------
> >> > 2018/03/23 15:34:31 ------------------------------
> >> > --------------------------------------------------
> >> > 2018/03/23 15:34:31 RES  <<<<<<<<<   <?xml version="1.0"
> >> encoding="UTF-8"?>
> >> > RES  <<<<<<<<<   <methodResponse
> >> > RES  <<<<<<<<<     xmlns:ex="http://ws.apache.org/xmlrpc/namespaces/
> >> > extensions">
> >> > RES  <<<<<<<<<     <fault>
> >> > RES  <<<<<<<<<       <value>
> >> > RES  <<<<<<<<<         <struct>
> >> > RES  <<<<<<<<<          <member>
> >> > RES  <<<<<<<<<            <name>faultCode</name>
> >> > RES  <<<<<<<<<            <value>
> >> > RES  <<<<<<<<<              <i4>0</i4>
> >> > RES  <<<<<<<<<            </value>
> >> > RES  <<<<<<<<<          </member>
> >> > RES  <<<<<<<<<          <member>
> >> > RES  <<<<<<<<<            <name>faultString</name>
> >> > RES  <<<<<<<<<            <value>Type check failed for field
> >> > RES  <<<<<<<<<              [calculateProductPrice.product]; expected
> >> > type is
> >> > RES  <<<<<<<<<              [org.apache.ofbiz.entity.GenericValue];
> >> > actual type is
> >> > RES  <<<<<<<<<              [java.util.HashMap]</value>
> >> > RES  <<<<<<<<<          </member>
> >> > RES  <<<<<<<<<         </struct>
> >> > RES  <<<<<<<<<       </value>
> >> > RES  <<<<<<<<<     </fault>
> >> > RES  <<<<<<<<<   </methodResponse>
> >> > 2018/03/23 15:34:31 ------------------------------
> >> > --------------------------------------------------
> >> > Service: calculateProductPrice faultString:Type check failed for field
> >> > [calculateProductPrice.product]; expected type is
> >> > [org.apache.ofbiz.entity.GenericValue]; actual type is
> >> [java.util.HashMap]
> >> >
> >> > ========================================
> >> > $ cat 007-get-price.pl
> >> >
> >> > #!/usr/bin/perl
> >> >
> >> > use OFBizClient;
> >> >
> >> > my $ofbiz_client = OFBizClient->new(
> >> >                                 url => 'https://your_ofbiz_server_
> >> > here/webtools/control/xmlrpc' ,
> >> >                                 username=>'admin'  ,
> >> >                                 password => 'ofbiz'
> >> > );
> >> >
> >> > my $productId = 'PROD_SY87B9B8MY';
> >> > $ofbiz_client->call('calculateProductPrice' , { product => {
> productId
> >> > =>  $productId }   } );
> >> >
> >> > ========================================
> >> >
> >> >
> >> >
> >>
>

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

Posted by Taher Alkhateeb <sl...@gmail.com>.
Thinking out loud, maybe one solution in here is to update the logic
in ModelService such that a map is automatically casted to a
GenericValue, or any object that is "instanceOf" would pass through.
The problem of course is how to carry "state" in these objects, which
is the reason why I dislike passing objects to services.

So another question, I see both SOAP and XML-RPC messages here, but
how are you invoking them? Is it just a simple URL or what?

On Sat, Mar 24, 2018 at 11:51 AM, Rishi Solanki <ri...@gmail.com> wrote:
> Hi Rajesh,
> SOAP request or XMLRPC request both uses the standard format conversion
> basic/regular java supports. That means if you are sending bunch of key
> value pair wrt a key ... in your case key is product. Then it will always
> convert it into the Map. So what general practices followed for xml data
> exchange is already exists.
>
> To have generic value or any other class value in your service IN
> parameter, you may need to add converter before passing it to service for
> invoke. That means, your checkMap method must be enabled for this type of
> conversion. Also this method will be invoked on IN parameter type. Please
> see XmlRpcEventHandler.getContext() for more details.
>
> This should be quick one and should resolve your problem, which enable the
> conversion of target type. A generic approach also welcome for
> contribution. :-)
>
> HTH!
>
> Regards,
> --
>
> Rishi Solanki
> Sr Manager, Enterprise Software Development
> HotWax Systems Pvt. Ltd.
> Direct: +91-9893287847
> http://www.hotwaxsystems.com
> www.hotwax.co
>
> On Sat, Mar 24, 2018 at 12:17 AM, Rajesh Mallah <ma...@gmail.com>
> wrote:
>
>> Hi Jacques / List  ,
>>
>> I face the very same problem with SOAP too , pls have a look if the SOAP
>> message is OK. Please suggest any edits to the SOAP message which i may
>> try.
>>
>>
>> <!-- start of soap -->
>>
>> <?xml version="1.0" encoding="UTF-8"?>
>> <soap:Envelope soap:encodingStyle="http://schemas.xmlsoap.org/soap/
>> encoding/"
>> xmlns:ns1="http://ofbiz.apache.org/service/" xmlns:soap="
>> http://schemas.xmlsoap.org/soap/envelope/" xmlns:soapenc="
>> http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="
>> http://www.w3.org/2001/XMLSchema" xmlns:xsi="
>> http://www.w3.org/2001/XMLSchema-instance">
>>     <soap:Body>
>>         <ns1:calculateProductPrice>
>>             <ns1:map-Map soapenc:arrayType="soapenc:Array[3]"
>> xsi:type="soapenc:Array">
>>                 <ns1:map-Entry soapenc:arrayType="xsd:anyType[2]"
>> xsi:type="soapenc:Array">
>>                     <ns1:map-Key>
>>                         <ns1:std-String value="login.username" />
>>                     </ns1:map-Key>
>>                     <ns1:map-Value>
>>                         <ns1:std-String value="admin" />
>>                     </ns1:map-Value>
>>                 </ns1:map-Entry>
>>                 <ns1:map-Entry soapenc:arrayType="xsd:anyType[2]"
>> xsi:type="soapenc:Array">
>>                     <ns1:map-Key>
>>                         <ns1:std-String value="login.password" />
>>                     </ns1:map-Key>
>>                     <ns1:map-Value>
>>                         <ns1:std-String value="ofbiz" />
>>                     </ns1:map-Value>
>>                 </ns1:map-Entry>
>>                 <ns1:map-Entry soapenc:arrayType="xsd:anyType[2]"
>> xsi:type="soapenc:Array">
>>                     <ns1:map-Key>
>>                         <ns1:std-String value="product" />
>>                     </ns1:map-Key>
>>                     <ns1:map-Value>
>>                         <ns1:map-Map>
>>                             <ns1:map-Entry
>> soapenc:arrayType="xsd:anyType[2]" xsi:type="soapenc:Array">
>>                                 <ns1:map-Key>
>>                                     <ns1:std-String value="productId" />
>>                                 </ns1:map-Key>
>>                                 <ns1:map-Value>
>>                                     <ns1:std-String value="PROD_SY87B9B8MY"
>> />
>>                                 </ns1:map-Value>
>>                             </ns1:map-Entry>
>>                         </ns1:map-Map>
>>                     </ns1:map-Value>
>>                 </ns1:map-Entry>
>>             </ns1:map-Map>
>>         </ns1:calculateProductPrice>
>>     </soap:Body>
>> </soap:Envelope>
>>
>> <!-- end of soap -->
>>
>> 2018-03-24 00:08:15,421 |http-nio-8443-exec-2
>> |ModelService                  |E| [ModelService.validate] :
>> {calculateProductPrice} : (IN) Required test error:
>> org.apache.ofbiz.service.ServiceValidationException: Type check failed for
>> field [calculateProductPrice.product]; expected type is
>> [org.apache.ofbiz.entity.GenericValue]; actual type is [java.util.HashMap]
>> 2018-03-24 00:08:15,421 |http-nio-8443-exec-2
>> |ServiceDispatcher             |E| Incoming context (in runSync :
>> calculateProductPrice) does not match expected requirements
>> org.apache.ofbiz.service.ServiceValidationException: Type check failed for
>> field [calculateProductPrice.product]; expected type is
>> [org.apache.ofbiz.entity.GenericValue]; actual type is [java.util.HashMap]
>>
>>
>>
>> regds
>> mallah.
>>
>>
>>
>> On Fri, Mar 23, 2018 at 3:43 PM, Rajesh Mallah <ma...@gmail.com>
>> wrote:
>>
>> >
>> > Hello Taher ,
>> >
>> > As suggested i shifted this discussion to the user list from dev.
>> >
>> > As you expected the product key has a value which is a
>> > struct. This maps to java.util.HashMap but the validator
>> > expects it to be a GenericValue and hence it does not hands it over
>> > to the service.
>> >
>> >
>> > $ ./007-get-price.pl  PROD_SY87B9B8MY
>> > 2018/03/23 15:34:31 ------------------------------
>> > --------------------------------------------------
>> > 2018/03/23 15:34:31 REQ  >>>>>>>>>   <?xml version="1.0"
>> encoding="UTF-8"?>
>> > REQ  >>>>>>>>>   <methodCall>
>> > REQ  >>>>>>>>>     <methodName>calculateProductPrice</methodName>
>> > REQ  >>>>>>>>>     <params>
>> > REQ  >>>>>>>>>       <param>
>> > REQ  >>>>>>>>>         <value>
>> > REQ  >>>>>>>>>          <struct>
>> > REQ  >>>>>>>>>            <member>
>> > REQ  >>>>>>>>>              <name>login.password</name>
>> > REQ  >>>>>>>>>              <value>
>> > REQ  >>>>>>>>>                <string><![CDATA[ofbiz]]></string>
>> > REQ  >>>>>>>>>              </value>
>> > REQ  >>>>>>>>>            </member>
>> > REQ  >>>>>>>>>            <member>
>> > REQ  >>>>>>>>>              <name>product</name>
>> > REQ  >>>>>>>>>              <value>
>> > REQ  >>>>>>>>>                <struct>
>> > REQ  >>>>>>>>>                  <member>
>> > REQ  >>>>>>>>>                    <name>productId</name>
>> > REQ  >>>>>>>>>                    <value>
>> > REQ  >>>>>>>>>                      <string><![CDATA[PROD_
>> > SY87B9B8MY]]></string>
>> > REQ  >>>>>>>>>                    </value>
>> > REQ  >>>>>>>>>                  </member>
>> > REQ  >>>>>>>>>                </struct>
>> > REQ  >>>>>>>>>              </value>
>> > REQ  >>>>>>>>>            </member>
>> > REQ  >>>>>>>>>            <member>
>> > REQ  >>>>>>>>>              <name>login.username</name>
>> > REQ  >>>>>>>>>              <value>
>> > REQ  >>>>>>>>>                <string><![CDATA[admin]]></string>
>> > REQ  >>>>>>>>>              </value>
>> > REQ  >>>>>>>>>            </member>
>> > REQ  >>>>>>>>>          </struct>
>> > REQ  >>>>>>>>>         </value>
>> > REQ  >>>>>>>>>       </param>
>> > REQ  >>>>>>>>>     </params>
>> > REQ  >>>>>>>>>   </methodCall>
>> > 2018/03/23 15:34:31 ------------------------------
>> > --------------------------------------------------
>> > 2018/03/23 15:34:31 ------------------------------
>> > --------------------------------------------------
>> > 2018/03/23 15:34:31 RES  <<<<<<<<<   <?xml version="1.0"
>> encoding="UTF-8"?>
>> > RES  <<<<<<<<<   <methodResponse
>> > RES  <<<<<<<<<     xmlns:ex="http://ws.apache.org/xmlrpc/namespaces/
>> > extensions">
>> > RES  <<<<<<<<<     <fault>
>> > RES  <<<<<<<<<       <value>
>> > RES  <<<<<<<<<         <struct>
>> > RES  <<<<<<<<<          <member>
>> > RES  <<<<<<<<<            <name>faultCode</name>
>> > RES  <<<<<<<<<            <value>
>> > RES  <<<<<<<<<              <i4>0</i4>
>> > RES  <<<<<<<<<            </value>
>> > RES  <<<<<<<<<          </member>
>> > RES  <<<<<<<<<          <member>
>> > RES  <<<<<<<<<            <name>faultString</name>
>> > RES  <<<<<<<<<            <value>Type check failed for field
>> > RES  <<<<<<<<<              [calculateProductPrice.product]; expected
>> > type is
>> > RES  <<<<<<<<<              [org.apache.ofbiz.entity.GenericValue];
>> > actual type is
>> > RES  <<<<<<<<<              [java.util.HashMap]</value>
>> > RES  <<<<<<<<<          </member>
>> > RES  <<<<<<<<<         </struct>
>> > RES  <<<<<<<<<       </value>
>> > RES  <<<<<<<<<     </fault>
>> > RES  <<<<<<<<<   </methodResponse>
>> > 2018/03/23 15:34:31 ------------------------------
>> > --------------------------------------------------
>> > Service: calculateProductPrice faultString:Type check failed for field
>> > [calculateProductPrice.product]; expected type is
>> > [org.apache.ofbiz.entity.GenericValue]; actual type is
>> [java.util.HashMap]
>> >
>> > ========================================
>> > $ cat 007-get-price.pl
>> >
>> > #!/usr/bin/perl
>> >
>> > use OFBizClient;
>> >
>> > my $ofbiz_client = OFBizClient->new(
>> >                                 url => 'https://your_ofbiz_server_
>> > here/webtools/control/xmlrpc' ,
>> >                                 username=>'admin'  ,
>> >                                 password => 'ofbiz'
>> > );
>> >
>> > my $productId = 'PROD_SY87B9B8MY';
>> > $ofbiz_client->call('calculateProductPrice' , { product => { productId
>> > =>  $productId }   } );
>> >
>> > ========================================
>> >
>> >
>> >
>>

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

Posted by Jacques Le Roux <ja...@les7arts.com>.
Thanks Rishi,

I also checked yesterday and I agree with you, SOAP is not doing more for that.

Jacques


Le 24/03/2018 à 09:51, Rishi Solanki a écrit :
> Hi Rajesh,
> SOAP request or XMLRPC request both uses the standard format conversion
> basic/regular java supports. That means if you are sending bunch of key
> value pair wrt a key ... in your case key is product. Then it will always
> convert it into the Map. So what general practices followed for xml data
> exchange is already exists.
>
> To have generic value or any other class value in your service IN
> parameter, you may need to add converter before passing it to service for
> invoke. That means, your checkMap method must be enabled for this type of
> conversion. Also this method will be invoked on IN parameter type. Please
> see XmlRpcEventHandler.getContext() for more details.
>
> This should be quick one and should resolve your problem, which enable the
> conversion of target type. A generic approach also welcome for
> contribution. :-)
>
> HTH!
>
> Regards,
> --
>
> Rishi Solanki
> Sr Manager, Enterprise Software Development
> HotWax Systems Pvt. Ltd.
> Direct: +91-9893287847
> http://www.hotwaxsystems.com
> www.hotwax.co
>
> On Sat, Mar 24, 2018 at 12:17 AM, Rajesh Mallah <ma...@gmail.com>
> wrote:
>
>> Hi Jacques / List  ,
>>
>> I face the very same problem with SOAP too , pls have a look if the SOAP
>> message is OK. Please suggest any edits to the SOAP message which i may
>> try.
>>
>>
>> <!-- start of soap -->
>>
>> <?xml version="1.0" encoding="UTF-8"?>
>> <soap:Envelope soap:encodingStyle="http://schemas.xmlsoap.org/soap/
>> encoding/"
>> xmlns:ns1="http://ofbiz.apache.org/service/" xmlns:soap="
>> http://schemas.xmlsoap.org/soap/envelope/" xmlns:soapenc="
>> http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="
>> http://www.w3.org/2001/XMLSchema" xmlns:xsi="
>> http://www.w3.org/2001/XMLSchema-instance">
>>      <soap:Body>
>>          <ns1:calculateProductPrice>
>>              <ns1:map-Map soapenc:arrayType="soapenc:Array[3]"
>> xsi:type="soapenc:Array">
>>                  <ns1:map-Entry soapenc:arrayType="xsd:anyType[2]"
>> xsi:type="soapenc:Array">
>>                      <ns1:map-Key>
>>                          <ns1:std-String value="login.username" />
>>                      </ns1:map-Key>
>>                      <ns1:map-Value>
>>                          <ns1:std-String value="admin" />
>>                      </ns1:map-Value>
>>                  </ns1:map-Entry>
>>                  <ns1:map-Entry soapenc:arrayType="xsd:anyType[2]"
>> xsi:type="soapenc:Array">
>>                      <ns1:map-Key>
>>                          <ns1:std-String value="login.password" />
>>                      </ns1:map-Key>
>>                      <ns1:map-Value>
>>                          <ns1:std-String value="ofbiz" />
>>                      </ns1:map-Value>
>>                  </ns1:map-Entry>
>>                  <ns1:map-Entry soapenc:arrayType="xsd:anyType[2]"
>> xsi:type="soapenc:Array">
>>                      <ns1:map-Key>
>>                          <ns1:std-String value="product" />
>>                      </ns1:map-Key>
>>                      <ns1:map-Value>
>>                          <ns1:map-Map>
>>                              <ns1:map-Entry
>> soapenc:arrayType="xsd:anyType[2]" xsi:type="soapenc:Array">
>>                                  <ns1:map-Key>
>>                                      <ns1:std-String value="productId" />
>>                                  </ns1:map-Key>
>>                                  <ns1:map-Value>
>>                                      <ns1:std-String value="PROD_SY87B9B8MY"
>> />
>>                                  </ns1:map-Value>
>>                              </ns1:map-Entry>
>>                          </ns1:map-Map>
>>                      </ns1:map-Value>
>>                  </ns1:map-Entry>
>>              </ns1:map-Map>
>>          </ns1:calculateProductPrice>
>>      </soap:Body>
>> </soap:Envelope>
>>
>> <!-- end of soap -->
>>
>> 2018-03-24 00:08:15,421 |http-nio-8443-exec-2
>> |ModelService                  |E| [ModelService.validate] :
>> {calculateProductPrice} : (IN) Required test error:
>> org.apache.ofbiz.service.ServiceValidationException: Type check failed for
>> field [calculateProductPrice.product]; expected type is
>> [org.apache.ofbiz.entity.GenericValue]; actual type is [java.util.HashMap]
>> 2018-03-24 00:08:15,421 |http-nio-8443-exec-2
>> |ServiceDispatcher             |E| Incoming context (in runSync :
>> calculateProductPrice) does not match expected requirements
>> org.apache.ofbiz.service.ServiceValidationException: Type check failed for
>> field [calculateProductPrice.product]; expected type is
>> [org.apache.ofbiz.entity.GenericValue]; actual type is [java.util.HashMap]
>>
>>
>>
>> regds
>> mallah.
>>
>>
>>
>> On Fri, Mar 23, 2018 at 3:43 PM, Rajesh Mallah <ma...@gmail.com>
>> wrote:
>>
>>> Hello Taher ,
>>>
>>> As suggested i shifted this discussion to the user list from dev.
>>>
>>> As you expected the product key has a value which is a
>>> struct. This maps to java.util.HashMap but the validator
>>> expects it to be a GenericValue and hence it does not hands it over
>>> to the service.
>>>
>>>
>>> $ ./007-get-price.pl  PROD_SY87B9B8MY
>>> 2018/03/23 15:34:31 ------------------------------
>>> --------------------------------------------------
>>> 2018/03/23 15:34:31 REQ  >>>>>>>>>   <?xml version="1.0"
>> encoding="UTF-8"?>
>>> REQ  >>>>>>>>>   <methodCall>
>>> REQ  >>>>>>>>>     <methodName>calculateProductPrice</methodName>
>>> REQ  >>>>>>>>>     <params>
>>> REQ  >>>>>>>>>       <param>
>>> REQ  >>>>>>>>>         <value>
>>> REQ  >>>>>>>>>          <struct>
>>> REQ  >>>>>>>>>            <member>
>>> REQ  >>>>>>>>>              <name>login.password</name>
>>> REQ  >>>>>>>>>              <value>
>>> REQ  >>>>>>>>>                <string><![CDATA[ofbiz]]></string>
>>> REQ  >>>>>>>>>              </value>
>>> REQ  >>>>>>>>>            </member>
>>> REQ  >>>>>>>>>            <member>
>>> REQ  >>>>>>>>>              <name>product</name>
>>> REQ  >>>>>>>>>              <value>
>>> REQ  >>>>>>>>>                <struct>
>>> REQ  >>>>>>>>>                  <member>
>>> REQ  >>>>>>>>>                    <name>productId</name>
>>> REQ  >>>>>>>>>                    <value>
>>> REQ  >>>>>>>>>                      <string><![CDATA[PROD_
>>> SY87B9B8MY]]></string>
>>> REQ  >>>>>>>>>                    </value>
>>> REQ  >>>>>>>>>                  </member>
>>> REQ  >>>>>>>>>                </struct>
>>> REQ  >>>>>>>>>              </value>
>>> REQ  >>>>>>>>>            </member>
>>> REQ  >>>>>>>>>            <member>
>>> REQ  >>>>>>>>>              <name>login.username</name>
>>> REQ  >>>>>>>>>              <value>
>>> REQ  >>>>>>>>>                <string><![CDATA[admin]]></string>
>>> REQ  >>>>>>>>>              </value>
>>> REQ  >>>>>>>>>            </member>
>>> REQ  >>>>>>>>>          </struct>
>>> REQ  >>>>>>>>>         </value>
>>> REQ  >>>>>>>>>       </param>
>>> REQ  >>>>>>>>>     </params>
>>> REQ  >>>>>>>>>   </methodCall>
>>> 2018/03/23 15:34:31 ------------------------------
>>> --------------------------------------------------
>>> 2018/03/23 15:34:31 ------------------------------
>>> --------------------------------------------------
>>> 2018/03/23 15:34:31 RES  <<<<<<<<<   <?xml version="1.0"
>> encoding="UTF-8"?>
>>> RES  <<<<<<<<<   <methodResponse
>>> RES  <<<<<<<<<     xmlns:ex="http://ws.apache.org/xmlrpc/namespaces/
>>> extensions">
>>> RES  <<<<<<<<<     <fault>
>>> RES  <<<<<<<<<       <value>
>>> RES  <<<<<<<<<         <struct>
>>> RES  <<<<<<<<<          <member>
>>> RES  <<<<<<<<<            <name>faultCode</name>
>>> RES  <<<<<<<<<            <value>
>>> RES  <<<<<<<<<              <i4>0</i4>
>>> RES  <<<<<<<<<            </value>
>>> RES  <<<<<<<<<          </member>
>>> RES  <<<<<<<<<          <member>
>>> RES  <<<<<<<<<            <name>faultString</name>
>>> RES  <<<<<<<<<            <value>Type check failed for field
>>> RES  <<<<<<<<<              [calculateProductPrice.product]; expected
>>> type is
>>> RES  <<<<<<<<<              [org.apache.ofbiz.entity.GenericValue];
>>> actual type is
>>> RES  <<<<<<<<<              [java.util.HashMap]</value>
>>> RES  <<<<<<<<<          </member>
>>> RES  <<<<<<<<<         </struct>
>>> RES  <<<<<<<<<       </value>
>>> RES  <<<<<<<<<     </fault>
>>> RES  <<<<<<<<<   </methodResponse>
>>> 2018/03/23 15:34:31 ------------------------------
>>> --------------------------------------------------
>>> Service: calculateProductPrice faultString:Type check failed for field
>>> [calculateProductPrice.product]; expected type is
>>> [org.apache.ofbiz.entity.GenericValue]; actual type is
>> [java.util.HashMap]
>>> ========================================
>>> $ cat 007-get-price.pl
>>>
>>> #!/usr/bin/perl
>>>
>>> use OFBizClient;
>>>
>>> my $ofbiz_client = OFBizClient->new(
>>>                                  url => 'https://your_ofbiz_server_
>>> here/webtools/control/xmlrpc' ,
>>>                                  username=>'admin'  ,
>>>                                  password => 'ofbiz'
>>> );
>>>
>>> my $productId = 'PROD_SY87B9B8MY';
>>> $ofbiz_client->call('calculateProductPrice' , { product => { productId
>>> =>  $productId }   } );
>>>
>>> ========================================
>>>
>>>
>>>


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

Posted by Rishi Solanki <ri...@gmail.com>.
Hi Rajesh,
SOAP request or XMLRPC request both uses the standard format conversion
basic/regular java supports. That means if you are sending bunch of key
value pair wrt a key ... in your case key is product. Then it will always
convert it into the Map. So what general practices followed for xml data
exchange is already exists.

To have generic value or any other class value in your service IN
parameter, you may need to add converter before passing it to service for
invoke. That means, your checkMap method must be enabled for this type of
conversion. Also this method will be invoked on IN parameter type. Please
see XmlRpcEventHandler.getContext() for more details.

This should be quick one and should resolve your problem, which enable the
conversion of target type. A generic approach also welcome for
contribution. :-)

HTH!

Regards,
--

Rishi Solanki
Sr Manager, Enterprise Software Development
HotWax Systems Pvt. Ltd.
Direct: +91-9893287847
http://www.hotwaxsystems.com
www.hotwax.co

On Sat, Mar 24, 2018 at 12:17 AM, Rajesh Mallah <ma...@gmail.com>
wrote:

> Hi Jacques / List  ,
>
> I face the very same problem with SOAP too , pls have a look if the SOAP
> message is OK. Please suggest any edits to the SOAP message which i may
> try.
>
>
> <!-- start of soap -->
>
> <?xml version="1.0" encoding="UTF-8"?>
> <soap:Envelope soap:encodingStyle="http://schemas.xmlsoap.org/soap/
> encoding/"
> xmlns:ns1="http://ofbiz.apache.org/service/" xmlns:soap="
> http://schemas.xmlsoap.org/soap/envelope/" xmlns:soapenc="
> http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="
> http://www.w3.org/2001/XMLSchema" xmlns:xsi="
> http://www.w3.org/2001/XMLSchema-instance">
>     <soap:Body>
>         <ns1:calculateProductPrice>
>             <ns1:map-Map soapenc:arrayType="soapenc:Array[3]"
> xsi:type="soapenc:Array">
>                 <ns1:map-Entry soapenc:arrayType="xsd:anyType[2]"
> xsi:type="soapenc:Array">
>                     <ns1:map-Key>
>                         <ns1:std-String value="login.username" />
>                     </ns1:map-Key>
>                     <ns1:map-Value>
>                         <ns1:std-String value="admin" />
>                     </ns1:map-Value>
>                 </ns1:map-Entry>
>                 <ns1:map-Entry soapenc:arrayType="xsd:anyType[2]"
> xsi:type="soapenc:Array">
>                     <ns1:map-Key>
>                         <ns1:std-String value="login.password" />
>                     </ns1:map-Key>
>                     <ns1:map-Value>
>                         <ns1:std-String value="ofbiz" />
>                     </ns1:map-Value>
>                 </ns1:map-Entry>
>                 <ns1:map-Entry soapenc:arrayType="xsd:anyType[2]"
> xsi:type="soapenc:Array">
>                     <ns1:map-Key>
>                         <ns1:std-String value="product" />
>                     </ns1:map-Key>
>                     <ns1:map-Value>
>                         <ns1:map-Map>
>                             <ns1:map-Entry
> soapenc:arrayType="xsd:anyType[2]" xsi:type="soapenc:Array">
>                                 <ns1:map-Key>
>                                     <ns1:std-String value="productId" />
>                                 </ns1:map-Key>
>                                 <ns1:map-Value>
>                                     <ns1:std-String value="PROD_SY87B9B8MY"
> />
>                                 </ns1:map-Value>
>                             </ns1:map-Entry>
>                         </ns1:map-Map>
>                     </ns1:map-Value>
>                 </ns1:map-Entry>
>             </ns1:map-Map>
>         </ns1:calculateProductPrice>
>     </soap:Body>
> </soap:Envelope>
>
> <!-- end of soap -->
>
> 2018-03-24 00:08:15,421 |http-nio-8443-exec-2
> |ModelService                  |E| [ModelService.validate] :
> {calculateProductPrice} : (IN) Required test error:
> org.apache.ofbiz.service.ServiceValidationException: Type check failed for
> field [calculateProductPrice.product]; expected type is
> [org.apache.ofbiz.entity.GenericValue]; actual type is [java.util.HashMap]
> 2018-03-24 00:08:15,421 |http-nio-8443-exec-2
> |ServiceDispatcher             |E| Incoming context (in runSync :
> calculateProductPrice) does not match expected requirements
> org.apache.ofbiz.service.ServiceValidationException: Type check failed for
> field [calculateProductPrice.product]; expected type is
> [org.apache.ofbiz.entity.GenericValue]; actual type is [java.util.HashMap]
>
>
>
> regds
> mallah.
>
>
>
> On Fri, Mar 23, 2018 at 3:43 PM, Rajesh Mallah <ma...@gmail.com>
> wrote:
>
> >
> > Hello Taher ,
> >
> > As suggested i shifted this discussion to the user list from dev.
> >
> > As you expected the product key has a value which is a
> > struct. This maps to java.util.HashMap but the validator
> > expects it to be a GenericValue and hence it does not hands it over
> > to the service.
> >
> >
> > $ ./007-get-price.pl  PROD_SY87B9B8MY
> > 2018/03/23 15:34:31 ------------------------------
> > --------------------------------------------------
> > 2018/03/23 15:34:31 REQ  >>>>>>>>>   <?xml version="1.0"
> encoding="UTF-8"?>
> > REQ  >>>>>>>>>   <methodCall>
> > REQ  >>>>>>>>>     <methodName>calculateProductPrice</methodName>
> > REQ  >>>>>>>>>     <params>
> > REQ  >>>>>>>>>       <param>
> > REQ  >>>>>>>>>         <value>
> > REQ  >>>>>>>>>          <struct>
> > REQ  >>>>>>>>>            <member>
> > REQ  >>>>>>>>>              <name>login.password</name>
> > REQ  >>>>>>>>>              <value>
> > REQ  >>>>>>>>>                <string><![CDATA[ofbiz]]></string>
> > REQ  >>>>>>>>>              </value>
> > REQ  >>>>>>>>>            </member>
> > REQ  >>>>>>>>>            <member>
> > REQ  >>>>>>>>>              <name>product</name>
> > REQ  >>>>>>>>>              <value>
> > REQ  >>>>>>>>>                <struct>
> > REQ  >>>>>>>>>                  <member>
> > REQ  >>>>>>>>>                    <name>productId</name>
> > REQ  >>>>>>>>>                    <value>
> > REQ  >>>>>>>>>                      <string><![CDATA[PROD_
> > SY87B9B8MY]]></string>
> > REQ  >>>>>>>>>                    </value>
> > REQ  >>>>>>>>>                  </member>
> > REQ  >>>>>>>>>                </struct>
> > REQ  >>>>>>>>>              </value>
> > REQ  >>>>>>>>>            </member>
> > REQ  >>>>>>>>>            <member>
> > REQ  >>>>>>>>>              <name>login.username</name>
> > REQ  >>>>>>>>>              <value>
> > REQ  >>>>>>>>>                <string><![CDATA[admin]]></string>
> > REQ  >>>>>>>>>              </value>
> > REQ  >>>>>>>>>            </member>
> > REQ  >>>>>>>>>          </struct>
> > REQ  >>>>>>>>>         </value>
> > REQ  >>>>>>>>>       </param>
> > REQ  >>>>>>>>>     </params>
> > REQ  >>>>>>>>>   </methodCall>
> > 2018/03/23 15:34:31 ------------------------------
> > --------------------------------------------------
> > 2018/03/23 15:34:31 ------------------------------
> > --------------------------------------------------
> > 2018/03/23 15:34:31 RES  <<<<<<<<<   <?xml version="1.0"
> encoding="UTF-8"?>
> > RES  <<<<<<<<<   <methodResponse
> > RES  <<<<<<<<<     xmlns:ex="http://ws.apache.org/xmlrpc/namespaces/
> > extensions">
> > RES  <<<<<<<<<     <fault>
> > RES  <<<<<<<<<       <value>
> > RES  <<<<<<<<<         <struct>
> > RES  <<<<<<<<<          <member>
> > RES  <<<<<<<<<            <name>faultCode</name>
> > RES  <<<<<<<<<            <value>
> > RES  <<<<<<<<<              <i4>0</i4>
> > RES  <<<<<<<<<            </value>
> > RES  <<<<<<<<<          </member>
> > RES  <<<<<<<<<          <member>
> > RES  <<<<<<<<<            <name>faultString</name>
> > RES  <<<<<<<<<            <value>Type check failed for field
> > RES  <<<<<<<<<              [calculateProductPrice.product]; expected
> > type is
> > RES  <<<<<<<<<              [org.apache.ofbiz.entity.GenericValue];
> > actual type is
> > RES  <<<<<<<<<              [java.util.HashMap]</value>
> > RES  <<<<<<<<<          </member>
> > RES  <<<<<<<<<         </struct>
> > RES  <<<<<<<<<       </value>
> > RES  <<<<<<<<<     </fault>
> > RES  <<<<<<<<<   </methodResponse>
> > 2018/03/23 15:34:31 ------------------------------
> > --------------------------------------------------
> > Service: calculateProductPrice faultString:Type check failed for field
> > [calculateProductPrice.product]; expected type is
> > [org.apache.ofbiz.entity.GenericValue]; actual type is
> [java.util.HashMap]
> >
> > ========================================
> > $ cat 007-get-price.pl
> >
> > #!/usr/bin/perl
> >
> > use OFBizClient;
> >
> > my $ofbiz_client = OFBizClient->new(
> >                                 url => 'https://your_ofbiz_server_
> > here/webtools/control/xmlrpc' ,
> >                                 username=>'admin'  ,
> >                                 password => 'ofbiz'
> > );
> >
> > my $productId = 'PROD_SY87B9B8MY';
> > $ofbiz_client->call('calculateProductPrice' , { product => { productId
> > =>  $productId }   } );
> >
> > ========================================
> >
> >
> >
>

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

Posted by Rajesh Mallah <ma...@gmail.com>.
Hi Jacques / List  ,

I face the very same problem with SOAP too , pls have a look if the SOAP
message is OK. Please suggest any edits to the SOAP message which i may
try.


<!-- start of soap -->

<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:ns1="http://ofbiz.apache.org/service/" xmlns:soap="
http://schemas.xmlsoap.org/soap/envelope/" xmlns:soapenc="
http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="
http://www.w3.org/2001/XMLSchema" xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance">
    <soap:Body>
        <ns1:calculateProductPrice>
            <ns1:map-Map soapenc:arrayType="soapenc:Array[3]"
xsi:type="soapenc:Array">
                <ns1:map-Entry soapenc:arrayType="xsd:anyType[2]"
xsi:type="soapenc:Array">
                    <ns1:map-Key>
                        <ns1:std-String value="login.username" />
                    </ns1:map-Key>
                    <ns1:map-Value>
                        <ns1:std-String value="admin" />
                    </ns1:map-Value>
                </ns1:map-Entry>
                <ns1:map-Entry soapenc:arrayType="xsd:anyType[2]"
xsi:type="soapenc:Array">
                    <ns1:map-Key>
                        <ns1:std-String value="login.password" />
                    </ns1:map-Key>
                    <ns1:map-Value>
                        <ns1:std-String value="ofbiz" />
                    </ns1:map-Value>
                </ns1:map-Entry>
                <ns1:map-Entry soapenc:arrayType="xsd:anyType[2]"
xsi:type="soapenc:Array">
                    <ns1:map-Key>
                        <ns1:std-String value="product" />
                    </ns1:map-Key>
                    <ns1:map-Value>
                        <ns1:map-Map>
                            <ns1:map-Entry
soapenc:arrayType="xsd:anyType[2]" xsi:type="soapenc:Array">
                                <ns1:map-Key>
                                    <ns1:std-String value="productId" />
                                </ns1:map-Key>
                                <ns1:map-Value>
                                    <ns1:std-String value="PROD_SY87B9B8MY"
/>
                                </ns1:map-Value>
                            </ns1:map-Entry>
                        </ns1:map-Map>
                    </ns1:map-Value>
                </ns1:map-Entry>
            </ns1:map-Map>
        </ns1:calculateProductPrice>
    </soap:Body>
</soap:Envelope>

<!-- end of soap -->

2018-03-24 00:08:15,421 |http-nio-8443-exec-2
|ModelService                  |E| [ModelService.validate] :
{calculateProductPrice} : (IN) Required test error:
org.apache.ofbiz.service.ServiceValidationException: Type check failed for
field [calculateProductPrice.product]; expected type is
[org.apache.ofbiz.entity.GenericValue]; actual type is [java.util.HashMap]
2018-03-24 00:08:15,421 |http-nio-8443-exec-2
|ServiceDispatcher             |E| Incoming context (in runSync :
calculateProductPrice) does not match expected requirements
org.apache.ofbiz.service.ServiceValidationException: Type check failed for
field [calculateProductPrice.product]; expected type is
[org.apache.ofbiz.entity.GenericValue]; actual type is [java.util.HashMap]



regds
mallah.



On Fri, Mar 23, 2018 at 3:43 PM, Rajesh Mallah <ma...@gmail.com>
wrote:

>
> Hello Taher ,
>
> As suggested i shifted this discussion to the user list from dev.
>
> As you expected the product key has a value which is a
> struct. This maps to java.util.HashMap but the validator
> expects it to be a GenericValue and hence it does not hands it over
> to the service.
>
>
> $ ./007-get-price.pl  PROD_SY87B9B8MY
> 2018/03/23 15:34:31 ------------------------------
> --------------------------------------------------
> 2018/03/23 15:34:31 REQ  >>>>>>>>>   <?xml version="1.0" encoding="UTF-8"?>
> REQ  >>>>>>>>>   <methodCall>
> REQ  >>>>>>>>>     <methodName>calculateProductPrice</methodName>
> REQ  >>>>>>>>>     <params>
> REQ  >>>>>>>>>       <param>
> REQ  >>>>>>>>>         <value>
> REQ  >>>>>>>>>          <struct>
> REQ  >>>>>>>>>            <member>
> REQ  >>>>>>>>>              <name>login.password</name>
> REQ  >>>>>>>>>              <value>
> REQ  >>>>>>>>>                <string><![CDATA[ofbiz]]></string>
> REQ  >>>>>>>>>              </value>
> REQ  >>>>>>>>>            </member>
> REQ  >>>>>>>>>            <member>
> REQ  >>>>>>>>>              <name>product</name>
> REQ  >>>>>>>>>              <value>
> REQ  >>>>>>>>>                <struct>
> REQ  >>>>>>>>>                  <member>
> REQ  >>>>>>>>>                    <name>productId</name>
> REQ  >>>>>>>>>                    <value>
> REQ  >>>>>>>>>                      <string><![CDATA[PROD_
> SY87B9B8MY]]></string>
> REQ  >>>>>>>>>                    </value>
> REQ  >>>>>>>>>                  </member>
> REQ  >>>>>>>>>                </struct>
> REQ  >>>>>>>>>              </value>
> REQ  >>>>>>>>>            </member>
> REQ  >>>>>>>>>            <member>
> REQ  >>>>>>>>>              <name>login.username</name>
> REQ  >>>>>>>>>              <value>
> REQ  >>>>>>>>>                <string><![CDATA[admin]]></string>
> REQ  >>>>>>>>>              </value>
> REQ  >>>>>>>>>            </member>
> REQ  >>>>>>>>>          </struct>
> REQ  >>>>>>>>>         </value>
> REQ  >>>>>>>>>       </param>
> REQ  >>>>>>>>>     </params>
> REQ  >>>>>>>>>   </methodCall>
> 2018/03/23 15:34:31 ------------------------------
> --------------------------------------------------
> 2018/03/23 15:34:31 ------------------------------
> --------------------------------------------------
> 2018/03/23 15:34:31 RES  <<<<<<<<<   <?xml version="1.0" encoding="UTF-8"?>
> RES  <<<<<<<<<   <methodResponse
> RES  <<<<<<<<<     xmlns:ex="http://ws.apache.org/xmlrpc/namespaces/
> extensions">
> RES  <<<<<<<<<     <fault>
> RES  <<<<<<<<<       <value>
> RES  <<<<<<<<<         <struct>
> RES  <<<<<<<<<          <member>
> RES  <<<<<<<<<            <name>faultCode</name>
> RES  <<<<<<<<<            <value>
> RES  <<<<<<<<<              <i4>0</i4>
> RES  <<<<<<<<<            </value>
> RES  <<<<<<<<<          </member>
> RES  <<<<<<<<<          <member>
> RES  <<<<<<<<<            <name>faultString</name>
> RES  <<<<<<<<<            <value>Type check failed for field
> RES  <<<<<<<<<              [calculateProductPrice.product]; expected
> type is
> RES  <<<<<<<<<              [org.apache.ofbiz.entity.GenericValue];
> actual type is
> RES  <<<<<<<<<              [java.util.HashMap]</value>
> RES  <<<<<<<<<          </member>
> RES  <<<<<<<<<         </struct>
> RES  <<<<<<<<<       </value>
> RES  <<<<<<<<<     </fault>
> RES  <<<<<<<<<   </methodResponse>
> 2018/03/23 15:34:31 ------------------------------
> --------------------------------------------------
> Service: calculateProductPrice faultString:Type check failed for field
> [calculateProductPrice.product]; expected type is
> [org.apache.ofbiz.entity.GenericValue]; actual type is [java.util.HashMap]
>
> ========================================
> $ cat 007-get-price.pl
>
> #!/usr/bin/perl
>
> use OFBizClient;
>
> my $ofbiz_client = OFBizClient->new(
>                                 url => 'https://your_ofbiz_server_
> here/webtools/control/xmlrpc' ,
>                                 username=>'admin'  ,
>                                 password => 'ofbiz'
> );
>
> my $productId = 'PROD_SY87B9B8MY';
> $ofbiz_client->call('calculateProductPrice' , { product => { productId
> =>  $productId }   } );
>
> ========================================
>
>
>

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

Posted by Rajesh Mallah <ma...@gmail.com>.
Hello Taher ,

As suggested i shifted this discussion to the user list from dev.

As you expected the product key has a value which is a
struct. This maps to java.util.HashMap but the validator
expects it to be a GenericValue and hence it does not hands it over
to the service.


$ ./007-get-price.pl  PROD_SY87B9B8MY
2018/03/23 15:34:31
--------------------------------------------------------------------------------
2018/03/23 15:34:31 REQ  >>>>>>>>>   <?xml version="1.0" encoding="UTF-8"?>
REQ  >>>>>>>>>   <methodCall>
REQ  >>>>>>>>>     <methodName>calculateProductPrice</methodName>
REQ  >>>>>>>>>     <params>
REQ  >>>>>>>>>       <param>
REQ  >>>>>>>>>         <value>
REQ  >>>>>>>>>          <struct>
REQ  >>>>>>>>>            <member>
REQ  >>>>>>>>>              <name>login.password</name>
REQ  >>>>>>>>>              <value>
REQ  >>>>>>>>>                <string><![CDATA[ofbiz]]></string>
REQ  >>>>>>>>>              </value>
REQ  >>>>>>>>>            </member>
REQ  >>>>>>>>>            <member>
REQ  >>>>>>>>>              <name>product</name>
REQ  >>>>>>>>>              <value>
REQ  >>>>>>>>>                <struct>
REQ  >>>>>>>>>                  <member>
REQ  >>>>>>>>>                    <name>productId</name>
REQ  >>>>>>>>>                    <value>
REQ  >>>>>>>>>
<string><![CDATA[PROD_SY87B9B8MY]]></string>
REQ  >>>>>>>>>                    </value>
REQ  >>>>>>>>>                  </member>
REQ  >>>>>>>>>                </struct>
REQ  >>>>>>>>>              </value>
REQ  >>>>>>>>>            </member>
REQ  >>>>>>>>>            <member>
REQ  >>>>>>>>>              <name>login.username</name>
REQ  >>>>>>>>>              <value>
REQ  >>>>>>>>>                <string><![CDATA[admin]]></string>
REQ  >>>>>>>>>              </value>
REQ  >>>>>>>>>            </member>
REQ  >>>>>>>>>          </struct>
REQ  >>>>>>>>>         </value>
REQ  >>>>>>>>>       </param>
REQ  >>>>>>>>>     </params>
REQ  >>>>>>>>>   </methodCall>
2018/03/23 15:34:31
--------------------------------------------------------------------------------
2018/03/23 15:34:31
--------------------------------------------------------------------------------
2018/03/23 15:34:31 RES  <<<<<<<<<   <?xml version="1.0" encoding="UTF-8"?>
RES  <<<<<<<<<   <methodResponse
RES  <<<<<<<<<     xmlns:ex="
http://ws.apache.org/xmlrpc/namespaces/extensions">
RES  <<<<<<<<<     <fault>
RES  <<<<<<<<<       <value>
RES  <<<<<<<<<         <struct>
RES  <<<<<<<<<          <member>
RES  <<<<<<<<<            <name>faultCode</name>
RES  <<<<<<<<<            <value>
RES  <<<<<<<<<              <i4>0</i4>
RES  <<<<<<<<<            </value>
RES  <<<<<<<<<          </member>
RES  <<<<<<<<<          <member>
RES  <<<<<<<<<            <name>faultString</name>
RES  <<<<<<<<<            <value>Type check failed for field
RES  <<<<<<<<<              [calculateProductPrice.product]; expected type
is
RES  <<<<<<<<<              [org.apache.ofbiz.entity.GenericValue]; actual
type is
RES  <<<<<<<<<              [java.util.HashMap]</value>
RES  <<<<<<<<<          </member>
RES  <<<<<<<<<         </struct>
RES  <<<<<<<<<       </value>
RES  <<<<<<<<<     </fault>
RES  <<<<<<<<<   </methodResponse>
2018/03/23 15:34:31
--------------------------------------------------------------------------------
Service: calculateProductPrice faultString:Type check failed for field
[calculateProductPrice.product]; expected type is
[org.apache.ofbiz.entity.GenericValue]; actual type is [java.util.HashMap]

========================================
$ cat 007-get-price.pl

#!/usr/bin/perl

use OFBizClient;

my $ofbiz_client = OFBizClient->new(
                                url => '
https://your_ofbiz_server_here/webtools/control/xmlrpc' ,
                                username=>'admin'  ,
                                password => 'ofbiz'
);

my $productId = 'PROD_SY87B9B8MY';
$ofbiz_client->call('calculateProductPrice' , { product => { productId =>
$productId }   } );

========================================

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

Posted by Rajesh Mallah <ma...@gmail.com>.
>
> 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 <slidingfilaments@gmail.com
> 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 <ma...@gmail.com>
> 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 <
> slidingfilaments@gmail.com
> >> 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 <
> mallah.rajesh@gmail.com>
> >> 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 <
> >> > jacques.le.roux@les7arts.com> 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
> >> >>
> >> >>
> >>
>

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

Posted by Taher Alkhateeb <sl...@gmail.com>.
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 <ma...@gmail.com> 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 <slidingfilaments@gmail.com
>> 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 <ma...@gmail.com>
>> 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 <
>> > jacques.le.roux@les7arts.com> 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
>> >>
>> >>
>>

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

Posted by Rajesh Mallah <ma...@gmail.com>.
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 <slidingfilaments@gmail.com
> 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 <ma...@gmail.com>
> 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 <
> > jacques.le.roux@les7arts.com> 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
> >>
> >>
>

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

Posted by Taher Alkhateeb <sl...@gmail.com>.
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 <ma...@gmail.com> 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 <
> jacques.le.roux@les7arts.com> 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
>>
>>

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

Posted by Rajesh Mallah <ma...@gmail.com>.
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 <
jacques.le.roux@les7arts.com> 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
>
>

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

Posted by Jacques Le Roux <ja...@les7arts.com>.
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


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

Posted by Rajesh Mallah <ma...@gmail.com>.
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 <ma...@gmail.com>
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;
>
>