The problem of passing collection parameters between SP and SC when using xfire+JAXB
来源:百度文库 编辑:神马文学网 时间:2024/07/03 08:25:24
The reason of failing to unmashall the xml to java object at SC side is the element names are different
between the SP and SC.
The response given by SP is
alex.yuan@hp.com
alex
10
linda@hp.com
linda
9
The embedded element should be . This is just what the SC anticipates.
The signature of the method SP provides is
@WebMethod
public @WebResult(name="getMembersResponse")
Collection getMembers();
Unfortunately, the class MemberType is mapped to an element whose name is "memberType"
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "memberType", propOrder = {
"name",
"mail",
"rank"
})
public class MemberType {
These POJOs are generated by XJC from JAXB2. I guess this problem relates to XJC?
Yes. It relates to XJC. For a schema as follows, XJC will only generate CustomerType.java but not Customer.java. This is INCORRECT. This gives me a wrong impression that the service should uses instance of CustomerType to fill the returning collection.
When using Castor, it will generate two java files, CustomerType and Customer. Instances of Customer should be used to fill the returned collection.
==============================================================================================
New Update :
Yes. This relates to JAXB but not a wrong behavior. The difference in design between JAXB and Castor caused the misunderstanding.
I am new to JAXB. What I know now is JAXB heavily uses JAXBElement, a generic class, to express an element within an XML document. XJC generates java classes for every type it finds in schema but not for elements in schema. It is expected to use JAXBElement to express these elements.
Meanwhile, XJC generates an auxiliary class called ObjectFactory whose purpose is to aim you to create the POJOs expressing data in XML.
So, in short, the example should be modified as follows.
The signature of the method SP provides is
@WebMethod
public @WebResult(name="getMembersResponse")
GetMembersResponseType getMembers();
GetMembersResponseType is a generated class.
The service implementation class should look like,
public class MemberServiceImpl implements MemberService {
ArrayList members;
...
public GetMembersResponseType getMembers() {
GetMembersResponseType getmembersResponse = factory.createGetMembersResponseType();
ArrayOfMemberType arrayOfMemberType = factory.createArrayOfMemberType();
arrayOfMemberType.member = members;
getmembersResponse.members = arrayOfMemberType;
return getmembersResponse;
}
between the SP and SC.
The response given by SP is
The embedded element
The signature of the method SP provides is
@WebMethod
public @WebResult(name="getMembersResponse")
Collection
Unfortunately, the class MemberType is mapped to an element whose name is "memberType"
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "memberType", propOrder = {
"name",
"mail",
"rank"
})
public class MemberType {
These POJOs are generated by XJC from JAXB2. I guess this problem relates to XJC?
Yes. It relates to XJC. For a schema as follows, XJC will only generate CustomerType.java but not Customer.java. This is INCORRECT. This gives me a wrong impression that the service should uses instance of CustomerType to fill the returning collection.
When using Castor, it will generate two java files, CustomerType and Customer. Instances of Customer should be used to fill the returned collection.
==============================================================================================
New Update :
Yes. This relates to JAXB but not a wrong behavior. The difference in design between JAXB and Castor caused the misunderstanding.
I am new to JAXB. What I know now is JAXB heavily uses JAXBElement, a generic class, to express an element within an XML document. XJC generates java classes for every type it finds in schema but not for elements in schema. It is expected to use JAXBElement to express these elements.
Meanwhile, XJC generates an auxiliary class called ObjectFactory whose purpose is to aim you to create the POJOs expressing data in XML.
So, in short, the example should be modified as follows.
The signature of the method SP provides is
@WebMethod
public @WebResult(name="getMembersResponse")
GetMembersResponseType getMembers();
GetMembersResponseType is a generated class.
The service implementation class should look like,
public class MemberServiceImpl implements MemberService {
ArrayList
...
public GetMembersResponseType getMembers() {
GetMembersResponseType getmembersResponse = factory.createGetMembersResponseType();
ArrayOfMemberType arrayOfMemberType = factory.createArrayOfMemberType();
arrayOfMemberType.member = members;
getmembersResponse.members = arrayOfMemberType;
return getmembersResponse;
}
The problem of passing collection parameters between SP and SC when using xfire+JAXB
A Contest between a Mortal and the Goddess of...
A breath of fresh air for relations between the U.S. and Latin America?
Problem when the content have more length whe...
What‘s the difference between JDK and ...
The Relationship between Idioms and Culture1
The Difference between HDTV, EDTV, and SDTV
The Relationships between Idioms and Culture
The Relationship between Idioms and Culture f
The Relationship between Idioms and Culture吧
The Relationship between Idioms and Culture !
The Relationship between Idioms and Culture。。
The Relationship between Idioms and Culture,
The Relationship between Idioms and Cultureghg
The Relationship between Idioms and Cultur
XFire: The easy and simple way to develop Web...
how to sovle the common problem of raid
AJET 15(1) Oliver and Omari (1999) - using online technologies to support problem based learning
Article: The Power of Using the SMART Board i...
Poverty, Inequality, and the Policies of the ...
Q&A: What‘s the difference between CustomControl and UserControl?
The link between murder and Mexico's GDP - FP...
Who will stand between Obama and the world
What are the differences between boy and girl...