Hi,

I'm a relative newcomer to Axis2 and this is my first encounter with
this list. I'm pretty sure this is a question you've had
time-and-again, although I've had no joy in the list archives - I
probably don't know the correct terminology to frame my question.

I am using Axis2 to support web-services.  I define these through
WSDL/XSD and use wsdl2java to generate Java classes (ADBs?) for
request/response types, then write web-service code in Java to process
them.  I'm trying to add some restrictions to my XSDs and have the
ADBs process them, but I'm not getting quite the behaviour I expect.

I've tried adding a couple of type restrictions to my web-services:
[1] A Yes/No type that is a string with an enumeration restriction;
[2] A star-rating type that is a number from 1-5 inclusive.

Here's the XSD snippet for the latter:

        <xsd:simpleType name="Rating">
                <xsd:restriction base="xsd:int">
                        <xsd:minInclusive value="1" />
                        <xsd:maxInclusive value="5" />
                </xsd:restriction>
        </xsd:simpleType>

Using soapUI I can test that my services work for correct values, and
indeed they do.  However, when I enter a value that violates one of my
restrictions I get a simple axis fault message with the following:

   <soapenv:Fault
      <faultcode>soapenv:Server</faultcode>
      <faultstring>unknown</faultstring>
   </soapenv:Fault>

What I'd like to do is make the "unknown" part more meaningful in
light of these restrictions, similar to its behaviour if I omit a
required element:

   <soapenv:Fault>
      <faultcode>soapenv:Server</faultcode
      <faultstring>org.apache.axis2.databinding.ADBException:
Unexpected subelement thisIsRequired</faultstring>
   </soapenv:Fault>

For instance, entering 6 for a star rating might give:

   <soapenv:Fault>
      <faultcode>soapenv:Server</faultcode
      <faultstring>WhateverException: 1 <= "rating" <= 6 violated:
found 6</faultstring>
   </soapenv:Fault>

I realise I can configure axis2.xml to include stacktraces, but they
are of limited use because the exceptions generated for these
restrictions (IllegalArgumentException for YesNo; RuntimeException for
Rating) don't seem to have meaningful error messages.

Is it possible to improve these exception messages and/or the
faultstring messages for restrictions? (... without doing the
validation manually in Java)

Many thanks,
David
--
David Brooks

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscr...@axis.apache.org
For additional commands, e-mail: java-user-h...@axis.apache.org

Reply via email to