简体   繁体   English

如何从Java中的肥皂响应获取错误消息

[英]How to get error message from soap response in Java

I used Jax-ws web services and generated client code using wsimport (Java API) from wsdl. 我使用了Jax-ws Web服务,并使用了来自wsdl的wsimport(Java API)生成了客户端代码 When I execute one request using SAOP UI then I got following output. 当我使用SAOP UI执行一个请求时,我得到以下输出。

 <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns="http://schemas.xmlsoap.org/soap/envelope/">
 <SOAP-ENV:Header/>
 <SOAP-ENV:Body>
  <SOAP-ENV:Error>Cannot create a new Goal for Receiver with Id : 3,as a Goal already exists </SOAP-ENV:Error>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

I want to fetch above error message using java as it is not coming in response object . 我想使用java来获取上述错误消息,因为它没有出现在响应对象中 I tried using Binding Provider but no luck . 我尝试使用Binding Provider但没有运气 Any help to get this message will be appreciated. 任何帮助获得此消息将不胜感激。

Depending on the WS Engine you are using, you will receive an exception when a SOAP Fault happens. 根据所使用的WS Engine,当SOAP Fault发生时,您将收到异常。 You will then be able to get the message from that exception object. 然后,您将能够从该异常对象获取消息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM