Topic
No replies
SystemAdmin
SystemAdmin
659 Posts
ACCEPTED ANSWER

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

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

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

javax.xml.bind.MarshalException
- with linked exception:
[javax.xml.bind.JAXBException: http://Luk.co.td.brl.account.model.AccountSummary; is not known to this context

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

Thanks
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 = javax.xml.ws.soap.SOAPBinding.SOAP12HTTP_BINDING)
@XmlSeeAlso({ AccountSummary[].class })
public class AccountSummaryEndpoint {
protected static final String SERVICE_NAME = "AccountSummary";
protected static final String PORT_NAME = "AccountSummaryPort";

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

}