Problem Solved
and i'm not even sure why. i think it might be a problem with calling the method with a wrong set or type of variables.
i just the same line from a different example and ths works great.
Thanks for the time and partience.


Soactive Inc wrote:
There seems to be some issue with deserializing the response message
to the GoogleSearchResult object. Not sure what the real issue here
would be since the exception thrown does not seem to reveal the actual
cause.

I like to use dynamic invocations as opposed to static. Here is a code
snippet (feel to use it) that I used  for calling the Google Search
service (without invoking via stubs - you still need the complex types
though).

-Arun

// imports...

import org.apache.axis.encoding.ser.*;
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import javax.xml.rpc.ParameterMode;
import javax.xml.namespace.QName;

// also import the google complex type objects...


// in your Java code, use this code snippet (within a try/catch block)
// ....

        // define qnames
        String targetNamespace = "urn:GoogleSearch";
        String schemaNamespace = "urn:GoogleSearch";

        QName serviceName = new QName(targetNamespace, "GoogleSearchService");

        QName portName = new QName(targetNamespace, "GoogleSearchPort");
        QName operationName = new QName(schemaNamespace, "doGoogleSearch");

        // create service
        Service service = new Service();
        Call call = (Call) service.createCall();

        // set port and operation name
        call.setPortTypeName(portName);
        call.setOperationName(operationName);

        QName strQName = new QName("http://www.w3.org/2001/XMLSchema",
 "string");
        QName intQName = new QName("http://www.w3.org/2001/XMLSchema",  "int");
        QName boolQName = new
QName("http://www.w3.org/2001/XMLSchema",  "boolean");

        call.addParameter("key", strQName, ParameterMode.IN);
        call.addParameter("q", strQName, ParameterMode.IN);
        call.addParameter("start", intQName, ParameterMode.IN);
        call.addParameter("maxResults", intQName, ParameterMode.IN);
        call.addParameter("filter", boolQName, ParameterMode.IN);
        call.addParameter("restrict", strQName, ParameterMode.IN);
        call.addParameter("safeSearch", boolQName, ParameterMode.IN);
        call.addParameter("lr", strQName, ParameterMode.IN);
        call.addParameter("ie", strQName, ParameterMode.IN);
        call.addParameter("oe", strQName, ParameterMode.IN);

        // return type
	call.setReturnType(org.apache.axis.Constants.XSD_STRING);
	call.setReturnType(new QName("urn:GoogleSearch",
"GoogleSearchResult"), GoogleSearchResult.class);
	call.setReturnQName(new QName("", "return"));

	// register type mapping
	call.registerTypeMapping(GoogleSearchResult.class, new
QName("urn:GoogleSearch", "GoogleSearchResult"),
BeanSerializerFactory.class, BeanDeserializerFactory.class);
	call.registerTypeMapping(DirectoryCategory.class, new
QName("urn:GoogleSearch", "DirectoryCategory"),
BeanSerializerFactory.class, BeanDeserializerFactory.class);
	call.registerTypeMapping(ResultElement.class, new
QName("urn:GoogleSearch", "ResultElement"),
BeanSerializerFactory.class, BeanDeserializerFactory.class);

	// set end point address
        call.setTargetEndpointAddress("http://api.google.com/search/beta2");

	// execute
        // Invoke the WebService
        String key = ""; // set your key here
        String queryStr = "query"; // your search keyword
        GoogleSearchResult result = (GoogleSearchResult)
call.invoke(new Object[]{key,
		queryStr, new Integer(0), new Integer(10), new Boolean(false), null,
new Boolean(false),
			null, null, null});

	StringBuffer resultStrBuf = new StringBuffer();
	for (int i = 0; i < result.getResultElements().length; i++) {
		ResultElement element = result.getResultElements()[i];
		resultStrBuf.append((i+1) + ": " + element.getTitle() + "<br>");
	}

	System.out.println("Search Response: " + responseStrBuf.toString());





On 7/4/05, Moshe Bar-Nachoom <[EMAIL PROTECTED]> wrote:
  
 Sorry...
 my mistake.
 i tested for nullity (gsr == null) and i got false.
 then i tried to output the gsr, as is, to the screen and got "null"
 but i have the traffic. i can see it in the sniffer.
 what's going on there?
 help!!! :-)

 
 
 
 Moshe Bar-Nachoom wrote: 
 
 thanks Arun.
 1) gsr is not a null. i've tested it in various ways.
 
 2) the stack i get is very simple. it tells me i have an error: "Exception
in thread "Thread-1" java.lang.NullPointerException at
axisThread.run(Glycerine.java:637)".
 this is the line that i use to print some of the values i should'va gotten
in response from the server. although the communication seens to be ok, i
still get this null ppinter exception when trying to: gsr.getEndIndex() (for
example)
 
 an important thing to note is that the gsp.doGoogleSearch(..) method works
and creates a request and gets a response (i've
  monitored that using etherea)
 
 thanks for the help so far.
 desparately looking for the light at the end :)
 
 
 Soactive Inc wrote: 
 Moshe,

I am not an expert on this but will try to help...

Seems like gsr itself is null...Is that true? Also, do you have the stack
trace?

-Arun

On 7/3/05, Moshe Bar-Nachoom <[EMAIL PROTECTED]> wrote:
 
 
 hi all,
 i'm new here and hope i can find some answers.
 
 i used the wsdl2java utility to create the stub of the google api so i can
call it from axis.
 i try a simple search and look for a reply, which i try and print one of
its returning data.
 
 the call is very simple:
 GoogleSearchService gss = new GoogleSearchServiceLocator();
 GoogleSearchPort gsp = gss.getGoogleSearchPort();
 GoogleSearchResult gsr = gsp.doGoogleSearch(googleKey, "search word" 0, 10,
true, "", false, "", "", "");
 
 what i try and do in return is display the value of:
 gsr.getEstimatedTotalResultsCount() and / or
gsr.getSearchTime()
 for which i get an error:
 SOAP messaging exception: null
 java.lang.NullPointerException
 
 i ran ethereal to review traffic and it seems there's a full qualified SOAP
messaging going around where the client sends the request object and gets
the response object.SOAP messaging exception: null
 java.lang.NullPointerException
 
 
 it seems to me the ptoblem is in the way i read and use the data from the
returning response.
 can you please help? this is rather urgent and i need every bit of info i
can put my hands on.
 
 thank you very much.
 moshe
 
 

 
 
 
 
 

    


  

Reply via email to