Jaxws WebMethod Custom Exception - PullRequest
0 голосов
/ 16 апреля 2020

У меня есть операция:

<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>

Я надеюсь, что я получаю Exception типа Fault, но я получаю ClientTransportException Сервер отправил HTTP-код состояния 400. Что я не так делаю. А как получить Fault Exception?

...