Исключение java saaj

#java #soap #saaj

#java #soap #saaj

Вопрос:

Я пытаюсь создать Soap-конверт из строки, используя

 SOAPPart().setContent(Source).
  

И я пытаюсь получить SOAPBody из того же сообщения, но он выдает исключение

 SEVERE: SAAJ0511: Unable to create envelope from given source
com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl: Unable to create envelope from given source: 
    at com.sun.xml.internal.messaging.saaj.soap.EnvelopeFactory.createEnvelope(EnvelopeFactory.java:114)
    at com.sun.xml.internal.messaging.saaj.soap.ver1_1.SOAPPart1_1Impl.createEnvelopeFromSource(SOAPPart1_1Impl.java:70)
    at com.sun.xml.internal.messaging.saaj.soap.SOAPPartImpl.getEnvelope(SOAPPartImpl.java:122)
    at com.sun.xml.internal.messaging.saaj.soap.MessageImpl.getSOAPBody(MessageImpl.java:1253)
    at mytransactions.Test.main(Test.java:107)
Caused by: javax.xml.transform.TransformerException: XML-22103: (Fatal Error) DOMResult can not be this kind of node.
    at oracle.xml.jaxp.JXTransformer.reportException(JXTransformer.java:883)
    at oracle.xml.jaxp.JXTransformer.transform(JXTransformer.java:353)
    at com.sun.xml.internal.messaging.saaj.util.transform.EfficientStreamingTransformer.transform(EfficientStreamingTransformer.java:393)
    at com.sun.xml.internal.messaging.saaj.soap.EnvelopeFactory.createEnvelope(EnvelopeFactory.java:102)
    ... 4 more

CAUSE:

javax.xml.transform.TransformerException: XML-22103: (Fatal Error) DOMResult can not be this kind of node.
    at oracle.xml.jaxp.JXTransformer.reportException(JXTransformer.java:883)
    at oracle.xml.jaxp.JXTransformer.transform(JXTransformer.java:353)
    at com.sun.xml.internal.messaging.saaj.util.transform.EfficientStreamingTransformer.transform(EfficientStreamingTransformer.java:393)
    at com.sun.xml.internal.messaging.saaj.soap.EnvelopeFactory.createEnvelope(EnvelopeFactory.java:102)
    at com.sun.xml.internal.messaging.saaj.soap.ver1_1.SOAPPart1_1Impl.createEnvelopeFromSource(SOAPPart1_1Impl.java:70)
    at com.sun.xml.internal.messaging.saaj.soap.SOAPPartImpl.getEnvelope(SOAPPartImpl.java:122)
    at com.sun.xml.internal.messaging.saaj.soap.MessageImpl.getSOAPBody(MessageImpl.java:1253)
    at mytransactions.Test.main(Test.java:107)

CAUSE:

javax.xml.transform.TransformerException: XML-22103: (Fatal Error) DOMResult can not be this kind of node.
    at oracle.xml.jaxp.JXTransformer.reportException(JXTransformer.java:883)
    at oracle.xml.jaxp.JXTransformer.transform(JXTransformer.java:353)
    at com.sun.xml.internal.messaging.saaj.util.transform.EfficientStreamingTransformer.transform(EfficientStreamingTransformer.java:393)
    at com.sun.xml.internal.messaging.saaj.soap.EnvelopeFactory.createEnvelope(EnvelopeFactory.java:102)
    at com.sun.xml.internal.messaging.saaj.soap.ver1_1.SOAPPart1_1Impl.createEnvelopeFromSource(SOAPPart1_1Impl.java:70)
    at com.sun.xml.internal.messaging.saaj.soap.SOAPPartImpl.getEnvelope(SOAPPartImpl.java:122)
    at com.sun.xml.internal.messaging.saaj.soap.MessageImpl.getSOAPBody(MessageImpl.java:1253)
    at mytransactions.Test.main(Test.java:107)
  

Как это исправить?

Комментарии:

1. эта проблема из-за _oracle.xml.jaxp.JXTransformer.transform. Я не могу удалить этот файл jar. Как заставить мое приложение использовать библиотеки XML по умолчанию?

Ответ №1:

API служб будет искать имя класса в файле META-INF/services/javax.xml.transform.TransformerFactory в jars, доступных для среды выполнения. Я переопределяю это свойство с помощью опции jvm -D.