3
현재 JAXB 및 웹 서비스를 배우고 있으며이 문제는 해결 방법을 알고 있습니다.JAXB에서 SOAP 특성 만들기
JAXB로 주석을 작성한 매우 간단한 클래스가 있다고 가정합니다.
@XmlRootElement
public class Customer {
private int custID;
private String custName;
//getters and setters
}
그리고이 클래스는 웹 서비스로 공개됩니다. 비누 봉투 응답은 다음과 같이이다
@WebService
public class CustomerWS {
@WebMethod(operationName = "customerData")
public Customer getCustomer(){
Customer cust = new Customer();
cust.setCustID(12345);
cust.setCustName("John Doe");
return cust;
}
}
: (I 단순 여기 모든 하드 코딩하지만이 DB에 연결 참고).
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Body>
<ns2:customerDataResponse xmlns:ns2="http://test.com/">
<return>
<custID>12345</custID>
<custName>John Doe</custName>
</return>
</ns2:customerDataResponse>
</S:Body>
</S:Envelope>
은 이제 고객 개체라는 상태에서 다른 속성을 가지고 있고 아래 대신 고객의 요소의 일부가되는처럼되고 비누 응답 속성으로이 속성을 원하는 가정합니다. (A = 활성, I = 비활성)
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Body>
<ns2:customerDataResponse status="A" xmlns:ns2="http://test.com/">
<return>
<custID>12345</custID>
<custName>John Doe</custName>
</return>
</ns2:customerDataResponse>
</S:Body>
</S:Envelope>
@XmlRootElement
public class Customer {
private int custID;
private String custName;
//Another Annotation??? (A or I only)
private String status;
//getters and setters
}
이 요구 사항을 충족시키기 위해 수업에 주석을 달려면 어떻게해야합니까? 감사합니다
답변 해 주셔서 감사합니다. 내가 원하는 것을 할 수 있도록 대안이나 해결 방법이 있습니까? 또한, 엔티티의 일부가 아니더라도 엔벨로프에 어떤 속성을 하드 코딩 할 수있는 방법이 있습니까? –