I'm specifying faults in my WADL like this:
<fault status="401" mediaType="text/xml"
element="imom:webserviceFault">
<doc>
Bad credentials, you are not authorized to make this
request.
</doc>
</fault>
<fault status="404" mediaType="text/xml"
element="imom:webserviceFault">
<doc>
Fault if the radar cannot be found
</doc>
</fault>
In the generated code, I have no problems catching 404 faults. They do
indeed raise a WebserviceFaultException. However, when I generated a 401
fault by passing bad credentials I get a different exception:
[java] Exception in thread "main" java.lang.IllegalArgumentException: is
parameter must not be null
[java] at
javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(AbstractUnmarshallerImpl.java:179)
[java] at
org.jvnet.ws.wadl.util.JAXBDispatcher.doGET(JAXBDispatcher.java:84)
[java] at
gov.inel.ecsi.j2ee.imomrestservices.Endpoint$Radar.getAsRadarInformationValueObjectList(Endpoint.java:315)
[java] at
gov.inel.ecsi.j2ee.imomrestservices.TestClient.testRadar(TestClient.java:270)
[java] at
gov.inel.ecsi.j2ee.imomrestservices.TestClient.main(TestClient.java:104)
I've confirmed that the server is generating a 401 fault code and that it
is sending an imom:webserviceFault element. This looks like a bug to me,
I guess I could go around it by catching an IllegalArgumentException and
treating it like a 401 error -- but this doesn't seem right.
Am I missing something?
-jOrGe W.