You are viewing a plain text version of this content. The canonical link for it is here.
Posted to soap-user@xml.apache.org by Founaboui Haman <ha...@online.de> on 2002/08/15 08:49:35 UTC
Service returning always "false"...
Hello to all,
I have a problem with my web service. It is always returning "false", but I am expecting
"true". To help u understanding my problem I put hier the codes.
Thanks for ur help.
Haman
The service method I am calling:
...
public boolean bestelleArtikel(String kID, String anfID, String bestellen){
try{
// Treiber laden
Class.forName("org.gjt.mm.mysql.Driver");
}
catch( ClassNotFoundException e1){
System.out.println("\nJDBC Driver class nicht gefunden");
e1.printStackTrace();
}catch( Exception e2){
System.out.println("\nDriver class nicht gefunden");
e2.printStackTrace();
}
try{
// Verbindung zur Datenbank
conn = DriverManager.getConnection (url, user, password);
// Ein Statement erstellen
stmt = conn.createStatement();
// Eine SQL-Befehl ausführen
String sql = "UPDATE Anfragen "
+"SET Status = '"+bestellen+"'"
+" WHERE KundenID = '"+kID+"'"
+" AND AnfrageID = '"+anfID+"'";
int countUpdate = stmt.executeUpdate(sql);
stmt.close();
conn.close();
if(countUpdate==1)
return true;
else
return false;
}catch (Exception e){
System.out.println(e.getMessage());
e.printStackTrace();
}finally{
if(conn != null){
try{
conn.close();
}catch(SQLException e){
e.printStackTrace();
}
}
}
return false;
}
...
And the client (a servlet):
...
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("<center><body><table width=800 border=15"
+" bordercolor='green' cellspacing=0 cellpadding=10><tr><td align=center>");
String kID = request.getParameter("kundenID");
String anfID = request.getParameter("anfrageID");
String bestellen = request.getParameter("bestellung");
SOAPMappingRegistry smr = new SOAPMappingRegistry();
// Setup von Call
Call call = new Call();
call.setSOAPMappingRegistry(smr);
call.setTargetObjectURI("urn:BestellService");
call.setMethodName("bestelleArtikel");
call.setEncodingStyleURI(Constants.NS_URI_SOAP_ENC);
// Parameters hinzufügen
Vector params = new Vector();
params.addElement(new Parameter("kID", String.class, kID, null));
params.addElement(new Parameter("anfID", String.class, anfID, null));
params.addElement(new Parameter("bestellen", String.class, bestellen, null));
call.setParams (params);
// call aufrufen
Response resp = null;
try{
URL url = new URL(RPCROUTER);
resp = call.invoke(url, "");
}catch (SOAPException e){
out.println(" SOAP-Fehler aufgetreten:<br>"
+" Fehler-Code: " + e.getFaultCode()
+" <br>Fehler-Text: " + e.getMessage()
+"<br><br><a href='/anfrage/index.html'>[Haupseite]</a> ");
}
// Die Antwort checken.
if (!resp.generatedFault()){ // Kein SOAP-Fehler
Parameter result = resp.getReturnValue();
Boolean value =(Boolean) result.getValue();
if (value.booleanValue()!=true){
out.println("<br> Die Bestellung ist fehlgeschlagen <br><br>"
+"<a href='/anfrage/index.html'>[Haupseite]</a>");
}else{
out.println(" Bestellung ist erfolgreich durchgeführt worden!<br><br>"
+" <a href='/anfrage/index.html'>[Haupseite]</a>");
}
}
else // SOAP-Fehler
{
Fault fault = resp.getFault();
out.println(" SOAP-Fehler aufgetreten:<br>"
+" Fehler-Code: " + fault.getFaultCode()
+" <br>Fehler-Text: " + fault.getFaultString()
+"<a href='/anfrage/index.html'>[Haupseite]</a> ");
}
out.println("</td></tr></table>");
out.close();
}
...
trying to use jdom with apache soap
Posted by stephen chan <st...@netnation.com>.
Hello:
I am trying to use jdom with apache soap, but I am not sure how to
create a jdom document from the Vector returned from
(Envelope)env.getBody().getBodyEntries();
Thanks in advance.
Stephen
trying to use jdom with apache soap
Posted by stephen chan <st...@netnation.com>.
Hello:
I am trying to use jdom with apache soap, but I am not sure how to
create a jdom document from the Vector returned from
(Envelope)env.getBody().getBodyEntries();
Thanks in advance.
Stephen