jaxws webMethod自定义异常

时间:2020-04-16 08:28:09

标签: java exception jax-ws

我有手术

<wsdl:operation name="importAcknowledgment">
  <wsdl:documentation>Импорт запросов на проведение квитирования</wsdl:documentation>
  <wsdl:input message="tns:importAcknowledgmentRequest"/>
  <wsdl:output message="tns:importAcknowledgmentResult"/>
  <wsdl:fault name="InvalidRequest" message="tns:Fault"/>
</wsdl:operation>
<xs:element name="Fault">
  <xs:annotation>
    <xs:documentation>Элемент Fault (для параметра Fault в операции)</xs:documentation>
  </xs:annotation>
  <xs:complexType>
    <xs:annotation>
      <xs:documentation>Базовый тип для fault-ошибки</xs:documentation>
    </xs:annotation>
    <xs:sequence>
      <xs:element name="ErrorCode" type="xs:string"/>
      <xs:element name="ErrorMessage" type="xs:string" minOccurs="0"/>
      <xs:element name="StackTrace" type="xs:string" minOccurs="0"/>
    </xs:sequence>
  </xs:complexType>
</xs:element>

从该模式jaxws生成方法

    @WebMethod(action = "urn:importAcknowledgment")
    @WebResult(name = "AckRequest", targetNamespace = "http://dom.gosuslugi.ru/schema/integration/base/", partName = "importAcknowledgmentResult")
    public AckRequest importAcknowledgment(
        @WebParam(name = "importAcknowledgmentRequest", targetNamespace = "http://dom.gosuslugi.ru/schema/integration/bills/", partName = "importAcknowledgmentRequest")
        ImportAcknowledgmentRequest importAcknowledgmentRequest)
        throws Fault
    ;

当我调用此方法时,我得到xml:

<env:Envelope>
  <env:Body>
    <env:Fault>
      <faultcode>env:Server</faultcode>
      <faultstring>FMT001300: Некорректный XML</faultstring>
      <detail>
        <ns4:Fault>
          <ns4:ErrorCode>FMT001300</ns4:ErrorCode>
          <ns4:ErrorMessage>Некорректный XML</ns4:ErrorMessage>
          <ns4:StackTrace>Line: 1...</ns4:StackTrace>
        </ns4:Fault>
      </detail>
    </env:Fault>
  </env:Body>
</env:Envelope>

我希望我得到故障类型的异常,但我得到ClientTransportException服务器发送了HTTP状态代码400。 我做错了什么。以及如何获取故障异常?

0 个答案:

没有答案
相关问题