4 Replies Latest reply on Jan 14, 2005 5:04 AM by Martin Connolly

    No serializer found for class - C# Client, JBoss Web Service

    Martin Connolly Newbie

      Hi,
      I am building a JBoss Web Service to communicate with a C# client. I have created two custom datatypes to pass from the C# program to the JBoss Web Service. I have followed the documentation closely and have the following in my ws2ee-deployment.xml file:

      <deployment
      xmlns='http://xml.apache.org/axis/wsdd/'
      xmlns:java='http://xml.apache.org/axis/wsdd/providers/java'
      xmlns:soap='http://schemas.xmlsoap.org/soap/encoding/'
      xmlns:xsi='http://www.w3.org/2000/10/XMLSchema-instance'
      xmlns:xsd='http://www.w3.org/2001/XMLSchema'>

      <typeMapping
      qname='ns1:BusinessCategoryType' xmlns:ns1='http://businessartifacts.tester.com'
      type='java:com.tester.businessartifacts.BusinessCategoryType'
      serializer='org.apache.axis.encoding.ser.BeanSerializerFactory'
      deserializer='org.apache.axis.encoding.ser.BeanDeserializerFactory'
      encodingStyle='' />


      <typeMapping
      qname='ns1:BusinessCategoryTypeArray' xmlns:ns1='http://businessartifacts.tester.com'
      type='java:com.tester.businessartifacts.BusinessCategoryTypeArray'
      serializer='org.apache.axis.encoding.ser.BeanSerializerFactory'
      deserializer='org.apache.axis.encoding.ser.BeanDeserializerFactory'
      encodingStyle=''/>




      BusinessCategoryTypeArray as the name implies consists of an array of BusinessCategories.

      The java classes are as follows:

      BusinessCategoryType.java

      package com.tester.businessartifacts;

      import java.io.Serializable;

      /**
      * @author martin
      *
      * The Business Category Class is used by the Web Service for sending and receiving the Business Categories.
      */
      public class BusinessCategoryType implements Serializable {

      /**
      * This is the ID for the Business Category.
      */
      private int businessCategoryID;

      /**
      * This is the name for the Business Category.
      */
      private String businessCategoryName;

      /**
      * This constructor sets the member variables for the class.
      *
      * @param businessCategoryID The Business Category ID.
      * @param businessCategoryName The Business Category Name.
      */
      public BusinessCategoryType(int businessCategoryID, String businessCategoryName)
      {
      this.businessCategoryID = businessCategoryID;
      this.businessCategoryName = businessCategoryName;
      }

      /**
      * The default empty constructor.
      *
      */
      public BusinessCategoryType()
      {

      }

      /**
      * Sets the Business Category ID.
      *
      * @param businessCategoryID
      */
      public void setBusinessCategoryID(int businessCategoryID)
      {
      this.businessCategoryID = businessCategoryID;
      }

      /**
      * Returns the Business Category ID.
      *
      * @return The Business Category ID.
      */
      public int getBusinessCategoryID()
      {
      return this.businessCategoryID;
      }

      /**
      * Sets the Business Category Name.
      *
      * @param businessCategoryName
      */
      public void setBusinessCategoryName(String businessCategoryName)
      {
      this.businessCategoryName = businessCategoryName;
      }

      /**
      * Returns the Business Category Name.
      *
      * @return The Business Category Name.
      */
      public String getBusinessCategoryName()
      {
      return this.businessCategoryName;
      }
      }

      BusinessCategoryTypeArray.java

      package com.tester.businessartifacts;

      import java.io.Serializable;


      /**
      * @author martin
      *
      * TODO To change the template for this generated type comment go to
      * Window - Preferences - Java - Code Style - Code Templates
      */
      public class BusinessCategoryTypeArray implements Serializable {

      private BusinessCategoryType[] businessCategoryTypes;

      public BusinessCategoryTypeArray()
      {

      }

      public BusinessCategoryTypeArray(BusinessCategoryType[] businessCategoryTypes)
      {
      this.businessCategoryTypes = businessCategoryTypes;
      }

      public void setBusinessCategoryTypes(BusinessCategoryType[] businessCategoryTypes)
      {
      this.businessCategoryTypes = businessCategoryTypes;
      }

      public BusinessCategoryType[] getBusinessCategoryTypes()
      {
      return this.businessCategoryTypes;
      }

      }

      I also generate a .NET proxy using Microsoft.NET's wsdl tool which gives me the following file:

      //------------------------------------------------------------------------------
      //
      // This code was generated by a tool.
      // Runtime Version: 1.1.4322.2032
      //
      // Changes to this file may cause incorrect behavior and will be lost if
      // the code is regenerated.
      //
      //------------------------------------------------------------------------------

      //
      // This source code was auto-generated by wsdl, Version=1.1.4322.2032.
      //
      using System.Diagnostics;
      using System.Xml.Serialization;
      using System;
      using System.Web.Services.Protocols;
      using System.ComponentModel;
      using System.Web.Services;


      ///
      [System.Diagnostics.DebuggerStepThroughAttribute()]
      [System.ComponentModel.DesignerCategoryAttribute("code")]
      [System.Web.Services.WebServiceBindingAttribute(Name="BusinessCategoriesManagementEndpointSoapBinding", Namespace="http://ejb.tester.com")]
      [System.Xml.Serialization.SoapIncludeAttribute(typeof(BusinessCategoryType))]
      public class BusinessCategoriesManagementService : System.Web.Services.Protocols.SoapHttpClientProtocol {

      ///
      public BusinessCategoriesManagementService() {
      this.Url = "http://localhost:8080/tester-ws-ejb/BusinessCategoriesManagementService";
      }

      ///
      [System.Web.Services.Protocols.SoapRpcMethodAttribute("", RequestNamespace="http://ejb.tester.com", ResponseNamespace="http://ejb.tester.com")]
      [return: System.Xml.Serialization.SoapElementAttribute("addBusinessCategoryReturn")]
      public bool addBusinessCategory(string in0) {
      object[] results = this.Invoke("addBusinessCategory", new object[] {
      in0});
      return ((bool)(results[0]));
      }

      ///
      public System.IAsyncResult BeginaddBusinessCategory(string in0, System.AsyncCallback callback, object asyncState) {
      return this.BeginInvoke("addBusinessCategory", new object[] {
      in0}, callback, asyncState);
      }

      ///
      public bool EndaddBusinessCategory(System.IAsyncResult asyncResult) {
      object[] results = this.EndInvoke(asyncResult);
      return ((bool)(results[0]));
      }

      ///
      [System.Web.Services.Protocols.SoapRpcMethodAttribute("", RequestNamespace="http://ejb.tester.com", ResponseNamespace="http://ejb.tester.com")]
      [return: System.Xml.Serialization.SoapElementAttribute("renameBusinessCategoryReturn")]
      public bool renameBusinessCategory(string in0, int in1) {
      object[] results = this.Invoke("renameBusinessCategory", new object[] {in0, in1});
      return ((bool)(results[0]));
      }

      ///
      public System.IAsyncResult BeginrenameBusinessCategory(string in0, int in1, System.AsyncCallback callback, object asyncState) {
      return this.BeginInvoke("renameBusinessCategory", new object[] {
      in0, in1}, callback, asyncState);
      }

      ///
      public bool EndrenameBusinessCategory(System.IAsyncResult asyncResult) {
      object[] results = this.EndInvoke(asyncResult);
      return ((bool)(results[0]));
      }

      ///
      [System.Web.Services.Protocols.SoapRpcMethodAttribute("", RequestNamespace="http://ejb.tester.com", ResponseNamespace="http://ejb.tester.com")]
      [return: System.Xml.Serialization.SoapElementAttribute("retrieveBusinessCategoriesReturn")]
      public BusinessCategoryTypeArray retrieveBusinessCategories() {
      object[] results = this.Invoke("retrieveBusinessCategories", new object[0]);
      return ((BusinessCategoryTypeArray)(results[0]));
      }

      ///
      public System.IAsyncResult BeginretrieveBusinessCategories(System.AsyncCallback callback, object asyncState) {
      return this.BeginInvoke("retrieveBusinessCategories", new object[0], callback, asyncState);
      }

      ///
      public BusinessCategoryTypeArray EndretrieveBusinessCategories(System.IAsyncResult asyncResult) {
      object[] results = this.EndInvoke(asyncResult);
      return ((BusinessCategoryTypeArray)(results[0]));
      }
      }

      ///
      [System.Xml.Serialization.SoapTypeAttribute("BusinessCategoryTypeArray", "http://businessartifacts.tester.com")]
      public class BusinessCategoryTypeArray {

      ///
      public BusinessCategoryType[] businessCategoryTypes;
      }

      ///
      [System.Xml.Serialization.SoapTypeAttribute("BusinessCategoryType", "http://businessartifacts.tester.com")]
      public class BusinessCategoryType {

      ///
      public int businessCategoryID;

      ///
      public string businessCategoryName;
      }

      The program works fine when I use BusinessCategoryType. However if I use BusinessCategoryTypeArray I get the following exception:

      java.io.IOException: No serializer found for class com.tester
      .businessartifacts.BusinessCategoryTypeArray in registry org.apache.axis.encoding.TypeMappingImpl@a574b2

      I have searched in the forums and the net for this error but have been unable to resolve it. One thing that puzzles me is the fact that BusinessCategoryType is cited as the top of the C# file as follows:

      System.Xml.Serialization.SoapIncludeAttribute(typeof(BusinessCategoryType))]

      There is no similar entry for BusinessCategoryTypeArray but iI still get the error even if I add it manually. It is however mentioned in the J2EE wsdl file.

      Apologies for the length of this mail but would anyone know how I can resolve this error?

      Thanks for your help

      Martin