I’m using Netbeans to create a web application project. The IDE adds METRO2.0 libraries when I create a new web service (code first WS). The SOAP web service is well deployed in my apache Tomcat 6. However, when I send a complex type, the client couldn’t access to the methods of the sended object in the client.
Say I have a class called Person and an operation:
@WebMethod(operationName = "getOnePerson")
public Person getOnePerson() {
return new Person("MyName", "MySurname", 24);
}
And the Person class:
public class Person {
private String name, surname;
private int age;
public Person() {
}
public Person(String name, String surname, int age) {
this.name = name;
this.surname = surname;
this.age = age;
}
public int getAge() {
return age;
}
public String getName() {
return name;
}
public String getSurname() {
return surname;
}
}
So how may I make the client know the Person methods?
Thanks
EDIT: I’ve tried to update my XSD file by adding Pesron’s attributes:
<xs:complexType name="person">
<xs:attribute name="name" type="xs:string" />
<xs:attribute name="surname" type="xs:string" />
<xs:attribute name="age" type="xs:int" />
</xs:complexType>
By adding this portion, the client knows the getter & setter of the class Person but when trying to run the program, all the getters return null (client side):
public class Main {
public static void main(String[] args) {
try {
Person p = getOnePerson();
System.out.println(p);
System.out.println(p.getSurname());
System.out.println(p.getName());
} catch (Exception e) {
e.printStackTrace();
}
}
private static Person getOnePerson() {
com.company.ws.BeanWebService_Service service = new com.company.ws.BeanWebService_Service();
com.company.ws.BeanWebService port = service.getBeanWebServicePort();
return port.getOnePerson();
}
}
returns:
com.company.ws.Person@d75415
null
null
So could you please tell me why the client doesn’t know the different values of class’s attribute?
What I have found and resolves the problem:
Thank you!