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.raj...@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 <slidingfilame...@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 <rishisolan...@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.raj...@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.raj...@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 } } ); >> >> > >> >> > ======================================== >> >> > >> >> > >> >> > >> >> >>