1 Reply Latest reply on Oct 22, 2006 12:57 AM by howardu

    Web Service and Arrays

    howardu

      I am having a problem with arrays of objects in my web service interface.
      Is there a way to get arrays of objects to work with the wstools?

      I am getting the following stack trace when I try to call my web service.

      [java] org.jboss.ws.WSException: Cannot load java type: com.dynaccsys.soa.wsdl.InvoiceType.Array
      [java] at org.jboss.ws.metadata.ParameterMetaData.getJavaType(ParameterMetaData.java:141)
      [java] at org.jboss.ws.metadata.ParameterMetaData.eagerInitialize(ParameterMetaData.java:291)
      [java] at org.jboss.ws.metadata.OperationMetaData.eagerInitialize(OperationMetaData.java:476)
      [java] at org.jboss.ws.metadata.EndpointMetaData.eagerInitialize(EndpointMetaData.java:351)
      [java] at org.jboss.ws.metadata.ServiceMetaData.eagerInitialize(ServiceMetaData.java:397)
      [java] at org.jboss.ws.metadata.UnifiedMetaData.eagerInitialize(UnifiedMetaData.java:147)
      [java] at org.jboss.ws.deployment.JSR109ClientMetaDataBuilder.buildMetaData(JSR109ClientMetaDataBuilder.java:129)
      [java] at org.jboss.ws.deployment.JSR109ClientMetaDataBuilder.buildMetaData(JSR109ClientMetaDataBuilder.java:82)
      [java] at org.jboss.ws.jaxrpc.ServiceImpl.(ServiceImpl.java:96)
      [java] at org.jboss.ws.jaxrpc.ServiceFactoryImpl.createService(ServiceFactoryImpl.java:157)
      [java] at org.jboss.ws.jaxrpc.ServiceFactoryImpl.createService(ServiceFactoryImpl.java:142)
      [java] at com.dynaccsys.soa.WebServiceClient.setUp(WebServiceClient.java:37)
      [java] at com.dynaccsys.soa.WebServiceClient.main(WebServiceClient.java:46)

      Here's my web service client:

      public class WebServiceClient
      {
      public final String TARGET_ENDPOINT_ADDRESS = "http://localhost:8080/soaDemo/Finaince_LoBService";

      private static ContractorInvoice_ContractorInvoice port;

      protected void setUp() throws Exception
      {
      ServiceFactoryImpl factory = new ServiceFactoryImpl();
      URL wsdlURL = new URL(TARGET_ENDPOINT_ADDRESS + "?wsdl");
      URL mappingURL = new File("gen/jaxrpc-mapping.xml").toURL();
      QName qname = new QName("http://gov.osera.bpel", "Finaince_LoBService");
      Service service = factory.createService(wsdlURL, qname, mappingURL);
      port = (ContractorInvoice_ContractorInvoice)service.getPort(ContractorInvoice_ContractorInvoice.class);
      }

      public static void main(String[] args)
      {
      try
      {
      WebServiceClient webServiceClient = new WebServiceClient();
      webServiceClient.setUp();
      InvoiceType[] invoices = new InvoiceType[1];
      String correlationId = "0";
      port.invoices(invoices,correlationId);
      }
      catch (Exception ex)
      {
      ex.printStackTrace();
      }
      }

      I have a wsdl file that is being used to generate all of my java classes using wstools wsdl-java

      The wsdl includes the following complex type:
      <xsd:complexType name="InvoicesType">
      <xsd:sequence>
      <xsd:element minOccurs="0" maxOccurs="unbounded" name="invoice" type="invoice:InvoiceType"/>
      </xsd:sequence>
      </xsd:complexType>

      This type is being used in the service parameters to generate the following method:
      public interface ContractorInvoice_ContractorInvoice extends java.rmi.Remote
      {

      public void invoices(com.dynaccsys.soa.wsdl.InvoiceType[] invoices,java.lang.String correlationId) throws java.rmi.RemoteException;
      }

        • 1. Re: Web Service and Arrays
          howardu

          The problem was actually discovered once I got the log4j to show the following message: [java] 23:30:38,015 WARN [JSR109ClientMetaDataBuilder] Cannot obtain the SEI mapping for: {http://gov.osera.bpel}Finaince_LoBService_1

          This led me to figure out how to use all of the @Webservice @Webmethod and @Webparam annotations to match up the wsdl names with the generated java code names as follows:

          @WebService(name = "ContractorInvoice_ContractorInvoice", targetNamespace = "http://gov.osera.bpel", serviceName = "Finaince_LoBService")
          @SOAPBinding(style = SOAPBinding.Style.RPC)
          public class ContractorInvoiceService
          {
          @WebMethod(operationName="Invoices")
          public void invoices(
          @WebParam(name="Invoices") InvoiceType[] invoices,
          @WebParam(name="correlationId") java.lang.String correlationId) throws java.rmi.RemoteException
          ...