You are viewing a plain text version of this content. The canonical link for it is here.
Posted to soap-dev@xml.apache.org by "Per Engsberg (LMD)" <Pe...@lmd.ericsson.se> on 2001/11/06 16:57:03 UTC

IllegalArgumentException

Hi,

As a newbie I am experimenting with the different encoding styles. I use Tomcat 4.0 and have deployed a small service that returns an 'org.w3c.dom.Element'. 
When i call it using Literal XML encoding I get the following exception:

Generated fault:
  Fault Code   = SOAP-ENV:Server
  Fault String = java.lang.IllegalArgumentException: I only know how to serialize an 'org.w3c.dom.Element'.

If I change the encoding to SOAP I get this exception: 
Generated fault:
  Fault Code   = SOAP-ENV:Server
  Fault String = java.lang.IllegalArgumentException: No Serializer found to serialize a 'org.w3c.dom.Element' using encoding style 'http://schemas.xmlsoap.org/s
oap/encoding/'.

Can anyone enlighten me ?

Regards
Per Engsberg




The service is the following:

import com.sap.mw.jco.*;
import  org.w3c.dom.*;
import javax.xml.parsers.*;
import org.apache.soap.util.xml.*;


public class XmlElement {


      public Element getList()
    {

             DocumentBuilder xdb = XMLParserUtils.getXMLDocBuilder();
             Document doc = xdb.newDocument();

             Element joblist = doc.createElement("JobList");
             joblist.appendChild(doc.createTextNode("\n"));

			 Element listingEl = doc.createElement("Listing");
         	 Element item = doc.createElement("Job");       // Create element
         	 item.appendChild(doc.createTextNode("Programmer"));

			 listingEl.appendChild(doc.createTextNode("\n    "));
			 listingEl.appendChild(item);
		     listingEl.appendChild(doc.createTextNode("\n    "));

			 item = doc.createElement("Job");       // Create element
			 item.appendChild(doc.createTextNode("Secretary"));

			 listingEl.appendChild(item);
		     listingEl.appendChild(doc.createTextNode("\n  "));

			 joblist.appendChild(doc.createTextNode("  "));
	         joblist.appendChild(listingEl);
			 joblist.appendChild(doc.createTextNode("\n"));

             return joblist;

    }

    	public static void main(String[] argv)
		{
			XmlElement j = new XmlElement();
			Element joblist = j.getList();
            System.out.println(DOM2Writer.nodeToString(joblist));
		}

}