You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by FireElement <pi...@163.com> on 2008/09/20 06:30:13 UTC

How to throw a user defiend exception from a service interface

I define a web service using cxf, and my interface could throw MyException
which is inherited Excetpion. But when the exception is throw, from the
client side, I could only catch a SOAPFaultExceptioin but not MyException.
Who can give me a example about how to throw out a user defined Exception.
Thanks a lot!
-- 
View this message in context: http://www.nabble.com/How-to-throw-a-user-defiend-exception-from-a-service-interface-tp19582586p19582586.html
Sent from the cxf-user mailing list archive at Nabble.com.


Re: How to throw a user defiend exception from a service interface

Posted by FireElement <pi...@163.com>.
I have resolve the problem, and my resolution is similar with your link.
Thanks a lot for your help.
:-)



Christian Schneider wrote:
> 
> You can take a look at the following Howto:
> http://cwiki.apache.org/CXF20DOC/defining-contract-first-webservices-with-wsdl-generation-from-java.html
> 
> Greetings
> 
> Christian
> 
> jian wu schrieb:
>> Hi,
>>
>> If you are using JAX-WS, you can use "WebFault" annotation with
>> the "MyException", Your Web Service Definition would be sth like:
>> ============================================
>> // MyService.java
>> @WebService
>> public interface MyService {
>>
>> @WebMethod
>> MyResponse MyMethod( ...) throws MyException;
>>
>> }
>>
>> // MyException.java
>> @WebFault( ... )
>> public class MyException extends Exception {
>> }
>> ============================================
>>
>> Hope this would be helpful.
>>
>> Jian
>>
>> On Fri, Sep 19, 2008 at 9:30 PM, FireElement <pi...@163.com> wrote:
>>   
>>> I define a web service using cxf, and my interface could throw
>>> MyException
>>> which is inherited Excetpion. But when the exception is throw, from the
>>> client side, I could only catch a SOAPFaultExceptioin but not
>>> MyException.
>>> Who can give me a example about how to throw out a user defined
>>> Exception.
>>> Thanks a lot!
>>> --
>>> View this message in context:
>>> http://www.nabble.com/How-to-throw-a-user-defiend-exception-from-a-service-interface-tp19582586p19582586.html
>>> Sent from the cxf-user mailing list archive at Nabble.com.
>>>
>>>
>>>     
>>
>>   
> 
> 
> -- 
> 
> Christian Schneider
> ---
> http://www.liquid-reality.de
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/How-to-throw-a-user-defiend-exception-from-a-service-interface-tp19582586p19619530.html
Sent from the cxf-user mailing list archive at Nabble.com.


Re: How to throw a user defiend exception from a service interface

Posted by Christian Schneider <ch...@die-schneider.net>.
You can take a look at the following Howto:
http://cwiki.apache.org/CXF20DOC/defining-contract-first-webservices-with-wsdl-generation-from-java.html

Greetings

Christian

jian wu schrieb:
> Hi,
>
> If you are using JAX-WS, you can use "WebFault" annotation with
> the "MyException", Your Web Service Definition would be sth like:
> ============================================
> // MyService.java
> @WebService
> public interface MyService {
>
> @WebMethod
> MyResponse MyMethod( ...) throws MyException;
>
> }
>
> // MyException.java
> @WebFault( ... )
> public class MyException extends Exception {
> }
> ============================================
>
> Hope this would be helpful.
>
> Jian
>
> On Fri, Sep 19, 2008 at 9:30 PM, FireElement <pi...@163.com> wrote:
>   
>> I define a web service using cxf, and my interface could throw MyException
>> which is inherited Excetpion. But when the exception is throw, from the
>> client side, I could only catch a SOAPFaultExceptioin but not MyException.
>> Who can give me a example about how to throw out a user defined Exception.
>> Thanks a lot!
>> --
>> View this message in context: http://www.nabble.com/How-to-throw-a-user-defiend-exception-from-a-service-interface-tp19582586p19582586.html
>> Sent from the cxf-user mailing list archive at Nabble.com.
>>
>>
>>     
>
>   


-- 

Christian Schneider
---
http://www.liquid-reality.de


Re: How to throw a user defiend exception from a service interface

Posted by FireElement <pi...@163.com>.
Yes, I have do that. And it's need to add getFaultInfo() method to the
MyException class. And I have resolve this problem. But also thanks very
much to your help:-)


Jian.Wu wrote:
> 
> Hi,
> 
> If you are using JAX-WS, you can use "WebFault" annotation with
> the "MyException", Your Web Service Definition would be sth like:
> ============================================
> // MyService.java
> @WebService
> public interface MyService {
> 
> @WebMethod
> MyResponse MyMethod( ...) throws MyException;
> 
> }
> 
> // MyException.java
> @WebFault( ... )
> public class MyException extends Exception {
> }
> ============================================
> 
> Hope this would be helpful.
> 
> Jian
> 
> On Fri, Sep 19, 2008 at 9:30 PM, FireElement <pi...@163.com> wrote:
>>
>> I define a web service using cxf, and my interface could throw
>> MyException
>> which is inherited Excetpion. But when the exception is throw, from the
>> client side, I could only catch a SOAPFaultExceptioin but not
>> MyException.
>> Who can give me a example about how to throw out a user defined
>> Exception.
>> Thanks a lot!
>> --
>> View this message in context:
>> http://www.nabble.com/How-to-throw-a-user-defiend-exception-from-a-service-interface-tp19582586p19582586.html
>> Sent from the cxf-user mailing list archive at Nabble.com.
>>
>>
> 
> 
:-):-):-):-):-):-):-):-):-):-)
-- 
View this message in context: http://www.nabble.com/How-to-throw-a-user-defiend-exception-from-a-service-interface-tp19582586p19619501.html
Sent from the cxf-user mailing list archive at Nabble.com.


Re: How to throw a user defiend exception from a service interface

Posted by jian wu <he...@gmail.com>.
Hi,

If you are using JAX-WS, you can use "WebFault" annotation with
the "MyException", Your Web Service Definition would be sth like:
============================================
// MyService.java
@WebService
public interface MyService {

@WebMethod
MyResponse MyMethod( ...) throws MyException;

}

// MyException.java
@WebFault( ... )
public class MyException extends Exception {
}
============================================

Hope this would be helpful.

Jian

On Fri, Sep 19, 2008 at 9:30 PM, FireElement <pi...@163.com> wrote:
>
> I define a web service using cxf, and my interface could throw MyException
> which is inherited Excetpion. But when the exception is throw, from the
> client side, I could only catch a SOAPFaultExceptioin but not MyException.
> Who can give me a example about how to throw out a user defined Exception.
> Thanks a lot!
> --
> View this message in context: http://www.nabble.com/How-to-throw-a-user-defiend-exception-from-a-service-interface-tp19582586p19582586.html
> Sent from the cxf-user mailing list archive at Nabble.com.
>
>