JBoss web services fails with exception for SwaRef attachments
Environment
- JBoss Enterprise Application Platform (EAP) 5.x
- JBossWS Native
Issue
- I'm trying to get a SwaRef JAX-WS client set up, but the client doesn't seem to be creating the MIME attachment, though it seems to be creating the reference in the XML:
javax.xml.ws.soap.SOAPFaultException: javax.xml.bind.UnmarshalException: org.jboss.ws.WSException: Cannot find attachment part for: <0-1383059564928-14471083@ws.jboss.org>
- with linked exception:
[com.sun.xml.bind.api.AccessorException: org.jboss.ws.WSException: Cannot find attachment part for: <0-1383059564928-14471083@ws.jboss.org>]
at org.jboss.ws.core.jaxws.SOAPFaultHelperJAXWS.getSOAPFaultException(SOAPFaultHelperJAXWS.java:85)
at org.jboss.ws.core.jaxws.binding.SOAP11BindingJAXWS.throwFaultException(SOAP11BindingJAXWS.java:107)
at org.jboss.ws.core.CommonSOAPBinding.unbindResponseMessage(CommonSOAPBinding.java:582)
at org.jboss.ws.core.CommonClient.invoke(CommonClient.java:396)
at org.jboss.ws.core.jaxws.client.ClientImpl.invoke(ClientImpl.java:232)
at org.jboss.ws.core.jaxws.client.ClientProxy.invoke(ClientProxy.java:171)
at org.jboss.ws.core.jaxws.client.ClientProxy.invoke(ClientProxy.java:157)
at $Proxy22.send(Unknown Source)
at com.redhat.test.Test.main(Test.java:130)
Resolution
Add the @javax.xml.bind.annotation.XmlAttachmentRef
annotation to the relevant parameter in your SEI. e.g.:
@WebService(name = "myServiceEndpointInterface", targetNamespace = "uri:jboss.com")
public interface MyServiceEndpointInterface {
@WebMethod(action = "test")
public void test(
@WebParam(name = "MNPFrame", targetNamespace = "MNPProtocol.xsd", partName = "param")
@XmlAttachmentRef
MySwaParam param);
}
Add the @XmlAttachmentRef
as shown above caused the client to correctly create the MIME attachment.
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.
Comments