0

我们目前称为 SOAP Web 服务,它发回非常大的响应。

我们在调用 Web 服务时使用 Spring-WS(使用 WebServiceTemplate)、JAX-WS 客户端,并且应用程序在 Jboss EAP 6.0 上运行。

我们目前也使用 SaajSoapMessageFactory。我从论坛上读到应该使用 AxiomSoapMessageFactory 而不是 SaajSoapMessageFactory ( http://docs.spring.io/spring-ws/site/reference/html/common.html ) 来提高阅读性能。

我做了以下修改:

更换

<bean id="messageFactory" class="org.springframework.ws.soap.saaj.SaajSoapMessageFactory"> 
        <property name="soapVersion">
            <util:constant static-field="org.springframework.ws.soap.SoapVersion.SOAP_11" />
        </property>
    </bean>

经过

 <bean id="messageFactory" class="org.springframework.ws.soap.axiom.AxiomSoapMessageFactory">
        <property name="payloadCaching" value="true"/>
    </bean>

此更改按预期工作得很好。但是,我上面提到的链接建议设置执行以下操作:

 <property name="payloadCaching" value="false"/>

设置此选项并调用 Web 服务后,出现以下异常:

org.springframework.ws.soap.axiom.AxiomSoapBodyException: Could not access envelope: null; nested exception is org.apache.axiom.om.NodeUnavailableException: org.springframework.ws.soap.axiom.AxiomSoapBodyException: Could not access envelope: null; nested exception is org.apache.axiom.om.NodeUnavailableException
    at org.springframework.ws.soap.axiom.AxiomSoapEnvelope.getBody(AxiomSoapEnvelope.java:97) [:2.2.0.RELEASE]
    at org.springframework.ws.soap.AbstractSoapMessage.getSoapBody(AbstractSoapMessage.java:38) [:2.2.0.RELEASE]
    at org.springframework.ws.soap.AbstractSoapMessage.getPayloadSource(AbstractSoapMessage.java:50) [:2.2.0.RELEASE]
    at org.springframework.ws.support.MarshallingUtils.unmarshal(MarshallingUtils.java:55) [:2.2.0.RELEASE]
    at org.springframework.ws.client.core.WebServiceTemplate$3.extractData(WebServiceTemplate.java:413) [:2.2.0.RELEASE]
    at org.springframework.ws.client.core.WebServiceTemplate.doSendAndReceive(WebServiceTemplate.java:616) [:2.2.0.RELEASE]
    at org.springframework.ws.client.core.WebServiceTemplate.sendAndReceive(WebServiceTemplate.java:555) [:2.2.0.RELEASE]
    at org.springframework.ws.client.core.WebServiceTemplate.marshalSendAndReceive(WebServiceTemplate.java:390) [:2.2.0.RELEASE]
    at org.springframework.ws.client.core.WebServiceTemplate.marshalSendAndReceive(WebServiceTemplate.java:383) [:2.2.0.RELEASE]
    at org.springframework.ws.client.core.WebServiceTemplate.marshalSendAndReceive(WebServiceTemplate.java:373) [:2.2.0.RELEASE]

关于为什么会出现此错误的任何想法?我是否错过了更改任何其他选项,或者是我使用的库文件不兼容。

另一个问题:


在注释掉与 og4j.logger.org.springframework.ws.client.MessageTracing 相关的 log4j 条目后,我能够成功使用 Web 服务。还进行了性能测试,发现对于同时访问 Web 服务的 50 个用户的测试(间接通过依次调用 Web 服务的屏幕),总响应时间(从单击按钮的那一刻到响应的那一刻Web 服务重新显示在屏幕上)从 ~ 27 秒减少到 22 秒 - 这比 SaajSoapMessageFactory 改进了 5 秒。但是,当我运行 100 个用户的测试时,响应时间增加了 2 秒,并且 SaajSoapMessageFactory 在这种情况下似乎更好。尽管 AxiomSoapMessageFactory 使用流式传输并避免构建树,但有人可以解释这种性能差异的原因吗?

4

1 回答 1

1

payloadCaching=false指示 Axiom 不要为有效负载构建对象模型树。这是实现性能提升的原因,但它也意味着有效负载只能访问一次。在较旧的 Axiom 版本中,再次尝试访问有效负载会导致OMException. 在最新版本中,它会触发JavadocNodeUnavailableException中记录的a 。正如您在评论中指出的那样,在您的情况下,有效负载由跟踪日志记录使用。

于 2014-07-22T22:08:44.770 回答