0 Replies Latest reply on Sep 11, 2007 5:40 PM by Karen Lease

    Jaxrpc service with parameter Type[] fails if array contains

    Karen Lease Newbie

      I have a jaxrpc endpoint which has methods like these:

      public interface TrivialService extends Remote
      {
       int purchase (String person, Product[] products) throws RemoteException;
       int purchaseA (String person, ProductA[] products) throws RemoteException;
      }


      I used wstools (java-wsdl) to generate deployment artifacts and deployed on a 4.2.1.GA jboss with 2.0.1.GA jbossws.

      Class ProductA is a subclass of Product.
      If I call purchase like this:
      public void testPurchase() throws Exception
       {
       String person = "Karen";
       ProductA bike = new ProductA();
       bike.setName("cyfac");
       bike.setPrice(3000);
       ProductA bike2 = new ProductA();
       bike2.setName("look");
       bike2.setPrice(5000);
       ProductA bike3 = new ProductA();
       bike3.setName("GOSPORT");
       bike3.setPrice(1000);
       Product[] bikes = new Product[] {bike, bike2, bike3};
       int price = port.purchase(person, bikes);
       assertEquals(9000, price);
       }

      the test case fails because it returns only the price of the last element in the list.
      In the service it only sees one element.
      If I call it like this (with same actual objects),
      ProductA[] bikes = new ProductA[] {bike, bike2, bike3};
      int price = port.purchaseA(person, bikes);

      the service receives all 3 elements and returns the correct response.

      The incoming soap message on the server is correct in both cases. In the first case, the elements all have the type attribute set, like so:
      <ns1:purchase xmlns:ns1='http://com.kl/test1/types'>
       <String_1>Karen</String_1>
       <arrayOfProduct_2 xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:type='ns1:ProductA'>
       <name>cyfac</name>
       <price>3000</price>
       </arrayOfProduct_2>
       <arrayOfProduct_2 xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:type='ns1:ProductA'>
       <name>look</name>
       <price>5000</price>
       </arrayOfProduct_2>
       .....
      


      This happens with both a jaxrpc style client and a jaxws client generated with wsconsume (-t 2.1). However it works correctly with jaxrpc client if I deploy into a jbossws 1.2.1GA server.

      I don't see anything in Jira which is quite like this, shall I file a new bug?