You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by NY...@aol.com on 2004/07/15 19:00:02 UTC

Please Help Re: Returning an Array over Axis

 
Changing the WSDL from Document to Wrapped does not help eliminate the  
ClassCastException
 
Does anybody have any ideas what could be bugging this program?
 
In a message dated 7/15/2004 12:49:06 PM Eastern Standard Time,  
an4m@cs.virginia.edu writes:

I think  you should be okay, but I am in the process of
migrating from rpc/encoded  to wrapped/literal, so I can't
say for sure.

Anand

On Thu, 15  Jul 2004 NYY96@aol.com wrote:

:
: Can I get away with  wrapped/literal for .net compatibilty?
:
: In a message dated 7/15/2004  10:28:41 AM Eastern Standard Time,
: an4m@cs.virginia.edu writes:
:
:  James,
:
: I noticed the SOAP response I pasted below when I used   an
: interactive tool to send/receive SOAP messages. That tool
: is good  for  testing, not production. For production, I
: switched to  wrapped/literal, and  clients targetting that
: get back an array just  fine.
:
: wrapped/literal  is supposed to be equivalent to  document/literal
: (except, of course, for an  additional enclosing  tag). Would
: it be possible for you to change your  server to  wrapped/literal?
:
: Anand
:
: On Thu, 15 Jul 2004   NYY96@aol.com wrote:
:
: : Thank you for your responses,
: :
: : I  was  wondering if you could tell me exactly what you did to get it  ot
: work.
: : Currently an array is is the needed type in my java (yes  I   use 
Doc/Lit),
: : however the error occurs anyway.
:  :
: : Please  help,
: : James
: :
: : In a message dated  7/14/2004 7:00:42 PM Eastern  Standard Time,
: : an4m@cs.virginia.edu  writes:
: :
: : James,
: :
: :  I'll back off from my claim  that there's a  problem.
: : When I write a  class/interface that  has a method
: : that returns a  string array, the  WSDL seems to  indicate
: : that the return is a single  xsd:string. Even   the
: : stubs generated from the WSDL show a return of  String.
:  :  However, when I actually invoke the method, I do get
: : back  the   array, just in different  namespaces:
: :
: :  ...
: :  <soapenv:Body>
: : <echoArrReturn    xmlns="urn:EchoDocLit">vlad</echoArrReturn>
: :   <ns1:echoArrReturn    xmlns:ns1="urn:EchoDocLit">is</ns1:echoArrReturn>
: :   <ns2:echoArrReturn
:  xmlns:ns2="urn:EchoDocLit">sanguine</ns2:echoArrReturn>
: :   </soapenv:Body>
: : ...
: :
: : Perhaps  that's what the  spec  for doc/lit indicates, but
: : it seems unintuitive to   me.
: :
: :  I'm moving over to wrapped/literal after this   experience;
: : perhaps  you could do the same.
: :
: :  Anand
: :
: : On Wed, 14  Jul 2004,  Anand Natrajan  wrote:
: :
: : : Is your web service exposed as a    document/literal?
: : : If yes, I face a similar problem - Axis 1.2  beta
: :  :  (June 14th release) makes the return type of  the
: : : method a  String, instead  of String[]. The  problem
: : : is right where I do  java2wsdl - even the WSDL,   I
: : : think, is incorrrect. The problem  does not occur
: : :  with rpc/encoded,  rpc/literal or  wrapped/literal.
: : :
: :  : I mailed a post about this a week or  so  ago but got
: : : no  response. I'm compiling a test case along with
: : :  the  WSDL  and sample clients to illustrate the issue.
: : : Next  post...
: :  :
: : :  Anand
: : :
: : : On Wed, 14 Jul 2004   NYY96@aol.com wrote:
: : :
: : : :
: : : : I  have a very nice  Axis  Web Service running in which I call a 
"query"
: : : :   function which  returns an arbitrarily sized array of type String[].
:  : :  :
: : : : I  call the axis implementation file with the  following call (Assume
: all
: : : : setup of service is correct):
:  : : :
: : : :  java.lang.String[]  yes_list =
: :   (java.lang.String[])handler.query(groupName,
: : : : password,    accountName, conditions);
: : : :
: : : : handler.query is the  function  which  returns the String[]. 
Regardless,
: : this
:  : : : function,  while actually  successfully running through Axis,  brings
: about
: :  the
: : : : following exception  on the  local machine:
: : : :
: : : :  java.lang.ClassCastException
: :  : :  java.lang.ClassCastException
: :  : : at  $Proxy0.query(Unknown Source)
: : : :  at
: : : :
: :
:  
_2._0._0._127.axis.services.adminHandlerServicePort.adminHandlerClient2.main(adminHandler
:  :  :  : Client2.java:77)
: : : :
: : : : I have checked the  mailing list  for possible  causes but to know 
avail.
: :  Would
: : : : somebody be  kind enough to offer  some advice as  to how I could stop
: this
: : : :  message from coming up?
: :  :  :
: : : : Below is my client  program:
: : : :  package   placeholder.axis.services.clientHandlerServicePort;
: :  : :
: : : : public  class  clientHandlerClient2
: : : : {
:  : : : static String   url   =
: : : :    "_http://placeholder/axis/services/clientHandlerServicePort_
: :   (http://placeholder/axis/services/clientHandlerServicePort) ";
: : :  :  static  String router  =   "_http://placeholder/axis/clientDirect_
: : : :    (http://placeholder/axis/clientDirect) ";
: : : :
: : : :   static String service =  "clientDirectService.wsdl";
: :  : :
: :  : :
: : : :  public static void main(String[]   args)
: : : :  {
: : : : try
: : : : {
: : :  :  System.err.println("This Client tests  getReport");
: : : :
: : :  :   ServiceFactory sf =    ServiceFactory.newInstance();
: : : :  URL u = new URL(router +  "/"  +  service);
: : : : QName  serviceName  =  new   QName(url,"clientHandlerService");
: : : : Service s  =   sf.createService(u,serviceName);
: : : :
: : : :   QName portName  = new    QName(url,"clientHandlerServicePort");
: : : :
: : : :   List  handlerChain =
: : : :    s.getHandlerRegistry().getHandlerChain(portName);
: : : : HandlerInfo  hi  =  new  HandlerInfo(LoggingHandler.class,null,null);
: :  : :   handlerChain.add(hi);
: : : :
: : : :     //Checking for  proper syntax of   call
: : : :  if   (args.length!=3)
: : : : {
: : :  :  System.err.println("Incorrect  usage of  Client. Please use  the
: :  following:");
: : : :   System.err.println("clientHandlerClient" + "  [Account Name]" +   "
: : : :  [Password]" + "     [Conditions]");
: : :  : }
: : : : else
: : : :  {
: : : :   System.out.println("Thank You. Processing. . .");
: : : :    ClientHandler  handler = (ClientHandler) s.getPort(portName,
: :  :  :  ClientHandler.class);
: : : :
: : : :    String  accountName    =  args[0];
: : : : String  password   =  args[1];
: : : :  String conditions =  args[2];
: : :  :
: : : : if(s == null)
: : : :   System.out.println("Service Not  Working Properly");
: : : :
: : :  :    String[] queryList =  handler.query(accountName,  password,
: : conditions);
: : : :
: : :  :    System.out.println("Testing in  csv  format");
: : :  :  String format = "csv";
: : : :
: : : :    String[]  rawQueryList  = handler.getQuery(accountName, password,
: :  queryList,
: : : :  format);
: : : :
: : : :     System.out.println("Finished.");
: :  : : }
: : : : }
: : :  :  catch(Exception  e)
: : : : {
: : : :   System.err.println("Error  running  Client:");
: : : :   System.err.println(e);
: : : :  e.printStackTrace();
: : : : }
:  : : :  }
: : : : }
: : : :
: : : : I would  appreciate any  comments on this  manner. I have checked the
: : : :  axis-mailing  list for previous  solutions however have found none  
have
: : been  helpful  for
: :  : : me to diagnose.
:  : : :
: : : : Sincere Thanks,
: : : : James   Crosson
:  :
: :
: :
: :
:  :
:
:
:
:
:





Re: Please Help Re: Returning an Array over Axis

Posted by Anand Natrajan <an...@cs.virginia.edu>.
James,

Instead of casting the results right away to String[], try setting the
results to Object or Object[] and then doing a getClass on that object to
see what the run-time class is. Knowing what the runtime class is may give
you insights into what the service is returning and what your client must
do.

Anand

On Thu, 15 Jul 2004 NYY96@aol.com wrote:

:
: Changing the WSDL from Document to Wrapped does not help eliminate the
: ClassCastException
:
: Does anybody have any ideas what could be bugging this program?
:
: In a message dated 7/15/2004 12:49:06 PM Eastern Standard Time,
: an4m@cs.virginia.edu writes:
:
: I think  you should be okay, but I am in the process of
: migrating from rpc/encoded  to wrapped/literal, so I can't
: say for sure.
:
: Anand
:
: On Thu, 15  Jul 2004 NYY96@aol.com wrote:
:
: :
: : Can I get away with  wrapped/literal for .net compatibilty?
: :
: : In a message dated 7/15/2004  10:28:41 AM Eastern Standard Time,
: : an4m@cs.virginia.edu writes:
: :
: :  James,
: :
: : I noticed the SOAP response I pasted below when I used   an
: : interactive tool to send/receive SOAP messages. That tool
: : is good  for  testing, not production. For production, I
: : switched to  wrapped/literal, and  clients targetting that
: : get back an array just  fine.
: :
: : wrapped/literal  is supposed to be equivalent to  document/literal
: : (except, of course, for an  additional enclosing  tag). Would
: : it be possible for you to change your  server to  wrapped/literal?
: :
: : Anand
: :
: : On Thu, 15 Jul 2004   NYY96@aol.com wrote:
: :
: : : Thank you for your responses,
: : :
: : : I  was  wondering if you could tell me exactly what you did to get it  ot
: : work.
: : : Currently an array is is the needed type in my java (yes  I   use
: Doc/Lit),
: : : however the error occurs anyway.
: :  :
: : : Please  help,
: : : James
: : :
: : : In a message dated  7/14/2004 7:00:42 PM Eastern  Standard Time,
: : : an4m@cs.virginia.edu  writes:
: : :
: : : James,
: : :
: : :  I'll back off from my claim  that there's a  problem.
: : : When I write a  class/interface that  has a method
: : : that returns a  string array, the  WSDL seems to  indicate
: : : that the return is a single  xsd:string. Even   the
: : : stubs generated from the WSDL show a return of  String.
: :  :  However, when I actually invoke the method, I do get
: : : back  the   array, just in different  namespaces:
: : :
: : :  ...
: : :  <soapenv:Body>
: : : <echoArrReturn    xmlns="urn:EchoDocLit">vlad</echoArrReturn>
: : :   <ns1:echoArrReturn    xmlns:ns1="urn:EchoDocLit">is</ns1:echoArrReturn>
: : :   <ns2:echoArrReturn
: :  xmlns:ns2="urn:EchoDocLit">sanguine</ns2:echoArrReturn>
: : :   </soapenv:Body>
: : : ...
: : :
: : : Perhaps  that's what the  spec  for doc/lit indicates, but
: : : it seems unintuitive to   me.
: : :
: : :  I'm moving over to wrapped/literal after this   experience;
: : : perhaps  you could do the same.
: : :
: : :  Anand
: : :
: : : On Wed, 14  Jul 2004,  Anand Natrajan  wrote:
: : :
: : : : Is your web service exposed as a    document/literal?
: : : : If yes, I face a similar problem - Axis 1.2  beta
: : :  :  (June 14th release) makes the return type of  the
: : : : method a  String, instead  of String[]. The  problem
: : : : is right where I do  java2wsdl - even the WSDL,   I
: : : : think, is incorrrect. The problem  does not occur
: : : :  with rpc/encoded,  rpc/literal or  wrapped/literal.
: : : :
: : :  : I mailed a post about this a week or  so  ago but got
: : : : no  response. I'm compiling a test case along with
: : : :  the  WSDL  and sample clients to illustrate the issue.
: : : : Next  post...
: : :  :
: : : :  Anand
: : : :
: : : : On Wed, 14 Jul 2004   NYY96@aol.com wrote:
: : : :
: : : : :
: : : : : I  have a very nice  Axis  Web Service running in which I call a
: "query"
: : : : :   function which  returns an arbitrarily sized array of type String[].
: :  : :  :
: : : : : I  call the axis implementation file with the  following call (Assume
: : all
: : : : : setup of service is correct):
: :  : : :
: : : : :  java.lang.String[]  yes_list =
: : :   (java.lang.String[])handler.query(groupName,
: : : : : password,    accountName, conditions);
: : : : :
: : : : : handler.query is the  function  which  returns the String[].
: Regardless,
: : : this
: :  : : : function,  while actually  successfully running through Axis,  brings
: : about
: : :  the
: : : : : following exception  on the  local machine:
: : : : :
: : : : :  java.lang.ClassCastException
: : :  : :  java.lang.ClassCastException
: : :  : : at  $Proxy0.query(Unknown Source)
: : : : :  at
: : : : :
: : :
: :
: _2._0._0._127.axis.services.adminHandlerServicePort.adminHandlerClient2.main(adminHandler
: :  :  :  : Client2.java:77)
: : : : :
: : : : : I have checked the  mailing list  for possible  causes but to know
: avail.
: : :  Would
: : : : : somebody be  kind enough to offer  some advice as  to how I could stop
: : this
: : : : :  message from coming up?
: : :  :  :
: : : : : Below is my client  program:
: : : : :  package   placeholder.axis.services.clientHandlerServicePort;
: : :  : :
: : : : : public  class  clientHandlerClient2
: : : : : {
: :  : : : static String   url   =
: : : : :    "_http://placeholder/axis/services/clientHandlerServicePort_
: : :   (http://placeholder/axis/services/clientHandlerServicePort) ";
: : : :  :  static  String router  =   "_http://placeholder/axis/clientDirect_
: : : : :    (http://placeholder/axis/clientDirect) ";
: : : : :
: : : : :   static String service =  "clientDirectService.wsdl";
: : :  : :
: : :  : :
: : : : :  public static void main(String[]   args)
: : : : :  {
: : : : : try
: : : : : {
: : : :  :  System.err.println("This Client tests  getReport");
: : : : :
: : : :  :   ServiceFactory sf =    ServiceFactory.newInstance();
: : : : :  URL u = new URL(router +  "/"  +  service);
: : : : : QName  serviceName  =  new   QName(url,"clientHandlerService");
: : : : : Service s  =   sf.createService(u,serviceName);
: : : : :
: : : : :   QName portName  = new    QName(url,"clientHandlerServicePort");
: : : : :
: : : : :   List  handlerChain =
: : : : :    s.getHandlerRegistry().getHandlerChain(portName);
: : : : : HandlerInfo  hi  =  new  HandlerInfo(LoggingHandler.class,null,null);
: : :  : :   handlerChain.add(hi);
: : : : :
: : : : :     //Checking for  proper syntax of   call
: : : : :  if   (args.length!=3)
: : : : : {
: : : :  :  System.err.println("Incorrect  usage of  Client. Please use  the
: : :  following:");
: : : : :   System.err.println("clientHandlerClient" + "  [Account Name]" +   "
: : : : :  [Password]" + "     [Conditions]");
: : : :  : }
: : : : : else
: : : : :  {
: : : : :   System.out.println("Thank You. Processing. . .");
: : : : :    ClientHandler  handler = (ClientHandler) s.getPort(portName,
: : :  :  :  ClientHandler.class);
: : : : :
: : : : :    String  accountName    =  args[0];
: : : : : String  password   =  args[1];
: : : : :  String conditions =  args[2];
: : : :  :
: : : : : if(s == null)
: : : : :   System.out.println("Service Not  Working Properly");
: : : : :
: : : :  :    String[] queryList =  handler.query(accountName,  password,
: : : conditions);
: : : : :
: : : :  :    System.out.println("Testing in  csv  format");
: : : :  :  String format = "csv";
: : : : :
: : : : :    String[]  rawQueryList  = handler.getQuery(accountName, password,
: : :  queryList,
: : : : :  format);
: : : : :
: : : : :     System.out.println("Finished.");
: : :  : : }
: : : : : }
: : : :  :  catch(Exception  e)
: : : : : {
: : : : :   System.err.println("Error  running  Client:");
: : : : :   System.err.println(e);
: : : : :  e.printStackTrace();
: : : : : }
: :  : : :  }
: : : : : }
: : : : :
: : : : : I would  appreciate any  comments on this  manner. I have checked the
: : : : :  axis-mailing  list for previous  solutions however have found none
: have
: : : been  helpful  for
: : :  : : me to diagnose.
: :  : : :
: : : : : Sincere Thanks,
: : : : : James   Crosson
: :  :
: : :
: : :
: : :
: :  :
: :
: :
: :
: :
: :
:
:
:
:
: