The Artima Developer Community
Sponsored Link

Web Services Forum
How to serialize java.util.Hashtable element in JavaBean

1 reply on 1 page. Most recent reply: Dec 15, 2005 4:02 AM by Marin Tzvetkov

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 1 reply on 1 page
Marin Tzvetkov

Posts: 3
Nickname: mtzvetkov
Registered: Dec, 2005

How to serialize java.util.Hashtable element in JavaBean Posted: Dec 14, 2005 9:03 AM
Reply to this message Reply
Advertisement
Hello
I have the following problem. I just have a web service client, that invokes a method from a webservice. The method gets a JavaBeans class(TestClass) as a parameter. It has 2 elements a java.lang.String and java.util.Map. On invocation I am getting the Exception:

faultString: org.xml.sax.SAXException: No object was found for class type class java.util.Hashtable

Could smb please help me

I am pasting the rest from the exception, my wsdd, my service class, client class and the TestClass

=========================Exception==========================
AxisFau lt
faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException
faultSubcode:
faultString: org.xml.sax.SAXException: No object was found for class type class java.util.Hashtable
faultActor:
faultNode:
faultDetail:
{http://xml.apache.org/axis/}hostname:toshko

org.xml.sax.SAXException: No object was found for class type class java.util.Hashtable
at org.apache.axis.message.SOAPFaultBuilder.createFault(SOAPFaultBuilder.java:222)
at org.apache.axis.message.SOAPFaultBuilder.endElement(SOAPFaultBuilder.java:129)
at org.apache.axis.encoding.DeserializationContext.endElement(DeserializationConte xt.java:1087)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endElement(Abstrac tSAXParser.java:633)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanEndElement (XMLNSDocumentScannerImpl.java:719)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$Fragment ContentDispatcher.dispatch(XMLDocumentFragmentScannerImpl.java:1685)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocu ment(XMLDocumentFragmentScannerImpl.java:368)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Config uration.java:834)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Config uration.java:764)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:148)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXP arser.java:1242)
at javax.xml.parsers.SAXParser.parse(SAXParser.java:375)
at org.apache.axis.encoding.DeserializationContext.parse(DeserializationContext.ja va:227)
at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:696)
at org.apache.axis.Message.getSOAPEnvelope(Message.java:435)
at org.apache.axis.transport.http.HTTPSender.readFromSocket(HTTPSender.java:796)
at org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:144)
at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32)
at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)
at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)
at org.apache.axis.client.AxisClient.invoke(AxisClient.java:165)
at org.apache.axis.client.Call.invokeEngine(Call.java:2784)
at org.apache.axis.client.Call.invoke(Call.java:2767)
at org.apache.axis.client.Call.invoke(Call.java:2443)
at org.apache.axis.client.Call.invoke(Call.java:2366)
at org.apache.axis.client.Call.invoke(Call.java:1812)
at test.WS.TestServ.main(TestServ.java:55)
=========================Exception===== =====================

=======================The Client===========================
package test.WS;

import java.util.Hashtable;
import java.util.Map;

import javax.xml.namespace.QName;
import javax.xml.rpc.ParameterMode;

import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import org.apache.axis.encoding.ser.BeanDeserializerFactory;
import org.apache.axis.encoding.ser.BeanSerializerFactory;
import org.apache.axis.encoding.ser.MapDeserializerFactory;
import org.apache.axis.encoding.ser.MapSerializerFactory;

public class TestServ {

public static void main(String[] args) {

Hashtable m = new Hashtable();
m.put("arg1", "arg1 Obj");
m.put("arg2", "arg2 Obj");
m.put("arg3", "arg3 Obj");

TestClass tc = new TestClass(m, "hallo");

String endpoint = "http://localhost:8080/axis/services/TestService";
String method = "testMap";

Service service = new Service();
Call call = null;
try {

call = (Call) service.createCall();

call.setTargetEndpointAddress(new java.net.URL(endpoint));
call.setOperationName(method);

QName qn = new QName("UDDIProperties", "BusinessProperties");

QName qn2 = new QName("UDDIProperties", "BusinessMap");
call.addParameter("tc", qn, ParameterMode.IN);

call.registerTypeMapping(TestClass.class, qn,
new BeanSerializerFactory(TestClass.class, qn),
new BeanDeserializerFactory(TestClass.class, qn));
/*
call.registerTypeMapping(TestClass.class, qn2,
new MapSerializerFactory(Map.class, qn2),
new MapDeserializerFactory(Hashtable.class, qn2));
*/
Object res = call.invoke(new Object[] { tc });

System.out.println(res.toString());

} catch (Exception e) {
e.printStackTrace();
}
}

}
=======================The Client End=======================

