• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

HashMap transmission thru Apache SOAP

 
Ranch Hand
Posts: 147
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I need to call a method in service which returns HashMap containing key,value pairs. Though I'm able to transmit the HashMap from service to client but when it reaches the client, the HashMap object doesn't contain any values (it is returned empty) I dont know why it is so ? I have checked the service method which is being called, before returning it is printing on the console what its returning, so I assume problem is not with the server(service). I'm using the folowing code to receive HashMap at the client side :
SOAPMappingRegistry smr = new SOAPMappingRegistry();

BeanSerializer bsr = new BeanSerializer();
QName qn = new QName("urn:serviceName", "java.util.HashMap");

smr.mapTypes(Constants.NS_URI_SOAP_ENC, qn, java.util.HashMap.class, bsr, bsr);
call.setSOAPMappingRegistry(smr);
Response resp = null;
try {
resp = call.invoke(serviceURLInstance, "");
} catch(Exception e)
{ System.out.println("Exception ooccured in SOAPClient : "+e);
}
if ( resp.generatedFault() )
{
Fault fault = resp.getFault();
System.out.println("The call failed: ");
System.out.println("Fault Code = " + fault.getFaultCode());
System.out.println("Fault String = " + fault.getFaultString());
objReturn = (Object) "Fault";
}
else
{
System.out.println("success : "+ resp.getReturnValue().getValue());
return resp.getReturnValue().getValue();
}
Someone pls. help me. !!!
[ August 16, 2002: Message edited by: Sam Cala ]
 
author
Posts: 3892
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My guess is the beans serializer isn't going to work since the HashMap doesn't conform to the Java Beans spec. Try using a HashTable instead and it should work using the HashtableSerializer. See Bong's article on type mapping for details.
Kyle
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is that code actually building and returning a HashMap? Does it have the expected number of entries?
Bill
 
Sam Cala
Ranch Hand
Posts: 147
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Kyle, There is no way I can make the service return Hashtable since I'm connecting to some other firm's service & calling a method of that service so its not in my hands !! I need some way to get the HashMap supported.
Yes William, HashMap object is being returned but when it reaches the client, it doesn't have any entries. ITS EMPTY.
Pls. help !
 
Kyle Brown
author
Posts: 3892
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't understand -- so the other firm has already implemented a web service that uses a Hashmap? If so, do they have an example of making this work (it sounds like THEIR problem, not yours...). Have you hooked up a SOAP trace tool (like the one in Apache SOAP, e.g. TcpTunnelGui, or Bill's tool) to see if there is anything being transmitted (it's not enough to see if the server is producing a Hashmap -- you have to find out if anything is being transmitted in the HTTP).
Or are you implementing a web service on top of an existing API? If so, write a wrapper layer to convert one to the other.
Kyle
[ August 18, 2002: Message edited by: Kyle Brown ]
[ August 18, 2002: Message edited by: Kyle Brown ]
 
reply
    Bookmark Topic Watch Topic
  • New Topic