Hi Deepak,
U though we could start from somewhere so I followed one of the tutorials I found on this awesome site. I followed it quite literally and went through all the processes and procedures. However I was an unable to insert the record I had created.
I have appended the results I got.
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package pack1;
import java.sql.Connection;
import java.sql.PreparedStatement;
import javax.annotation.Resource;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebService;
import javax.sql.DataSource;
/**
*
* @author Ba Mwamba
*/
@WebService()
public class customer {
@Resource(name = "customer")
private DataSource customer;
/**
* Web service operation
*/
@WebMethod(operationName = "Create")
public String Create(@WebParam(name = "username")
String username, @WebParam(name = "drivinglicence")
String drivinglicence, @WebParam(name = "creditcard")
String creditcard, @WebParam(name = "firstname")
String firstname, @WebParam(name = "lastname")
String lastname, @WebParam(name = "physicaladdress")
String physicaladdress, @WebParam(name = "phonenumber")
String phonenumber, @WebParam(name = "password")
String password, @WebParam(name = "location")
String location, @WebParam(name = "Registrationdate")
String Registrationdate) {
//TODO write your implementation code here:
String status = "Record not inserted";
try
{
Connection con= customer.getConnection();
PreparedStatement ps=con.prepareStatement("INSERT INTO Customer VALUES(?,?,?,?,?,?,?,?,?,?)");
ps.setString(1, username);
ps.setString(2, drivinglicence);
ps.setString(3, creditcard);
ps.setString(4, firstname);
ps.setString(5, lastname);
ps.setString(6, physicaladdress);
ps.setString(7, phonenumber);
ps.setString(8, password);
ps.setString(9, location);
ps.setString(10, Registrationdate);
int i = ps.executeUpdate();
if(i!=0)
{
status="Record Inserted";
}
}catch(Exception e){
System.out.println("Error in storing data"+e);
}
return status;
}
}
Results from the above operation:
create Method invocation
Method parameter(s)
Type Value
java.lang.String mwamba
java.lang.String 123456789
java.lang.String 98765443
java.lang.String mwamba
java.lang.String chishimba
java.lang.String 48/50A Makeni
java.lang.String 098765433
java.lang.String mwamba
java.lang.String L002
java.lang.String 10/11/2009
Method returned
java.lang.String : "Record not inserted"
SOAP Request
<?xml version="1.0" encoding="UTF-8"?>
<S:Envelope xmlns:S="
http://schemas.xmlsoap.org/soap/envelope/">;
<S:Header/>
<S:Body>
<ns2:Create xmlns:ns2="
http://pack1/">;
<username>mwamba</username>
<drivinglicence>123456789</drivinglicence>
<creditcard>98765443</creditcard>
<firstname>mwamba</firstname>
<lastname>chishimba</lastname>
<physicaladdress>48/50A Makeni</physicaladdress>
<phonenumber>098765433</phonenumber>
<password>mwamba</password>
<location>L002</location>
<Registrationdate>10/11/2009</Registrationdate>
</ns2:Create>
</S:Body>
</S:Envelope>
SOAP Response
<?xml version="1.0" encoding="UTF-8"?>
<S:Envelope xmlns:S="
http://schemas.xmlsoap.org/soap/envelope/">;
<S:Body>
<ns2:CreateResponse xmlns:ns2="
http://pack1/">;
<return>Record not inserted</return>
</ns2:CreateResponse>
</S:Body>
</S:Envelope>
Where I am going wrong?
Kind Regards,