Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

almost there - BUT exception in client :-)

1 view
Skip to first unread message

rajiv

unread,
Oct 15, 2002, 11:01:56 PM10/15/02
to
I am getting the following exception - any help ?
***********************************************

Exception in thread "main" [SOAPException: faultCode=SOAP-ENV:Client;
msg=No Des
erializer found to deserialize a 'urn:GoogleSearch:GoogleSearchResult'
using enc
oding style 'http://schemas.xmlsoap.org/soap/encoding/'.;
targetException=java.l
ang.IllegalArgumentException: No Deserializer found to deserialize a
'urn:Google
Search:GoogleSearchResult' using encoding style
'http://schemas.xmlsoap.org/soap
/encoding/'.]
at org.apache.soap.rpc.Call.invoke(Call.java:246)
at com.rajivnarula.google.Google.search(Google.java:72)
at com.rajivnarula.google.Google.main(Google.java:88)


*******************************************

I am writing my own soap client to call google API
here is the code ....

*******************************************

public class Google {

public Google (){
}

public String endpoint = "http://api.google.com/search/beta2";

public void search ()throws Exception{

URL endpointURL = new URL(endpoint);
Call call = new Call();
call.setTargetObjectURI("urn:GoogleSearch");
call.setMethodName("doGoogleSearch");
call.setEncodingStyleURI(Constants.NS_URI_SOAP_ENC);


SOAPMappingRegistry smr = new SOAPMappingRegistry();
BeanSerializer bsr = new BeanSerializer();
QName qn = new QName("urn:GoogleSearch:GoogleSearchResult",
"com.google.soap.search.GoogleSearchResult");

smr.mapTypes(Constants.NS_URI_SOAP_ENC, qn,
com.google.soap.search.GoogleSearchResult.class, bsr, bsr);
call.setSOAPMappingRegistry(smr);

Vector params = new Vector();
params.addElement(new Parameter("key", String.class, "I have
removed the key from this message", null));
params.addElement(new Parameter("q", String.class, "shrdlu
winograd maclisp teletype", null));

params.addElement(new Parameter("start", Integer.class, "0",
null));
params.addElement(new Parameter("maxResults", Integer.class, "10",
null));
params.addElement(new Parameter("filter", Boolean.class, "true",
null));

params.addElement(new Parameter("restrict", String.class, "",
null));
params.addElement(new Parameter("safeSearch", Boolean.class,
"false", null));

params.addElement(new Parameter("lr", String.class, "", null));
params.addElement(new Parameter("ie", String.class, "latin1",
null));
params.addElement(new Parameter("oe", String.class, "latin1",
null));

//Parameter param1 = new Parameter("name",
sam.soap.client.Person.class, nameObject, null);

call.setParams(params);
Object returnVal = null ;
Response response = call.invoke(endpointURL, "");
if (!response.generatedFault())
{
Parameter result = response.getReturnValue();
returnVal = result.getValue();
}
else
{
Fault fault = response.getFault();
throw new SOAPException(fault.getFaultCode(),
fault.getFaultString());
}
}
public static void main (String args[])throws Exception{
new Google ().search ();
}
}

0 new messages