wsdl2ruby SOAP::FaultError 详细属性中的解组异常

发布于 2024-07-21 09:40:12 字数 311 浏览 3 评论 0原文

我使用 wsdl2ruby 生成 Web 服务的客户端。 当服务方法引发 WSDL 中定义的异常之一时,我想访问异常对象的属性。 据我所知,异常对象已被编组到 SOAP::Mapping::Object 中,该对象由可用于 RESCUE 块的 SOAP::FaultError 对象的详细信息属性引用。

虽然 SOAP::Mapping::Object 响应 marshal_load 方法,但该方法采用一个参数 dumpobj,这让我觉得我应该提供该对象作为方法的参数,而不是使用该对象作为方法的接收者。

任何人都可以向我指出解组异常对象的正确方法的示例吗?

I've used wsdl2ruby to generate a client for a web service. When a service method raises one of the exceptions defined in the WSDL I'd like to access the exception object's attributes. From what I can tell the exception object has been marshalled into a SOAP::Mapping::Object that's referenced by the detail attribute of the SOAP::FaultError object that's made available to the RESCUE block.

Although SOAP::Mapping::Object responds to a marshal_load method, that method takes one parameter, dumpobj, which makes me think I'm supposed to provide that object as the method's parameter rather than use the object as the method's receiver.

Can anyone point me to an example of the proper way to unmarshal the exception object?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

手心的海 2024-07-28 09:40:12

如果您探究 SOAP::Mapping::Object ...,看起来解组已经完成

rescue SOAP::FaultError => ee
  ## InvalidLogin, InvalidLocale, NoPermission, RuntimeFault
  ## ee.detail.__xmlele[0][0] is an XSD::QName object, with accessors name and namespace
  ## ee.detail.__xmlele[0][1] is a VMware::VIM25::xxx fault object
  vim_fault = ee.detail.__xmlele[0][1]
  case vim_fault.class
  when VMware::VIM25::InvalidLogin
  when VMware::VIM25::InvalidLocale
  when VMware::VIM25::NoPermission
  when VMware::VIM25::RuntimeFault

looks like the unmarshalling is already done, if you probe into the SOAP::Mapping::Object ...

rescue SOAP::FaultError => ee
  ## InvalidLogin, InvalidLocale, NoPermission, RuntimeFault
  ## ee.detail.__xmlele[0][0] is an XSD::QName object, with accessors name and namespace
  ## ee.detail.__xmlele[0][1] is a VMware::VIM25::xxx fault object
  vim_fault = ee.detail.__xmlele[0][1]
  case vim_fault.class
  when VMware::VIM25::InvalidLogin
  when VMware::VIM25::InvalidLocale
  when VMware::VIM25::NoPermission
  when VMware::VIM25::RuntimeFault
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文