=======================The Service==========================
package tuberlin.sysedv.srvmngmt.client.webservices;

import java.util.Hashtable;

import test.WS.TestClass;

public class TestService {

public static String testMap (Object o) {

TestClass tc = (TestClass)o;
System.out.println ("Ausführen testMap");

return "Nachricht bekommen"+tc.getMap().size();
}

}
=======================The Service End=====================

=======================TestClass=====================
package test.WS;

import java.io.Serializable;
import java.util.Hashtable;

public class TestClass implements Serializable{

private String desc;

private Hashtable map;
public TestClass(Hashtable map, String desc) {
super();
// TODO Auto-generated constructor stub
this.map = map;
this.desc = desc;
}
public String getDesc() {
return desc;
}
public void setDesc(String desc) {
this.desc = desc;
}
public Hashtable getMap() {
return map;
}
public void setMap(Hashtable map) {
this.map = map;
}

}

=======================TestClass End=====================

=======================WSDD==========================
<deployment xmlns="http://xml.apache.org/axis/wsdd/"
xmlns:java="http://xml.apache.org/axis/wsdd/providers/java">
<service name="TestService" provider="java:RPC">
<requestFlow>
<handler type="soapmonitor"/>
</requestFlow>
<responseFlow>
<handler type="soapmonitor"/>
</responseFlow>
<parameter name="className" value="tuberlin.sysedv.srvmngmt.client.webservices.TestService"/>
<parameter name="allowedMethods" value="*"/>

<typeMapping
qname="ns:BusinessProperties"
xmlns:ns="UDDIProperties"
type = "java:test.WS.TestClass"
serializer="org.apache.axis.encoding.ser.BeanSerializerFactory"
deserializer="org.apache.axis.encoding.ser.BeanDeserializerFactory"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
/>

<typeMapping
qname="ns:BusinessMap"
xmlns:ns="UDDIProperties"
type = "java:java.util.Hashtable"
serializer="org.apache.axis.encoding.ser.MapSerializerFactory"
deserializer="org.apache.axis.encoding.ser.MapDeserializerFactory"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
/>

</service>
</deployment>
=======================WSDD END==========================

===================SOAP MONITOR - REQUEST==================
<?xml version="1.0" encoding="utf-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<testMap soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<tc href="#id0"/>
</testMap>
<multiRef id="id0" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="ns1:BusinessProperties" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns1="UDDIProperties">
<desc xsi:type="soapenc:string">hallo</desc>
<map href="#id1"/>
</multiRef>
<multiRef id="id1" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="ns2:Map" xmlns:ns2="http://xml.apache.org/xml-soap" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
<item>
<key xsi:type="soapenc:string">arg3</key>
<value xsi:type="soapenc:string">arg3 Obj</value>
</item>
<item>
<key xsi:type="soapenc:string">arg2</key>
<value xsi:type="soapenc:string">arg2 Obj</value>
</item>
<item>
<key xsi:type="soapenc:string">arg1</key>
<value xsi:type="soapenc:string">arg1 Obj</value>
</item>
</multiRef>
</soapenv:Body>
</soapenv:Envelope>


===================NO RESPONCE============================


Marin Tzvetkov

Posts: 3
Nickname: mtzvetkov
Registered: Dec, 2005

Re: How to serialize java.util.Hashtable element in JavaBean Posted: Dec 15, 2005 4:02 AM
Reply to this message Reply
I'm using Axis 1.3 and Java 1.5_5

Flat View: This topic has 1 reply on 1 page
Topic: how to retriview  complex data type from a soap web services? Previous Topic   Next Topic Topic: Axis : problem with java.util.List objects !

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use