SiteExperts.com Logo Home | Community | Developer's Paradise
User Groups | Site Tools | Site Information | Search
 Main Menu
 Forums
SiteExperts.com Forums
All Discussions

SiteExperts Feedback
The Lounge
Dynamic HTML
Site Design/ Critiques
HTML and CSS
XML Technologies
The Wireless Internet
Internet Explorer
Microsoft .NET
The Server
Technical Support

Sponsored Links

User Groups : Forums : SiteExperts : XML Technologies :

Previous DiscussionNext Discussion
 SOAPException: faultCode=SOAP-ENV:Client; msg=No Deserializer found to dese

hi,
     i am using tomcat 4.1, jdk 1.4 and soap 2.3.1...i have set classpath all required jar files(mail.jar,activation.jar,xerces.jar,soap.jar) and deploy service on server successfully...
Service program---

/** Simple test of String and String[] parameters and return values */
public class HelloService1
{
    /** Says hello to one person */
    public String helloString(String name)
    {
        return "Hello, " + name;
    }
    /** Says hello to many people */
    public String[] helloStringArray(String[] names)
    {
        String[] ret = new String[names.length];
        for (int i = 0; i < names.length; i++)
            ret[i] = "Hello, " + names[i];
        return ret;
    }
}

Client program---

import java.net.*;
import java.util.*;
import org.apache.soap.*;
import org.apache.soap.rpc.*;
import org.apache.soap.encoding.*;
/** Simple test of String and String[] parameters and return values */
public class HelloClient1
{
    /** Gets the type of a class as a string */
    private static String getType(Class c)
    {
        if (!c.isArray())
            return c.getName();

        return "array of " + getType(c.getComponentType());
    }
   
    /** Gets the value of an object as a string */
    private static String getValue(Object o)
    {
        Class c = o.getClass();
        if (!c.isArray())
            return "'" + o.toString() + "'";

        String ret = null;
        Object[] oa = (Object[]) o;
        for (int i = 0; i < oa.length; i++) {
            if (ret == null)
                ret = "[" + getValue(oa[i]);
            else
                ret = ret + ", " + getValue(oa[i]);
        }
        return ret + "]";
    }
   
    /** Makes a SOAP call */
    private static void makeCall(String targetURI,
                                 String methodName,
                                 String encodingStyleURI,
                                 SOAPMappingRegistry smr,
                                 Vector parameters,
                                 String endpointURL) throws Exception {
        Call call = new Call();
        call.setTargetObjectURI(targetURI);
        call.setMethodName(methodName);
        call.setEncodingStyleURI(encodingStyleURI);
        if (smr != null)
            call.setSOAPMappingRegistry(smr);
        call.setParams(parameters);

        System.out.print("Call to method '" +
                         methodName +
                         "' of object '" +
                         targetURI + "' ");
        Response resp = call.invoke(new URL(endpointURL),
                                    targetURI);
     //     System.out.println(resp);
        if (resp.generatedFault())
        {
          Fault fault = resp.getFault();
          System.out.println("faulted:");
          System.out.println("  Code = " + fault.getFaultCode());  
          System.out.println("  String = " + fault.getFaultString());
        }
        else
        {
          Parameter result = resp.getReturnValue();
          Object value = result.getValue();
          System.out.println("returned:");
          System.out.println("  Type = " + getType(value.getClass()));
          System.out.println("  Value = " + getValue(value));
        }
    }
   
    /** Tests a service using String and String[] parameters and return values */
    public static void main(String[] args) throws Exception
    {
        if (args.length < 2)
        {
            System.err.println("Usage: java HelloClient1 SOAP-router-URL name [name ...]");
            System.exit(1);
        }
   
        String targetURI = "urn:hello1";
        String methodName = "helloString";
        String encodingStyleURI = Constants.NS_URI_SOAP_ENC;
        Vector params = new Vector();
        params.addElement(new Parameter("name", String.class, args[1], null));
        String endpointURL = args[0];
     //     System.out.println(params);
     //     System.out.println(endpointURL);
        makeCall(targetURI, methodName, encodingStyleURI, null, params, endpointURL);

        methodName = "helloStringArray";
        String[] names = new String[args.length - 1];
        for (int i = 0; i < args.length - 1; i++)
        {
            names[i] = args[i + 1];
        //    System.out.println(names[i]);
        }
        params = new Vector();
        params.addElement(new Parameter("names", names.getClass(), names, null));

        makeCall(targetURI, methodName, encodingStyleURI, null, params, endpointURL);
    }
}



