axis-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Muthana Al-Temimi" <muth...@gmx.de>
Subject need help in axis
Date Mon, 27 Oct 2008 16:14:21 GMT
Hello there,

 

i'm new in Axis and i wrote the following code in java

package logistic.ws.serverside;

 

 

 

 

import java.sql.Connection;

import java.sql.DriverManager;

import java.sql.Statement;

import java.sql.ResultSet;

 

 

public class AnimalService {

 

      

            final int idVal = 0;

            private String name ;

            private String category;

            private String[] retVal = new String[2];

            

            

            

            

            Connection conn = null;

            

            public  AnimalService () {}

            

            

            public String getAnimals() {

                  return name+category;

            }

 

            

            

          

              public String[] findAnimal(int idVal) {

              

              try

              {

                  String userName = "root";

                  String password = "muthana";

                  String url = "jdbc:mysql://localhost:3306/logit";

                  try {

                  Class.forName ("com.mysql.jdbc.Driver").newInstance ();

                  }catch (ClassNotFoundException e){

                        System.out.println ( " Unable to load Driver Class
");     

                        

                  }

                  conn = DriverManager.getConnection (url, userName,
password);

                  System.out.println ("Database connection established");

                  Statement s = conn.createStatement ();

                  

                  

                  String query = "SELECT name,category FROM animal where
id="+ idVal +"";

                  

                  System.out.println(query);

                  

                  ResultSet rs = s.executeQuery(query);

                  

                  while (rs.next ())

                  {

                     

                      

                     

                     

                             // animals = rs.getString(1);

                             // category=rs.getString(2);

 

                             /*

                             String nameVal = rs.getString ("name");

                      String catVal = rs.getString ("category");

                      System.out.println ( "id = " + idVal + ", name = " +
nameVal  + ", category = " + catVal);

                              

                      */

                             

                             String X1 = rs.getString(1);

                             String X2 = rs.getString(2);

                             System.out.println (X1);

                             System.out.println (X2);

                             

                             this.name =  X1 ;

                             this.category =  X2 ;

                             

                             

                             // I think that my problem is here 2 string in
array

                             String[] retVal= {X1,X2};

                             

                  }

                  rs.close ();

                  s.close ();

                  

                  

                 

 

              }catch (Exception e)

              {

                  System.err.println ("Cannot connect to database server");

                  System.err.println ("Error message: " + e.getMessage ());

               

                 

              }

              finally

              {

                  if (conn != null)

                  {

                      try

                      {

                          conn.close ();

                          System.out.println ("Database connection
terminated");

                      }

                      catch (Exception e) { /* ignore close errors */ }

                  }

              }

          

              return retVal;

              

             

 

}     

              

              

             

              

      /*

            

                  public static void main (String[] args)

                {

               AnimalService animalws = new AnimalService();

               animalws.findAnimal(1);

              }  // end main method

              

         */    

}     

 

 

      

 

 

The response is wrong as follow:

 

<?xml version="1.0" encoding="utf-8" standalone="no"?>

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

<soapenv:Body>

<findAnimalResponse xmlns="http://serverside.ws.logistic">

<findAnimalReturn xsi:nil="true"/>

<findAnimalReturn xsi:nil="true"/>

</findAnimalResponse>

</soapenv:Body>

</soapenv:Envelope>

 

The request is correct:

 

<?xml version="1.0" encoding="UTF-8" standalone="no"?>

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

<soapenv:Body>

<findAnimal xmlns="http://serverside.ws.logistic">

<idVal>2</idVal>

</findAnimal>

</soapenv:Body>

</soapenv:Envelope>

 

I think my problem is how to map array into string

I need help to fix that to get the result from the database.

 

Any help will be good

 

Thanks

muthana


Mime
View raw message