• No replies
659 Posts

Pinned topic How to return an array of objects in JAX-WS (is not known to this context)

‏2012-10-24T12:59:55Z |

Does anyone know how to pass an array of objects back from a JAX-WS webservice?

I'm trying to returning an AccountSummary[] from a simple JAX-WS where AccountSummary is a JAXB annotated model object. Unfortunatley websphere 7 doesn't like this much and always returns

- with linked exception:
[javax.xml.bind.JAXBException:; is not known to this context

Do I have to create a wrapper class for this (which sucks)?

My simple webservice is as such:

@WebService(serviceName = AccountSummaryEndpoint.SERVICE_NAME, portName = AccountSummaryEndpoint.PORT_NAME, wsdlLocation = "WEB-INF/wsdl/AccountSummary.wsdl")
// JWS annotation that specifies the mapping of the service onto the
// SOAP message protocol.In particular, it specifies that the SOAP messages
// are document-literal.
@SOAPBinding(style = SOAPBinding.Style.DOCUMENT, use = SOAPBinding.Use.LITERAL, parameterStyle = SOAPBinding.ParameterStyle.BARE)
@BindingType(value =
@XmlSeeAlso({ AccountSummary[].class })
public class AccountSummaryEndpoint {
protected static final String SERVICE_NAME = "AccountSummary";
protected static final String PORT_NAME = "AccountSummaryPort";

public AccountSummary[] getAccountSummarys(final String accountId) {
AccountSummary s = MockAccountFactory.createAccountSummary(accountId);
return new AccountSummary[] { s };