0 Replies Latest reply on Aug 6, 2008 8:39 AM by argol1278

    get complex type in web service client

    argol1278

      Whene i invoke web service in client application i have java.lang.NullPointerException.
      In log in SOAP message there are values but client can't get them. This is what i have done:

      @XmlAccessorType(XmlAccessType.FIELD)
      @XmlType(name = "Users",namespace="http://webServices.ejb/" ,propOrder = { "userid","name","surname","login",
      "password","status","email" })
      @XmlRootElement(namespace="http://webServices.ejb/", name = "test")
      public class Users implements Serializable{
      
       @XmlElement(namespace="http://webServices.ejb/",name="userid")
       private int userid;
       @XmlElement(namespace="http://webServices.ejb/")
       private String name;
       @XmlElement(namespace="http://webServices.ejb/")
       private String surname;
       @XmlElement(namespace="http://webServices.ejb/")
       private String login;
       @XmlElement(namespace="http://webServices.ejb/")
       private String password;
       @XmlElement(namespace="http://webServices.ejb/")
       private int status;
       @XmlElement(namespace="http://webServices.ejb/")
       private String email;
       @XmlTransient
       private Set addresses = new HashSet(0);
       @XmlTransient
       private Set accounts = new HashSet(0);
      
      
      
       public Users() {
       }
      
       public int getUserid() {
       return this.userid;
       }
      
       public void setUserid(int userid) {
       this.userid = userid;
       }
      
       public String getName() {
       return this.name;
       }
      
       public void setName(String name) {
       this.name = name;
       }
      
       public String getSurname() {
       return this.surname;
       }
      
       public void setSurname(String surname) {
       this.surname = surname;
       }
      
       public String getLogin() {
       return this.login;
       }
      
       public void setLogin(String login) {
       this.login = login;
       }
      
       public String getPassword() {
       return this.password;
       }
      
       public void setPassword(String password) {
       this.password = password;
       }
      
       public int getStatus() {
       return this.status;
       }
      
       public void setStatus(int status) {
       this.status = status;
       }
      
       public String getEmail() {
       return this.email;
       }
      
       public void setEmail(String email) {
       this.email = email;
       }
      
       public Set getAccounts() {
       return accounts;
       }
      
       public void setAccounts(Set accounts) {
       this.accounts = accounts;
       }
      
       public Set getAddresses() {
       return addresses;
       }
      
       public void setAddresses(Set addresses) {
       this.addresses = addresses;
       }
      
      
      }
      
      


      @Stateless(mappedName = "UsersOperations")
      @WebService(name = "UsersOperations")
      public class UsersOperations implements UsersOperationsEjbRemote, UsersOperationsEjbLocal {
      
       /**
       * Default constructor.
       */
       public UsersOperations() {
       // TODO Auto-generated constructor stub
       }
      
       @WebMethod
       public Users test(@WebParam(name = "userid") int userid){
       // Hibernate query
       Users u = queryUserDetails(userid);
       System.out.println(u.getLogin());
       return u;
       }
      
      
      }
      


      CLIENT

      @WebService(name = "UsersOperations", targetNamespace = "http://webServices.ejb/")
      @XmlSeeAlso({bankDB.Users.class})
      public interface UsersOperations {
      
      @WebMethod
       @WebResult(targetNamespace = "http://webServices.ejb/")
       public Users test(@WebParam(name = "userid") int userid);
      }
      


      @WebServiceClient(name = "UsersOperationsService", targetNamespace = "http://webServices.ejb/", wsdlLocation = "http://127.0.0.1:8080/Bank-BankEJB/UsersOperations?wsdl")
      public class UsersOperationsService
       extends Service
      {
      
       private final static URL UsersOperationsService_WSDL_LOCATION;
      
       static {
       URL url = null;
       try {
       url = new URL("http://127.0.0.1:8080/Bank-BankEJB/UsersOperations?wsdl");
       } catch (MalformedURLException e) {
       e.printStackTrace();
       }
       UsersOperationsService_WSDL_LOCATION = url;
       }
      
       public UsersOperationsService(URL wsdlLocation, QName serviceName) {
       super(wsdlLocation, serviceName);
       }
      
       public UsersOperationsService() {
       super(UsersOperationsService_WSDL_LOCATION, new QName("http://webServices.ejb/", "UsersOperationsService"));
       }
      
       /**
       *
       * @return
       * returns Notification
       */
       @WebEndpoint(name = "UsersOperationsPort")
       public UsersOperations getUsersOperationsPort() {
       return (UsersOperations)super.getPort(new QName("http://webServices.ejb/", "UsersOperationsPort"), UsersOperations.class);
       }
      
      


      // invoke web service in client
      UsersOperationsService service = newUsersOperationsService();
      UsersOperations ejb = service.getUsersOperationsPort();
      Users u = ejb.test(2);