Re: Two long params.

[email protected] Mon, 28 Apr 2003 12:20:35 +0200 (MEST)
Newsgroups gmane.comp.java.enhydra.ksoap
Message-ID <[email protected]>
Hi Stefan,

I am sorry I have not responded to your post  recently.
I was completetly off-line for one week (I have not used computer for one
week :-)

> I did not find anything obvious in the code... can you try printing the
> value
> of soapReq.toString() to see whether it is constructed correctly?
OK so here are some more details about this problem:

On the client side it looks like this:

--- REQUEST ---

<SOAP-ENV:Envelope
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns:xsd="http://www.w3.org/2001/XMLSchema"
  xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
  xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
 <SOAP-ENV:Body
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
  <endChat xmlns="/chat" id="o0" SOAP-ENC:root="1">
   <arg0 xmlns="" xsi:type="xsd:long">123</arg0>
   <arg1 xmlns="" xsi:type="xsd:long">342</arg1>
  </endChat>
 </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

--- END ---

--- RESPONE ---

<SOAP-ENV:Envelope xmlns:n0="/chat"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns:xsd="http://www.w3.org/2001/XMLSchema"
  xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
  xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
 <SOAP-ENV:Body>
  <SOAP-ENV:Fault>
   <faultcode>Server</faultcode>
   <faultstring>null</faultstring>
   <detail />
  </SOAP-ENV:Fault>
 </SOAP-ENV:Body>
</SOAP-ENV:Envelope>
--- END ---

these are the values of HttpTransport requestDump, responseDump debug
variables.
Below you will find the  body of my "debug" version of invoke method (it is
rewritten invoke method
from org.ksoap.servlet.SoapServlet with some debug output):

    String name = soapReq.getName();
    Class types[] = new Class[soapReq.getPropertyCount()];
    Object[] args = new Object[soapReq.getPropertyCount()];
    PropertyInfo arg = new PropertyInfo();

    for (int i = 0; i < types.length; i++) {
      soapReq.getPropertyInfo(i, arg);
      types[i] = (Class) arg.type;
      args[i] = soapReq.getProperty(i);
       // __________ this was added to see params values ________________
      System.out.println("Added type/property: " + types[i] + "/" +
args[i]);
   }

    // expensive invocation here..  optimize with method cache,
    // want to support method overloading so need to figure in
    // the arg types..

    Method method = service.getClass().getMethod(name, types);
    //  __________ this was added to see method name ________________
     System.out.println("method: " + method.getName());
    Object result = method.invoke(service, args);
    SoapObject response =
      new SoapObject(soapReq.getNamespace(), name + "Response");
    if (result != null)
      response.addProperty("return", result);

    return response;

If you take a look back at the previous post I have sent you will see
that envelope seems to be received correctly by servlet.
If you also take a look at the exception in previous post you should also
see
that correct method was found (or at least some method with two long params
- now I have added
one more debug out - to see found method name - it is "endChat").
The problem is that the method has two paramters and the second parameter
somehow is getting lost during parsing the envelope? So during invocation
following array is passed to method { new Long(342), null }.

A.

PS. If you are intereasted in whole sample (I am just learning SOAP - the
sample is not done on
comercial purpose) I can send it to you. I do not remeber if it is allowed
to send attachments to this
newsgroup so I would send it to you directly - if you are intereasted..

-- 
+++ GMX - Mail, Messaging & more  http://www.gmx.net +++
Bitte lächeln! Fotogalerie online mit GMX ohne eigene Homepage!