Netbeans를 사용하여 웹 응용 프로그램 프로젝트를 만듭니다. IDE는 새로운 웹 서비스 (코드 WS)를 만들 때 METRO2.0 라이브러리를 추가합니다. SOAP 웹 서비스는 아파치 Tomcat 6에 잘 전개되어있다. 그러나 복잡한 유형을 보낼 때 클라이언트는 클라이언트에서 보낸 객체의 메소드에 액세스 할 수 없다. SOAP를 통해 전송되는 객체의 메소드 표시
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;
}
}
그래서 어떻게 클라이언트가
사람 방법을 알고 할 수 있습니다
@WebMethod(operationName = "getOnePerson")
public Person getOnePerson() {
return new Person("MyName", "MySurname", 24);
}
그리고 Person 클래스 : 내가 사람라는 클래스와 수술을 말해? 감사 편집이 : 나는 Pesron의 속성을 추가하여 내 XSD 파일을 업데이트 시도했다 :
<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>
이 부분을 추가함으로써, 클라이언트는 Person 클래스의 게터 & 세터를 알고 있지만, 프로그램을 실행하려고 할 때,
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();
}
}
반환 : 모든 게터는 (클라이언트 측) null를 돌려 [email protected] 널 널 클라이언트가 클래스 속성의 다른 값을 모르는 이유를 말해 주시겠습니까? JAX-WS는/비 정렬 화 객체를 마샬링하는 JAXB를 사용하기 때문에
클래스를 클라이언트에 복사 할 수 있습니다. 하지만 JVM은 모든 속성의 주소 메모리를 해결할 수 있습니까? 실제로 클라이언트는 메소드가없는 com.company.ws.Person이라는 새로운 유형을 자동으로 생성합니다. 같은 이름의 다른 클래스를 만들면 문제가 발생할 수 있습니다. 그렇지 않니? –