Results 1 to 3 of 3
- 02-18-2008, 11:28 AM #1
Member
- Join Date
- Feb 2008
- Posts
- 1
- Rep Power
- 0
Problems with a complex datatype in a webservice
Hi,
I'm trying to programm a webservice in java. For I'm new to the area of webservices I downloaded netbeans and just started. so my webservice looks that way:
As you see one Method is using a class as a parameter. this class looks that way:Java Code:@WebService() public class HuntGameWS { private DatabaseHandler m_dbHandler; public HuntGameWS() { try { m_dbHandler = new DatabaseHandler(); } catch (ClassNotFoundException ex) { Logger.getLogger(HuntGameWS.class.getName()).log(Level.SEVERE, null, ex); } catch (SQLException ex) { Logger.getLogger(HuntGameWS.class.getName()).log(Level.SEVERE, null, ex); } } /** * Web service operation */ @WebMethod(operationName = "checkUserNameExists") public boolean checkUserNameExists(@WebParam(name = "strUserName") String strUserName) { try { if( m_dbHandler == null ) m_dbHandler = new DatabaseHandler(); return m_dbHandler.checkUserNameExists(strUserName); } catch (ClassNotFoundException ex) { Logger.getLogger(HuntGameWS.class.getName()).log(Level.SEVERE, null, ex); } catch (SQLException ex) { Logger.getLogger(HuntGameWS.class.getName()).log(Level.SEVERE, null, ex); } return true; } /** * Web service operation */ @WebMethod(operationName = "checkEmailExists") public boolean checkEmailExists(@WebParam(name = "strEmail") final String strEmail) { try { if( m_dbHandler == null ) m_dbHandler = new DatabaseHandler(); return m_dbHandler.checkEmailExists(strEmail); } catch (ClassNotFoundException ex) { Logger.getLogger(HuntGameWS.class.getName()).log(Level.SEVERE, null, ex); } catch (SQLException ex) { Logger.getLogger(HuntGameWS.class.getName()).log(Level.SEVERE, null, ex); } return true; } /** * Web service operation */ @WebMethod(operationName = "createMProfile") public boolean createMProfile(@WebParam(name = "objMProfile") MProfile objMProfile) { try { if (m_dbHandler == null) { m_dbHandler = new DatabaseHandler(); } return m_dbHandler.createMProfile(objMProfile); } catch (ClassNotFoundException ex) { Logger.getLogger(HuntGameWS.class.getName()).log(Level.SEVERE, null, ex); return false; } catch (SQLException ex) { Logger.getLogger(HuntGameWS.class.getName()).log(Level.SEVERE, null, ex); return false; } } }
The client application which uses the WebService is an android-Programm which are using the KSOAP2-Framework to make calls. The method calls to the methods with the primitiv datatypes are working fine. But the method call to the method with the class as parameter is making a problem. When I'm debuging the serverside the parameter is always null. I've logged the soapcall which is looking that way:Java Code:@XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "mProfile", propOrder = { "email", "firstName", "gender", "lastName", "pwd", "userName" }) public class MProfile { protected String email; protected String firstName; protected String gender; protected String lastName; protected String pwd; protected String userName; /** * Gets the value of the email property. * * @return * possible object is * {@link String } * */ public String getEmail() { return email; } /** * Sets the value of the email property. * * @param value * allowed object is * {@link String } * */ public void setEmail(String value) { this.email = value; } /** * Gets the value of the firstName property. * * @return * possible object is * {@link String } * */ public String getFirstName() { return firstName; } /** * Sets the value of the firstName property. * * @param value * allowed object is * {@link String } * */ public void setFirstName(String value) { this.firstName = value; } /** * Gets the value of the gender property. * * @return * possible object is * {@link String } * */ public String getGender() { return gender; } /** * Sets the value of the gender property. * * @param value * allowed object is * {@link String } * */ public void setGender(String value) { this.gender = value; } /** * Gets the value of the lastName property. * * @return * possible object is * {@link String } * */ public String getLastName() { return lastName; } /** * Sets the value of the lastName property. * * @param value * allowed object is * {@link String } * */ public void setLastName(String value) { this.lastName = value; } /** * Gets the value of the pwd property. * * @return * possible object is * {@link String } * */ public String getPwd() { return pwd; } /** * Sets the value of the pwd property. * * @param value * allowed object is * {@link String } * */ public void setPwd(String value) { this.pwd = value; } /** * Gets the value of the userName property. * * @return * possible object is * {@link String } * */ public String getUserName() { return userName; } /** * Sets the value of the userName property. * * @param value * allowed object is * {@link String } * */ public void setUserName(String value) { this.userName = value; } }
I've trying a few things right now to find out what's wrong but I didn't had any success. So does anyone here knows what's wrong?Java Code:POST /HuntGameWebService/HuntGameWSService HTTP/1.1 User-Agent: kSOAP/2.0 SOAPAction: createMProfile Content-Type: text/xml Connection: close Content-Length: 805 Host: xxxxxxxxxxxx <v:Envelope xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns:d="http://www.w3.org/2001/XMLSchema" xmlns:c="http://schemas.xmlsoap.org/soap/encoding/" xmlns:v="http://schemas.xmlsoap.org/soap/envelope/"> <v:Header /> <v:Body> <n0:createMProfile id="o0" c:root="1" xmlns:n0="http://WebService.HuntGame.markus_heid.com/"> <createMProfile i:type="n0:createMProfile"> <objMProfile i:type="d:anyType"> <username i:type="d:string">user</username> <firstname i:type="d:string">user</firstname> <lastname i:type="d:string">user</lastname> <birthdate i:type="d:long">57751920000000</birthdate> <gender i:type="d:string">w</gender> <email i:type="d:string">user@user.com</email> <pwd i:type="d:string">5cc32e366c87c4cb49e4309b75f57d64</pwd> </objMProfile> </createMProfile> </n0:createMProfile> </v:Body> </v:Envelope>
Thanks
Markus
- 05-20-2008, 02:12 PM #2
Member
- Join Date
- May 2008
- Posts
- 1
- Rep Power
- 0
Hi Marcus,
have the same problem as you - have you solved it? Maybe you can answer me and submit your solution.
Thanx a lot
Christian
- 10-29-2008, 05:32 AM #3
Member
- Join Date
- Oct 2008
- Posts
- 1
- Rep Power
- 0
Hi.
Looks like the same problem with my kSoap2 code...
C# code produces: <username> JonDoe </username>
kSoap2 code produces: <username i:type="d:string"> JonDoe </username>
C# code works, Java code fails.
if you go through and remove the i:type="d:string" from the request before sending it, I suspect it will work.
RR.Last edited by PymbleSoftware; 10-29-2008 at 05:34 AM.
Similar Threads
-
Axis Client accessing data on .Net webservice
By cfacile666 in forum Web FrameworksReplies: 3Last Post: 09-02-2008, 11:35 AM -
Writing webservice client
By javaplus in forum Web FrameworksReplies: 0Last Post: 12-19-2007, 10:10 AM -
Webservice ain't working?
By marcelman in forum NetworkingReplies: 0Last Post: 08-10-2007, 02:48 AM -
Webservice wizard error?
By marcelman in forum NetBeansReplies: 0Last Post: 08-10-2007, 02:46 AM -
Complex proximity Clauses
By peiceonly in forum LuceneReplies: 1Last Post: 08-07-2007, 05:43 PM


LinkBack URL
About LinkBacks

Bookmarks