when i run client program then i recieved an error.. Error is......

Call to method 'helloString' of object 'urn:hello1' Exception in thread "main" [
SOAPException: faultCode=SOAP-ENV:Client; msg=No Deserializer found to deseriali
ze a ':return' using encoding style 'http://schemas.xmlsoap.org/soap/encoding/'.
; targetException=java.lang.IllegalArgumentException: No Deserializer found to d
eserialize a ':return' using encoding style 'http://schemas.xmlsoap.org/soap/enc
oding/'.]
        at org.apache.soap.rpc.Call.invoke(Call.java:244)
        at HelloClient1.makeCall(HelloClient1.java:55)
        at HelloClient1.main(HelloClient1.java:92)

please give me reasion of this exception
thanks and regards
mahesh

Started By maheshjangir on Jan 11, 2006 at 1:36:44 AM

5 Response(s) | Reply

Earlier Replies | Replies 1 to 5 of 5 | Later Replies
MHenke on Jan 11, 2006 at 2:22:07 AM (# 1)

Your SOAP endpoint returns a value in an XML element named "return".
I guess that this element has no "xsi:type" atttribute, therefore it can't be deserialized
in an corresponding Java Object since the type information is missing (Java can't guess
what lurks behind that "return" thing).
You've to add that attribute to the SOAP response (the type should be "string" for the first
method in your example) or you've to provide an explicit type mapping for the client, e.g.:

SOAPMappingRegistry soapMappingRegistry = new SOAPMappingRegistry();
soapMappingRegistry.mapTypes(Constants.NS_URI_SOAP_ENC, new QName("", "return"),
                             null, null, new StringDeserializer());
call.setSOAPMappingRegistry(soapMappingRegistry);


maheshjangir on Jan 11, 2006 at 4:27:23 AM (# 2)

thanks MHenke, i solve my problem with explicit type mapping,but i don't understand first option

bye

mahesh


MHenke on Jan 11, 2006 at 5:57:23 AM (# 3)

> but i don't understand first option
A (typical) SOAP reponse for your example could looks like that:
<?xml version='1.0' encoding='UTF-8'?>
<SOAP-ENV:Envelope
   xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<SOAP-ENV:Body>
<ns1:helloStringResponse xmlns:ns1="urn:hello1"
   SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<return xsi:type="xsd:string">Hello, maheshjangir</return>
</ns1:helloStringResponse>

</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
The emphasized attribute specifies an XML Schema data type for the result element, for that a (compliant) Client can perform a default mapping
to the corresponding Java data type.
If that attribute is missing in the SOAP response (or the client lacks the ability for the standard mappings), you've to do explicit mapping.
BTW, it's not the best netiquette do leave a thread after getting help and don't come back with a follow up/issue closed or whatever posting.

123452011 on Jan 10, 2011 at 2:20:42 PM (# 4)

hi all,

I need to do the same change in server side because i am not supposed to change the client java file ..(I did tried changing the client java file it works)..

 

But i wanted to know is there any way to put some conf stuff in wsdl or any patch in weblogic for this issue ?

Thanks in advance


bod1467 on Jan 12, 2011 at 8:42:42 AM (# 5)

Necropost almost 5 years to the day? Impressive. :-)


Earlier Replies | Replies 1 to 5 of 5 | Later Replies

To respond to a discussion, you must first logon.

If you are not registered, please register yourself to become a member of the SiteExperts.community.

User Name
Password
Copyright 1997-2004 InsideDHTML.com, LLC. All rights reserved.