OUT Parameter as Array

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

OUT Parameter as Array

Vinu Varghese-2
Hi all,

 I am creating a ofbiz java service, is there any option I can pass an
Array of Objects as OUT parameter?

regards
Vinu

--
........................................
<signature>
   <full-name> Vinu Varghese </full-name>
   <company-email> [hidden email] </company-email>
   <company-website> www.x-minds.org </company-website>
   <big-words>
    Success always occurs in private, and failure in full view.
    </big-words>
   <company-name-big>
\/      ._ _   o  ._    _|   _
/\  ~~  | | |  |  | |  (_|  _\                                                        
    </company-name-big>
</signature>

Reply | Threaded
Open this post in threaded view
|

RE: OUT Parameter as Array

Nikita Shinde
Hi Vinu,

        You can use the following in your service definition

        <attribute name="results" type="List" mode="OUT" optional="false"/>

Kind Regards,
Nikita Shinde
Amicon Technologies Pvt. Ltd., Mumbai, India.
India's No. 1 OFBiz Services Provider

-----Original Message-----
From: Vinu Varghese [mailto:[hidden email]]
Sent: Tuesday, February 03, 2009 1:31 PM
To: [hidden email]
Subject: OUT Parameter as Array

Hi all,

 I am creating a ofbiz java service, is there any option I can pass an
Array of Objects as OUT parameter?

regards
Vinu

--
........................................
<signature>
   <full-name> Vinu Varghese </full-name>
   <company-email> [hidden email] </company-email>
   <company-website> www.x-minds.org </company-website>
   <big-words>
    Success always occurs in private, and failure in full view.
    </big-words>
   <company-name-big>
\/      ._ _   o  ._    _|   _
/\  ~~  | | |  |  | |  (_|  _\

    </company-name-big>
</signature>

Reply | Threaded
Open this post in threaded view
|

Re: OUT Parameter as Array

Vinu Varghese-2
Thanks Nikita, I will try

........................................
<signature>
   <full-name> Vinu Varghese </full-name>
   <company-email> [hidden email] </company-email>
   <company-website> www.x-minds.org </company-website>
   <big-words>
    Success always occurs in private, and failure in full view.
    </big-words>
   <company-name-big>
\/      ._ _   o  ._    _|   _
/\  ~~  | | |  |  | |  (_|  _\                                                        
    </company-name-big>
</signature>



Nikita Shinde wrote:

> Hi Vinu,
>
>         You can use the following in your service definition
>
>         <attribute name="results" type="List" mode="OUT" optional="false"/>
>
> Kind Regards,
> Nikita Shinde
> Amicon Technologies Pvt. Ltd., Mumbai, India.
> India's No. 1 OFBiz Services Provider
>
> -----Original Message-----
> From: Vinu Varghese [mailto:[hidden email]]
> Sent: Tuesday, February 03, 2009 1:31 PM
> To: [hidden email]
> Subject: OUT Parameter as Array
>
> Hi all,
>
>  I am creating a ofbiz java service, is there any option I can pass an
> Array of Objects as OUT parameter?
>
> regards
> Vinu
>
>  
Reply | Threaded
Open this post in threaded view
|

Re: OUT Parameter as Array

Vinu Varghese-2
In reply to this post by Nikita Shinde
Hi

 I tried this, but got
 Exception: org.ofbiz.service.ServiceValidationException
     [java] Message: Type check failed for field
[customCDCountryCodeList.countryCode]; expected type is [List]; actual
type is [[Lcom.lb.xminds.services.customcd.orderreceiver.CountryCode;]

Any help?

regards
Vinu

........................................
<signature>
   <full-name> Vinu Varghese </full-name>
   <company-email> [hidden email] </company-email>
   <company-website> www.x-minds.org </company-website>
   <big-words>
    Success always occurs in private, and failure in full view.
    </big-words>
   <company-name-big>
\/      ._ _   o  ._    _|   _
/\  ~~  | | |  |  | |  (_|  _\                                                        
    </company-name-big>
</signature>



Nikita Shinde wrote:

> Hi Vinu,
>
>         You can use the following in your service definition
>
>         <attribute name="results" type="List" mode="OUT" optional="false"/>
>
> Kind Regards,
> Nikita Shinde
> Amicon Technologies Pvt. Ltd., Mumbai, India.
> India's No. 1 OFBiz Services Provider
>
> -----Original Message-----
> From: Vinu Varghese [mailto:[hidden email]]
> Sent: Tuesday, February 03, 2009 1:31 PM
> To: [hidden email]
> Subject: OUT Parameter as Array
>
> Hi all,
>
>  I am creating a ofbiz java service, is there any option I can pass an
> Array of Objects as OUT parameter?
>
> regards
> Vinu
>
>  
Reply | Threaded
Open this post in threaded view
|

RE: OUT Parameter as Array

Nikita Shinde
Can you paste the service definition and the code snippet here?

-----Original Message-----
From: Vinu Varghese [mailto:[hidden email]]
Sent: Tuesday, February 03, 2009 2:08 PM
To: [hidden email]
Subject: Re: OUT Parameter as Array

Hi

 I tried this, but got
 Exception: org.ofbiz.service.ServiceValidationException
     [java] Message: Type check failed for field
[customCDCountryCodeList.countryCode]; expected type is [List]; actual
type is [[Lcom.lb.xminds.services.customcd.orderreceiver.CountryCode;]

Any help?

regards
Vinu

........................................
<signature>
   <full-name> Vinu Varghese </full-name>
   <company-email> [hidden email] </company-email>
   <company-website> www.x-minds.org </company-website>
   <big-words>
    Success always occurs in private, and failure in full view.
    </big-words>
   <company-name-big>
\/      ._ _   o  ._    _|   _
/\  ~~  | | |  |  | |  (_|  _\

    </company-name-big>
</signature>



Nikita Shinde wrote:
> Hi Vinu,
>
>         You can use the following in your service definition
>
>         <attribute name="results" type="List" mode="OUT"
optional="false"/>

>
> Kind Regards,
> Nikita Shinde
> Amicon Technologies Pvt. Ltd., Mumbai, India.
> India's No. 1 OFBiz Services Provider
>
> -----Original Message-----
> From: Vinu Varghese [mailto:[hidden email]]
> Sent: Tuesday, February 03, 2009 1:31 PM
> To: [hidden email]
> Subject: OUT Parameter as Array
>
> Hi all,
>
>  I am creating a ofbiz java service, is there any option I can pass an
> Array of Objects as OUT parameter?
>
> regards
> Vinu
>
>  

Reply | Threaded
Open this post in threaded view
|

Re: OUT Parameter as Array

Vinu Varghese-2
Hi
Please check this

Service definition

<service name="customCDCountryCodeList" engine="java"
  location="com.lb.xminds.services.CustoCDService"
invoke="getCountryCodeList">
  <description> Get the country codes </description>
  <attribute name="login" type="String" mode="IN"
   optional="false" />
  <attribute name="password" type="String" mode="IN"
   optional="false" />
  <attribute name="countryCode" type="List" mode="OUT"
   optional="false" />
 
 </service>

public static Map getCountryCodeList(DispatchContext dctx, Map context)
    {
        Map resultMap = null;
        try
        {
            String login = (String) context.get("login");
            String password = (String) context.get("password");
            CustomCDWraper wraper = new CustomCDWraperImpl();
            resultMap = ServiceUtil.returnSuccess();

          // Here this will be an array of type CountryCode
            resultMap.put("countryCode",
wraper.getCountryCodeList(login, password));

            log.info("*************** Country Code List Completed
****************");
        }
        catch (Exception e)
        {
            log.error("Error", e);
            resultMap = ServiceUtil.returnError("Failed to connect");
        }
        return resultMap;
    }

TestCase to test this

 public void testCountryCodeList() throws Exception
    {
        Map<String, Object> ctx = FastMap.newInstance();
        ctx.put("login", "customcd_test");
        ctx.put("password", "CustomCD");
        Map res = dispatcher.runSync("customCDCountryCodeList", ctx);
         List ls= (List)res.get("countryCode");
         log.info("################ code" + ls);
    }

........................................
<signature>
   <full-name> Vinu Varghese </full-name>
   <company-email> [hidden email] </company-email>
   <company-website> www.x-minds.org </company-website>
   <big-words>
    Success always occurs in private, and failure in full view.
    </big-words>
   <company-name-big>
\/      ._ _   o  ._    _|   _
/\  ~~  | | |  |  | |  (_|  _\                                                        
    </company-name-big>
</signature>



Nikita Shinde wrote:

> Can you paste the service definition and the code snippet here?
>
> -----Original Message-----
> From: Vinu Varghese [mailto:[hidden email]]
> Sent: Tuesday, February 03, 2009 2:08 PM
> To: [hidden email]
> Subject: Re: OUT Parameter as Array
>
> Hi
>
>  I tried this, but got
>  Exception: org.ofbiz.service.ServiceValidationException
>      [java] Message: Type check failed for field
> [customCDCountryCodeList.countryCode]; expected type is [List]; actual
> type is [[Lcom.lb.xminds.services.customcd.orderreceiver.CountryCode;]
>
> Any help?
>
> regards
> Vinu
>
> ........................................
> <signature>
>    <full-name> Vinu Varghese </full-name>
>    <company-email> [hidden email] </company-email>
>    <company-website> www.x-minds.org </company-website>
>    <big-words>
>     Success always occurs in private, and failure in full view.
>     </big-words>
>    <company-name-big>
> \/      ._ _   o  ._    _|   _
> /\  ~~  | | |  |  | |  (_|  _\
>
>     </company-name-big>
> </signature>
>
>
>
> Nikita Shinde wrote:
>  
>> Hi Vinu,
>>
>>         You can use the following in your service definition
>>
>>         <attribute name="results" type="List" mode="OUT"
>>    
> optional="false"/>
>  
>> Kind Regards,
>> Nikita Shinde
>> Amicon Technologies Pvt. Ltd., Mumbai, India.
>> India's No. 1 OFBiz Services Provider
>>
>> -----Original Message-----
>> From: Vinu Varghese [mailto:[hidden email]]
>> Sent: Tuesday, February 03, 2009 1:31 PM
>> To: [hidden email]
>> Subject: OUT Parameter as Array
>>
>> Hi all,
>>
>>  I am creating a ofbiz java service, is there any option I can pass an
>> Array of Objects as OUT parameter?
>>
>> regards
>> Vinu
>>
>>  
>>    
>
>
>  
Reply | Threaded
Open this post in threaded view
|

RE: OUT Parameter as Array

Nikita Shinde
As per the error ...wraper.getCountryCodeList(login, password) method seems
to return just a CountryCode object and not an array.

Can you please verify what does wraper.getCountryCodeList(login, password)
return?


-----Original Message-----
From: Vinu Varghese [mailto:[hidden email]]
Sent: Tuesday, February 03, 2009 3:04 PM
To: [hidden email]
Subject: Re: OUT Parameter as Array

Hi
Please check this

Service definition

<service name="customCDCountryCodeList" engine="java"
  location="com.lb.xminds.services.CustoCDService"
invoke="getCountryCodeList">
  <description> Get the country codes </description>
  <attribute name="login" type="String" mode="IN"
   optional="false" />
  <attribute name="password" type="String" mode="IN"
   optional="false" />
  <attribute name="countryCode" type="List" mode="OUT"
   optional="false" />
 
 </service>

public static Map getCountryCodeList(DispatchContext dctx, Map context)
    {
        Map resultMap = null;
        try
        {
            String login = (String) context.get("login");
            String password = (String) context.get("password");
            CustomCDWraper wraper = new CustomCDWraperImpl();
            resultMap = ServiceUtil.returnSuccess();

          // Here this will be an array of type CountryCode
            resultMap.put("countryCode",
wraper.getCountryCodeList(login, password));

            log.info("*************** Country Code List Completed
****************");
        }
        catch (Exception e)
        {
            log.error("Error", e);
            resultMap = ServiceUtil.returnError("Failed to connect");
        }
        return resultMap;
    }

TestCase to test this

 public void testCountryCodeList() throws Exception
    {
        Map<String, Object> ctx = FastMap.newInstance();
        ctx.put("login", "customcd_test");
        ctx.put("password", "CustomCD");
        Map res = dispatcher.runSync("customCDCountryCodeList", ctx);
         List ls= (List)res.get("countryCode");
         log.info("################ code" + ls);
    }

........................................
<signature>
   <full-name> Vinu Varghese </full-name>
   <company-email> [hidden email] </company-email>
   <company-website> www.x-minds.org </company-website>
   <big-words>
    Success always occurs in private, and failure in full view.
    </big-words>
   <company-name-big>
\/      ._ _   o  ._    _|   _
/\  ~~  | | |  |  | |  (_|  _\

    </company-name-big>
</signature>



Nikita Shinde wrote:

> Can you paste the service definition and the code snippet here?
>
> -----Original Message-----
> From: Vinu Varghese [mailto:[hidden email]]
> Sent: Tuesday, February 03, 2009 2:08 PM
> To: [hidden email]
> Subject: Re: OUT Parameter as Array
>
> Hi
>
>  I tried this, but got
>  Exception: org.ofbiz.service.ServiceValidationException
>      [java] Message: Type check failed for field
> [customCDCountryCodeList.countryCode]; expected type is [List]; actual
> type is [[Lcom.lb.xminds.services.customcd.orderreceiver.CountryCode;]
>
> Any help?
>
> regards
> Vinu
>
> ........................................
> <signature>
>    <full-name> Vinu Varghese </full-name>
>    <company-email> [hidden email] </company-email>
>    <company-website> www.x-minds.org </company-website>
>    <big-words>
>     Success always occurs in private, and failure in full view.
>     </big-words>
>    <company-name-big>
> \/      ._ _   o  ._    _|   _
> /\  ~~  | | |  |  | |  (_|  _\
>
>     </company-name-big>
> </signature>
>
>
>
> Nikita Shinde wrote:
>  
>> Hi Vinu,
>>
>>         You can use the following in your service definition
>>
>>         <attribute name="results" type="List" mode="OUT"
>>    
> optional="false"/>
>  
>> Kind Regards,
>> Nikita Shinde
>> Amicon Technologies Pvt. Ltd., Mumbai, India.
>> India's No. 1 OFBiz Services Provider
>>
>> -----Original Message-----
>> From: Vinu Varghese [mailto:[hidden email]]
>> Sent: Tuesday, February 03, 2009 1:31 PM
>> To: [hidden email]
>> Subject: OUT Parameter as Array
>>
>> Hi all,
>>
>>  I am creating a ofbiz java service, is there any option I can pass an
>> Array of Objects as OUT parameter?
>>
>> regards
>> Vinu
>>
>>  
>>    
>
>
>  

Reply | Threaded
Open this post in threaded view
|

Re: OUT Parameter as Array

Vinu Varghese-2
public CountryCode[] getCountryCodeList(String login, String password)

this is the method in wrapper

........................................
<signature>
   <full-name> Vinu Varghese </full-name>
   <company-email> [hidden email] </company-email>
   <company-website> www.x-minds.org </company-website>
   <big-words>
    Success always occurs in private, and failure in full view.
    </big-words>
   <company-name-big>
\/      ._ _   o  ._    _|   _
/\  ~~  | | |  |  | |  (_|  _\                                                        
    </company-name-big>
</signature>



Nikita Shinde wrote:

> As per the error ...wraper.getCountryCodeList(login, password) method seems
> to return just a CountryCode object and not an array.
>
> Can you please verify what does wraper.getCountryCodeList(login, password)
> return?
>
>
> -----Original Message-----
> From: Vinu Varghese [mailto:[hidden email]]
> Sent: Tuesday, February 03, 2009 3:04 PM
> To: [hidden email]
> Subject: Re: OUT Parameter as Array
>
> Hi
> Please check this
>
> Service definition
>
> <service name="customCDCountryCodeList" engine="java"
>   location="com.lb.xminds.services.CustoCDService"
> invoke="getCountryCodeList">
>   <description> Get the country codes </description>
>   <attribute name="login" type="String" mode="IN"
>    optional="false" />
>   <attribute name="password" type="String" mode="IN"
>    optional="false" />
>   <attribute name="countryCode" type="List" mode="OUT"
>    optional="false" />
>  
>  </service>
>
> public static Map getCountryCodeList(DispatchContext dctx, Map context)
>     {
>         Map resultMap = null;
>         try
>         {
>             String login = (String) context.get("login");
>             String password = (String) context.get("password");
>             CustomCDWraper wraper = new CustomCDWraperImpl();
>             resultMap = ServiceUtil.returnSuccess();
>
>           // Here this will be an array of type CountryCode
>             resultMap.put("countryCode",
> wraper.getCountryCodeList(login, password));
>
>             log.info("*************** Country Code List Completed
> ****************");
>         }
>         catch (Exception e)
>         {
>             log.error("Error", e);
>             resultMap = ServiceUtil.returnError("Failed to connect");
>         }
>         return resultMap;
>     }
>
> TestCase to test this
>
>  public void testCountryCodeList() throws Exception
>     {
>         Map<String, Object> ctx = FastMap.newInstance();
>         ctx.put("login", "customcd_test");
>         ctx.put("password", "CustomCD");
>         Map res = dispatcher.runSync("customCDCountryCodeList", ctx);
>          List ls= (List)res.get("countryCode");
>          log.info("################ code" + ls);
>     }
>
> ........................................
> <signature>
>    <full-name> Vinu Varghese </full-name>
>    <company-email> [hidden email] </company-email>
>    <company-website> www.x-minds.org </company-website>
>    <big-words>
>     Success always occurs in private, and failure in full view.
>     </big-words>
>    <company-name-big>
> \/      ._ _   o  ._    _|   _
> /\  ~~  | | |  |  | |  (_|  _\
>
>     </company-name-big>
> </signature>
>
>
>
> Nikita Shinde wrote:
>  
>> Can you paste the service definition and the code snippet here?
>>
>> -----Original Message-----
>> From: Vinu Varghese [mailto:[hidden email]]
>> Sent: Tuesday, February 03, 2009 2:08 PM
>> To: [hidden email]
>> Subject: Re: OUT Parameter as Array
>>
>> Hi
>>
>>  I tried this, but got
>>  Exception: org.ofbiz.service.ServiceValidationException
>>      [java] Message: Type check failed for field
>> [customCDCountryCodeList.countryCode]; expected type is [List]; actual
>> type is [[Lcom.lb.xminds.services.customcd.orderreceiver.CountryCode;]
>>
>> Any help?
>>
>> regards
>> Vinu
>>
>> ........................................
>> <signature>
>>    <full-name> Vinu Varghese </full-name>
>>    <company-email> [hidden email] </company-email>
>>    <company-website> www.x-minds.org </company-website>
>>    <big-words>
>>     Success always occurs in private, and failure in full view.
>>     </big-words>
>>    <company-name-big>
>> \/      ._ _   o  ._    _|   _
>> /\  ~~  | | |  |  | |  (_|  _\
>>
>>     </company-name-big>
>> </signature>
>>
>>
>>
>> Nikita Shinde wrote:
>>  
>>    
>>> Hi Vinu,
>>>
>>>         You can use the following in your service definition
>>>
>>>         <attribute name="results" type="List" mode="OUT"
>>>    
>>>      
>> optional="false"/>
>>  
>>    
>>> Kind Regards,
>>> Nikita Shinde
>>> Amicon Technologies Pvt. Ltd., Mumbai, India.
>>> India's No. 1 OFBiz Services Provider
>>>
>>> -----Original Message-----
>>> From: Vinu Varghese [mailto:[hidden email]]
>>> Sent: Tuesday, February 03, 2009 1:31 PM
>>> To: [hidden email]
>>> Subject: OUT Parameter as Array
>>>
>>> Hi all,
>>>
>>>  I am creating a ofbiz java service, is there any option I can pass an
>>> Array of Objects as OUT parameter?
>>>
>>> regards
>>> Vinu
>>>
>>>  
>>>    
>>>      
>>  
>>    
>
>
>  
Reply | Threaded
Open this post in threaded view
|

RE: OUT Parameter as Array

Nikita Shinde
You will have to modify "getCountryCodeList" method in wrapper to return a
list or can modify the code as below:

resultMap.put("countryCode",
UtilMisc.toList(wraper.getCountryCodeList(login, password)));

And when you try to retrieve "countryCode", you will have to iterate this
list and get your array object.

There is no way to define an Array as IN/OUT parameter in a service
definition as far as I know.


-----Original Message-----
From: Vinu Varghese [mailto:[hidden email]]
Sent: Tuesday, February 03, 2009 3:19 PM
To: [hidden email]
Subject: Re: OUT Parameter as Array

public CountryCode[] getCountryCodeList(String login, String password)

this is the method in wrapper

........................................
<signature>
   <full-name> Vinu Varghese </full-name>
   <company-email> [hidden email] </company-email>
   <company-website> www.x-minds.org </company-website>
   <big-words>
    Success always occurs in private, and failure in full view.
    </big-words>
   <company-name-big>
\/      ._ _   o  ._    _|   _
/\  ~~  | | |  |  | |  (_|  _\

    </company-name-big>
</signature>



Nikita Shinde wrote:
> As per the error ...wraper.getCountryCodeList(login, password) method
seems

> to return just a CountryCode object and not an array.
>
> Can you please verify what does wraper.getCountryCodeList(login, password)
> return?
>
>
> -----Original Message-----
> From: Vinu Varghese [mailto:[hidden email]]
> Sent: Tuesday, February 03, 2009 3:04 PM
> To: [hidden email]
> Subject: Re: OUT Parameter as Array
>
> Hi
> Please check this
>
> Service definition
>
> <service name="customCDCountryCodeList" engine="java"
>   location="com.lb.xminds.services.CustoCDService"
> invoke="getCountryCodeList">
>   <description> Get the country codes </description>
>   <attribute name="login" type="String" mode="IN"
>    optional="false" />
>   <attribute name="password" type="String" mode="IN"
>    optional="false" />
>   <attribute name="countryCode" type="List" mode="OUT"
>    optional="false" />
>  
>  </service>
>
> public static Map getCountryCodeList(DispatchContext dctx, Map context)
>     {
>         Map resultMap = null;
>         try
>         {
>             String login = (String) context.get("login");
>             String password = (String) context.get("password");
>             CustomCDWraper wraper = new CustomCDWraperImpl();
>             resultMap = ServiceUtil.returnSuccess();
>
>           // Here this will be an array of type CountryCode
>             resultMap.put("countryCode",
> wraper.getCountryCodeList(login, password));
>
>             log.info("*************** Country Code List Completed
> ****************");
>         }
>         catch (Exception e)
>         {
>             log.error("Error", e);
>             resultMap = ServiceUtil.returnError("Failed to connect");
>         }
>         return resultMap;
>     }
>
> TestCase to test this
>
>  public void testCountryCodeList() throws Exception
>     {
>         Map<String, Object> ctx = FastMap.newInstance();
>         ctx.put("login", "customcd_test");
>         ctx.put("password", "CustomCD");
>         Map res = dispatcher.runSync("customCDCountryCodeList", ctx);
>          List ls= (List)res.get("countryCode");
>          log.info("################ code" + ls);
>     }
>
> ........................................
> <signature>
>    <full-name> Vinu Varghese </full-name>
>    <company-email> [hidden email] </company-email>
>    <company-website> www.x-minds.org </company-website>
>    <big-words>
>     Success always occurs in private, and failure in full view.
>     </big-words>
>    <company-name-big>
> \/      ._ _   o  ._    _|   _
> /\  ~~  | | |  |  | |  (_|  _\
>
>     </company-name-big>
> </signature>
>
>
>
> Nikita Shinde wrote:
>  
>> Can you paste the service definition and the code snippet here?
>>
>> -----Original Message-----
>> From: Vinu Varghese [mailto:[hidden email]]
>> Sent: Tuesday, February 03, 2009 2:08 PM
>> To: [hidden email]
>> Subject: Re: OUT Parameter as Array
>>
>> Hi
>>
>>  I tried this, but got
>>  Exception: org.ofbiz.service.ServiceValidationException
>>      [java] Message: Type check failed for field
>> [customCDCountryCodeList.countryCode]; expected type is [List]; actual
>> type is [[Lcom.lb.xminds.services.customcd.orderreceiver.CountryCode;]
>>
>> Any help?
>>
>> regards
>> Vinu
>>
>> ........................................
>> <signature>
>>    <full-name> Vinu Varghese </full-name>
>>    <company-email> [hidden email] </company-email>
>>    <company-website> www.x-minds.org </company-website>
>>    <big-words>
>>     Success always occurs in private, and failure in full view.
>>     </big-words>
>>    <company-name-big>
>> \/      ._ _   o  ._    _|   _
>> /\  ~~  | | |  |  | |  (_|  _\
>>
>>     </company-name-big>
>> </signature>
>>
>>
>>
>> Nikita Shinde wrote:
>>  
>>    
>>> Hi Vinu,
>>>
>>>         You can use the following in your service definition
>>>
>>>         <attribute name="results" type="List" mode="OUT"
>>>    
>>>      
>> optional="false"/>
>>  
>>    
>>> Kind Regards,
>>> Nikita Shinde
>>> Amicon Technologies Pvt. Ltd., Mumbai, India.
>>> India's No. 1 OFBiz Services Provider
>>>
>>> -----Original Message-----
>>> From: Vinu Varghese [mailto:[hidden email]]
>>> Sent: Tuesday, February 03, 2009 1:31 PM
>>> To: [hidden email]
>>> Subject: OUT Parameter as Array
>>>
>>> Hi all,
>>>
>>>  I am creating a ofbiz java service, is there any option I can pass an
>>> Array of Objects as OUT parameter?
>>>
>>> regards
>>> Vinu
>>>
>>>  
>>>    
>>>      
>>  
>>    
>
>
>  

Reply | Threaded
Open this post in threaded view
|

Re: OUT Parameter as Array

Vinu Varghese-2
Thanks, I will go that way

........................................
<signature>
   <full-name> Vinu Varghese </full-name>
   <company-email> [hidden email] </company-email>
   <company-website> www.x-minds.org </company-website>
   <big-words>
    Success always occurs in private, and failure in full view.
    </big-words>
   <company-name-big>
\/      ._ _   o  ._    _|   _
/\  ~~  | | |  |  | |  (_|  _\                                                        
    </company-name-big>
</signature>



Nikita Shinde wrote:

> You will have to modify "getCountryCodeList" method in wrapper to return a
> list or can modify the code as below:
>
> resultMap.put("countryCode",
> UtilMisc.toList(wraper.getCountryCodeList(login, password)));
>
> And when you try to retrieve "countryCode", you will have to iterate this
> list and get your array object.
>
> There is no way to define an Array as IN/OUT parameter in a service
> definition as far as I know.
>
>
> -----Original Message-----
> From: Vinu Varghese [mailto:[hidden email]]
> Sent: Tuesday, February 03, 2009 3:19 PM
> To: [hidden email]
> Subject: Re: OUT Parameter as Array
>
> public CountryCode[] getCountryCodeList(String login, String password)
>
> this is the method in wrapper
>
> ........................................
> <signature>
>    <full-name> Vinu Varghese </full-name>
>    <company-email> [hidden email] </company-email>
>    <company-website> www.x-minds.org </company-website>
>    <big-words>
>     Success always occurs in private, and failure in full view.
>     </big-words>
>    <company-name-big>
> \/      ._ _   o  ._    _|   _
> /\  ~~  | | |  |  | |  (_|  _\
>
>     </company-name-big>
> </signature>
>
>
>
> Nikita Shinde wrote:
>  
>> As per the error ...wraper.getCountryCodeList(login, password) method
>>    
> seems
>  
>> to return just a CountryCode object and not an array.
>>
>> Can you please verify what does wraper.getCountryCodeList(login, password)
>> return?
>>
>>
>> -----Original Message-----
>> From: Vinu Varghese [mailto:[hidden email]]
>> Sent: Tuesday, February 03, 2009 3:04 PM
>> To: [hidden email]
>> Subject: Re: OUT Parameter as Array
>>
>> Hi
>> Please check this
>>
>> Service definition
>>
>> <service name="customCDCountryCodeList" engine="java"
>>   location="com.lb.xminds.services.CustoCDService"
>> invoke="getCountryCodeList">
>>   <description> Get the country codes </description>
>>   <attribute name="login" type="String" mode="IN"
>>    optional="false" />
>>   <attribute name="password" type="String" mode="IN"
>>    optional="false" />
>>   <attribute name="countryCode" type="List" mode="OUT"
>>    optional="false" />
>>  
>>  </service>
>>
>> public static Map getCountryCodeList(DispatchContext dctx, Map context)
>>     {
>>         Map resultMap = null;
>>         try
>>         {
>>             String login = (String) context.get("login");
>>             String password = (String) context.get("password");
>>             CustomCDWraper wraper = new CustomCDWraperImpl();
>>             resultMap = ServiceUtil.returnSuccess();
>>
>>           // Here this will be an array of type CountryCode
>>             resultMap.put("countryCode",
>> wraper.getCountryCodeList(login, password));
>>
>>             log.info("*************** Country Code List Completed
>> ****************");
>>         }
>>         catch (Exception e)
>>         {
>>             log.error("Error", e);
>>             resultMap = ServiceUtil.returnError("Failed to connect");
>>         }
>>         return resultMap;
>>     }
>>
>> TestCase to test this
>>
>>  public void testCountryCodeList() throws Exception
>>     {
>>         Map<String, Object> ctx = FastMap.newInstance();
>>         ctx.put("login", "customcd_test");
>>         ctx.put("password", "CustomCD");
>>         Map res = dispatcher.runSync("customCDCountryCodeList", ctx);
>>          List ls= (List)res.get("countryCode");
>>          log.info("################ code" + ls);
>>     }
>>
>> ........................................
>> <signature>
>>    <full-name> Vinu Varghese </full-name>
>>    <company-email> [hidden email] </company-email>
>>    <company-website> www.x-minds.org </company-website>
>>    <big-words>
>>     Success always occurs in private, and failure in full view.
>>     </big-words>
>>    <company-name-big>
>> \/      ._ _   o  ._    _|   _
>> /\  ~~  | | |  |  | |  (_|  _\
>>
>>     </company-name-big>
>> </signature>
>>
>>
>>
>> Nikita Shinde wrote:
>>  
>>    
>>> Can you paste the service definition and the code snippet here?
>>>
>>> -----Original Message-----
>>> From: Vinu Varghese [mailto:[hidden email]]
>>> Sent: Tuesday, February 03, 2009 2:08 PM
>>> To: [hidden email]
>>> Subject: Re: OUT Parameter as Array
>>>
>>> Hi
>>>
>>>  I tried this, but got
>>>  Exception: org.ofbiz.service.ServiceValidationException
>>>      [java] Message: Type check failed for field
>>> [customCDCountryCodeList.countryCode]; expected type is [List]; actual
>>> type is [[Lcom.lb.xminds.services.customcd.orderreceiver.CountryCode;]
>>>
>>> Any help?
>>>
>>> regards
>>> Vinu
>>>
>>> ........................................
>>> <signature>
>>>    <full-name> Vinu Varghese </full-name>
>>>    <company-email> [hidden email] </company-email>
>>>    <company-website> www.x-minds.org </company-website>
>>>    <big-words>
>>>     Success always occurs in private, and failure in full view.
>>>     </big-words>
>>>    <company-name-big>
>>> \/      ._ _   o  ._    _|   _
>>> /\  ~~  | | |  |  | |  (_|  _\
>>>
>>>     </company-name-big>
>>> </signature>
>>>
>>>
>>>
>>> Nikita Shinde wrote:
>>>  
>>>    
>>>      
>>>> Hi Vinu,
>>>>
>>>>         You can use the following in your service definition
>>>>
>>>>         <attribute name="results" type="List" mode="OUT"
>>>>    
>>>>      
>>>>        
>>> optional="false"/>
>>>  
>>>    
>>>      
>>>> Kind Regards,
>>>> Nikita Shinde
>>>> Amicon Technologies Pvt. Ltd., Mumbai, India.
>>>> India's No. 1 OFBiz Services Provider
>>>>
>>>> -----Original Message-----
>>>> From: Vinu Varghese [mailto:[hidden email]]
>>>> Sent: Tuesday, February 03, 2009 1:31 PM
>>>> To: [hidden email]
>>>> Subject: OUT Parameter as Array
>>>>
>>>> Hi all,
>>>>
>>>>  I am creating a ofbiz java service, is there any option I can pass an
>>>> Array of Objects as OUT parameter?
>>>>
>>>> regards
>>>> Vinu
>>>>
>>>>  
>>>>    
>>>>      
>>>>        
>>>  
>>>    
>>>      
>>  
>>    
>
>
>