在 WSDL 文件中指定抛出 AxisFault
我从 WSDL 文件生成 Web 服务。但我需要在这个文件中定义我在 SkeletonInterface 中的方法会出现轴故障异常。 类似:
void method() throws AxisFault{....}
我可以通过什么方式做到这一点(在 WSDL 中)。
谢谢。
I generate my web service from WSDL file. But I need t o define in this file that my methods in SkeletonInterface thow Axis Fault Exception.
Smth like:
void method() throws AxisFault{....}
In which way I can do this (in WSDL).
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
简而言之,针对您自己的应用程序错误重用 AxisFault 是一种不好的做法。当我看到 AxisFault 时,它表明 Axis autogen 代码内部的某些内容失败了。这可能包括包裹在其中的异常。
首先,我想解决你的伪代码。
该伪代码表明您想要一个没有输入、没有输出但仍然有异常的方法。如果我假设这一点,那么不推荐该设计(我什至不确定是否可能)。如果您希望某件事触发某件事而没有输出,则空输出消息比异常更可取。仅当发生不常见的情况时才应使用异常。
如果您将上面的代码作为一个抽象示例,并且您确实有输入/输出,那么正确的方法是弥补您自己的错误。利用自己的错误可以让你控制行为并更准确地描述失败的原因。您将来可能还需要多个故障,因此在这种情况下使用 AxisFault 并没有什么好处。
也就是说,
AxisFault
确实发生在 Web 服务操作调用中。对于您的客户端存根代码,它应该抛出RemoteException
。如果您查看 autogen Stub 代码,您应该会发现它实际上抛出了一个扩展了RemoteException
的 AxisFault。In short, it's bad practice to reuse
AxisFault
for your own application faults. When I seeAxisFault
, it signals that something internal to the Axis autogen code failed. This could include your exception wrapped inside of it.First, I want to address your pseudcode.
This pseudocode indicates that you want a method with no input, no output, but still have an exception. If I assume this, then that design is not recommended (I'm not even sure if it is possible). If you want something to trigger something to happen with no output, an empty output message is preferable to an exception. Exceptions should only be used when something uncommon happens.
If you meant the above code as an abstract example and you do have input/output, then the correct approach would be to make up your own fault. Using your own fault allows you to control behavior and more accurately describe what is failing. You may also need several faults in the future so using
AxisFault
is not beneficial in that case.That said,
AxisFault
does happen for web service operation calls. For your client stub code, it should throw aRemoteException
. If you take a look at your autogen Stub code, you should see that does in fact throw anAxisFault
which extendsRemoteException
.使用错误
using the faults