axis-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Lorenzo Dalla Vecchia" <lor...@tiscali.it>
Subject Re: AxisFault with custom exception
Date Sat, 22 Jan 2005 14:35:40 GMT
I checked the website and tried following its guidelines: nothing.
Everything works: the WSDL and the WSDD are correct but at the time the 
exception is throwed the <detail> item of the SOAP response does not contain 
exception fileds but only that "hostname" thing.

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" 
xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <soapenv:Body>
    <soapenv:Fault>
      <faultcode>soapenv:Server.userException</faultcode>
      <faultstring>test.MyException</faultstring>
      <detail>
        <ns1:hostname 
xmlns:ns1="http://xml.apache.org/axis/">atlantis</ns1:hostname>
      </detail>
    </soapenv:Fault>
  </soapenv:Body>
</soapenv:Envelope>

Other ideas? It must have happened before... it almost looks like an Axis 
bug.

--
Lorenzo

-----Messaggio Originale----- 
Da: "Sunil Kothari" <sunil.kothari@majoris.com>
A: <axis-user@ws.apache.org>
Data invio: sabato 22 gennaio 2005 14.35
Oggetto: Re: AxisFault with custom exception


> Note that the exception class fields come under details element. And 
> here's
> how its sent to the client:
>
>
>
> ?xml version="1.0" encoding="UTF-8"?>
>
> <soapenv:Envelope 
> xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
> xmlns:xsd="http://www.w3.org/2001/XMLSchema"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
>
> <soapenv:Body>
>
>  <soapenv:Fault>
>
>   <faultcode>soapenv:Server.generalException</faultcode>
>
>   <faultstring></faultstring>
>
>   <detail>
>
>    <ns1:fault href="#id0" xmlns:ns1="urn:banktest"/>
>
>    <ns2:exceptionName
> xmlns:ns2="http://xml.apache.org/axis/">example.MyException</ns2:exceptionNa
> me>
>
>   </detail>
>
>  </soapenv:Fault>
>
>  <multiRef id="id0" soapenc:root="0"
> soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
> xsi:type="ns3:MyException"
> xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
> xmlns:ns3="urn:banktest">
>
>   <errorDesc xsi:type="xsd:string">Invalid date format</errorDesc>
>
>   <errorCode xsi:type="xsd:int">1220</errorCode>
>
>  </multiRef>
>
> </soapenv:Body>
>
> </soapenv:Envelope>
>
> [CUT]
>
> A very good reference on exception handling is here:
>
> Web services programming tips and tricks: Exception Handling with JAX-RPC
> URL: http://www-106.ibm.com/developerworks/xml/library/ws-tip-jaxrpc.html
>
> ----- Original Message -----
> From: "Lorenzo Dalla Vecchia" <lor.dv@tiscali.it>
> To: <axis-user@ws.apache.org>
> Sent: Saturday, January 22, 2005 5:53 PM
> Subject: AxisFault with custom exception
>
>
>> Hello everyone.
>>
>> I'm new to Axis and to this mailing list and I'm having a hard time 
>> trying
>> to throw custom exceptions from my Axis web service.
>>
>> I'm working with a simple test project. Here's my exception class:
>>
>> public class MyException
>>     extends Exception
>> {
>>     private String nome1;
>>     private String nome2;
>>
>>     public MyException(String nome1, String nome2)
>>     {
>>         this.nome1 = nome1;
>>         this.nome2 = nome2;
>>     }
>>     public void setNome1(String nome1) {
>>         this.nome1 = nome1;
>>     }
>>     public String getNome1() {
>>         return nome1;
>>     }
>>     public void setNome2(String nome2) {
>>         this.nome2 = nome2;
>>     }
>>      public String getNome2() {
>>         return nome2;
>>     }
>> }
>>
>> I followed the "bean" pattern to have Axis serialize it automatically.
>> Java2WSDL produces the following description for the exception, which I
>> think is correct.
>>
>>       <complexType name="MyException">
>>         <sequence>
>>           <element name="nome1" nillable="true" type="xsd:string"/>
>>           <element name="nome2" nillable="true" type="xsd:string"/>
>>         </sequence>
>>       </complexType>
>>
>> I then execute WSDL2Java to generate proxy client classes and WSDD
>> descriptors. Here is the type binding in deply.wsdd:
>>
>>       <typeMapping
>>         xmlns:ns=http://test
>>         qname="ns:MyException"
>>         type="java:text.proxy.MyException"
>>         serializer="org.apache.axis.encoding.ser.BeanSerializerFactory"
>>
> deserializer="org.apache.axis.encoding.ser.BeanDeserializerFactory"
>>         encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
>>       />
>>
>> Now, the part where the problem arises. I build a simple client that 
>> calls
> a
>> method throwing MyException and here's the result:
>>
>> AxisFault
>>  faultCode:
> {http://schemas.xmlsoap.org/soap/envelope/}Server.userException
>>  faultSubcode:
>>  faultString: test.MyException
>>  faultActor:
>>  faultNode:
>>  faultDetail:
>>  {http://xml.apache.org/axis/}hostname:atlantis
>>
>> test.MyException
>>  at
>>
> org.apache.axis.message.SOAPFaultBuilder.createFault(SOAPFaultBuilder.java:2
> 21)
>>  at
>>
> org.apache.axis.message.SOAPFaultBuilder.endElement(SOAPFaultBuilder.java:12
> 8)
>>  at
>>
> org.apache.axis.encoding.DeserializationContext.endElement(DeserializationCo
> ntext.java:1083)
>>  at org.apache.crimson.parser.Parser2.maybeElement(Unknown Source)
>>  at org.apache.crimson.parser.Parser2.content(Unknown Source)
>>  at org.apache.crimson.parser.Parser2.maybeElement(Unknown Source)
>>  at org.apache.crimson.parser.Parser2.content(Unknown Source)
>>  at org.apache.crimson.parser.Parser2.maybeElement(Unknown Source)
>>  at org.apache.crimson.parser.Parser2.parseInternal(Unknown Source)
>>  at org.apache.crimson.parser.Parser2.parse(Unknown Source)
>>  at org.apache.crimson.parser.XMLReaderImpl.parse(Unknown Source)
>>  at javax.xml.parsers.SAXParser.parse(Unknown Source)
>>  at
>>
> org.apache.axis.encoding.DeserializationContext.parse(DeserializationContext
> .java:226)
>>  at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:645)
>>  at org.apache.axis.Message.getSOAPEnvelope(Message.java:424)
>>  at
>>
> org.apache.axis.handlers.soap.MustUnderstandChecker.invoke(MustUnderstandChe
> cker.java:62)
>>  at org.apache.axis.client.AxisClient.invoke(AxisClient.java:173)
>>  at org.apache.axis.client.Call.invokeEngine(Call.java:2719)
>>  at org.apache.axis.client.Call.invoke(Call.java:2702)
>>  at org.apache.axis.client.Call.invoke(Call.java:2378)
>>  at org.apache.axis.client.Call.invoke(Call.java:2301)
>>  at org.apache.axis.client.Call.invoke(Call.java:1758)
>>  at test.proxy.HelloStub.sayHello(HelloStub.java:147)
>>  at test.Client.main(Client.java:23)
>> Exception in thread "main"
>>
>> "atlantis" is my computer netbios name.
>> What is this AxisFault? I suspect it may be a problem with 
>> deserialization
>> since the returned SOAP reply (captured with TCPMonitor) is:
>>
>> <soapenv:Envelope
> xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
>> xmlns:xsd="http://www.w3.org/2001/XMLSchema"
>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
>>   <soapenv:Body>
>>     <soapenv:Fault>
>>       <faultcode>soapenv:Server.userException</faultcode>
>>       <faultstring>test.MyException</faultstring>
>>       <detail>
>>         <ns1:hostname
>> xmlns:ns1="http://xml.apache.org/axis/">atlantis</ns1:hostname>
>>       </detail>
>>     </soapenv:Fault>
>>   </soapenv:Body>
>> </soapenv:Envelope>
>>
>> Since MyException carries two Strings (say "string1" and "string2"),
>> shouldn't it look like <faultstring>test.MyException: string1,
>> string2</faultstring> or something like that?
>>
>> When I throws Exception instances (not subclasses) they got serialized
> with
>> <faultstring>java.lang.Exception: message</faultstring> and work. Also
>> there's no problem with throwing RemoteException.
>>
>> I'm using the latest Axis 1.2RC2 since Axis 1.1 refused to serialize
>> Exception subclasses due to the "cause" field of type Throwable that was
>> added in JVM 1.4 (wich I'm using).
>>
>> Please help me: I'm completely lost.
>> Thanks in advance.
>>
>> --
>> Lorenzo
>>
>>
>
> 



Mime
View raw message