Java 如何在SpringSOAPWeb服务中缓存JAXB上下文?
我们通过SpringInsight和NewRelic分析了我们的SpringSOAPWeb服务,超过60%的时间都用在Springjar上。我们猜测这与日志、jaxb上下文有关。我们正在公开soap wsJava 如何在SpringSOAPWeb服务中缓存JAXB上下文?,java,spring,web-services,soap,jaxb,Java,Spring,Web Services,Soap,Jaxb,我们通过SpringInsight和NewRelic分析了我们的SpringSOAPWeb服务,超过60%的时间都用在Springjar上。我们猜测这与日志、jaxb上下文有关。我们正在公开soap ws <bean class="org.springframework.ws.soap.security.xwss.XwsSecurityInterceptor"> <property name="policyConfiguration" value="/W
<bean class="org.springframework.ws.soap.security.xwss.XwsSecurityInterceptor">
<property name="policyConfiguration" value="/WEB-INF/securityPolicy.xml"/>
<property name="callbackHandlers">
<list>
<ref bean="callbackHandler"/>
</list>
</property>
</bean>
</sws:interceptors>
<bean id="callbackHandler" class="org.springframework.ws.soap.security.xwss.callback.SimplePasswordValidationCallbackHandler">
<property name="users">
<props>
</props>
</property>
</bean>
<sws:static-wsdl id="employeeTransfer" location="/WEB-INF/wsdl/employeeTransfer.wsdl" />
我们还观察到,安全头占用了一些时间
<bean class="org.springframework.ws.soap.security.xwss.XwsSecurityInterceptor">
<property name="policyConfiguration" value="/WEB-INF/securityPolicy.xml"/>
<property name="callbackHandlers">
<list>
<ref bean="callbackHandler"/>
</list>
</property>
</bean>
</sws:interceptors>
<bean id="callbackHandler" class="org.springframework.ws.soap.security.xwss.callback.SimplePasswordValidationCallbackHandler">
<property name="users">
<props>
</props>
</property>
</bean>
<sws:static-wsdl id="employeeTransfer" location="/WEB-INF/wsdl/employeeTransfer.wsdl" />
我们可以在SpringSOAPWeb服务中缓存JAXB上下文吗?或
还有其他提高SpringSOAPWeb服务性能的指标吗
<bean class="org.springframework.ws.soap.security.xwss.XwsSecurityInterceptor">
<property name="policyConfiguration" value="/WEB-INF/securityPolicy.xml"/>
<property name="callbackHandlers">
<list>
<ref bean="callbackHandler"/>
</list>
</property>
</bean>
</sws:interceptors>
<bean id="callbackHandler" class="org.springframework.ws.soap.security.xwss.callback.SimplePasswordValidationCallbackHandler">
<property name="users">
<props>
</props>
</property>
</bean>
<sws:static-wsdl id="employeeTransfer" location="/WEB-INF/wsdl/employeeTransfer.wsdl" />
谢谢你的帮助
<bean class="org.springframework.ws.soap.security.xwss.XwsSecurityInterceptor">
<property name="policyConfiguration" value="/WEB-INF/securityPolicy.xml"/>
<property name="callbackHandlers">
<list>
<ref bean="callbackHandler"/>
</list>
</property>
</bean>
</sws:interceptors>
<bean id="callbackHandler" class="org.springframework.ws.soap.security.xwss.callback.SimplePasswordValidationCallbackHandler">
<property name="users">
<props>
</props>
</property>
</bean>
<sws:static-wsdl id="employeeTransfer" location="/WEB-INF/wsdl/employeeTransfer.wsdl" />
配置详细信息:-
<bean class="org.springframework.ws.soap.security.xwss.XwsSecurityInterceptor">
<property name="policyConfiguration" value="/WEB-INF/securityPolicy.xml"/>
<property name="callbackHandlers">
<list>
<ref bean="callbackHandler"/>
</list>
</property>
</bean>
</sws:interceptors>
<bean id="callbackHandler" class="org.springframework.ws.soap.security.xwss.callback.SimplePasswordValidationCallbackHandler">
<property name="users">
<props>
</props>
</property>
</bean>
<sws:static-wsdl id="employeeTransfer" location="/WEB-INF/wsdl/employeeTransfer.wsdl" />
<bean class="org.springframework.ws.soap.security.xwss.XwsSecurityInterceptor">
<property name="policyConfiguration" value="/WEB-INF/securityPolicy.xml"/>
<property name="callbackHandlers">
<list>
<ref bean="callbackHandler"/>
</list>
</property>
</bean>
</sws:interceptors>
<bean id="callbackHandler" class="org.springframework.ws.soap.security.xwss.callback.SimplePasswordValidationCallbackHandler">
<property name="users">
<props>
</props>
</property>
</bean>
<sws:static-wsdl id="employeeTransfer" location="/WEB-INF/wsdl/employeeTransfer.wsdl" />
<bean class="org.springframework.ws.soap.security.xwss.XwsSecurityInterceptor">
<property name="policyConfiguration" value="/WEB-INF/securityPolicy.xml"/>
<property name="callbackHandlers">
<list>
<ref bean="callbackHandler"/>
</list>
</property>
</bean>
</sws:interceptors>
<bean id="callbackHandler" class="org.springframework.ws.soap.security.xwss.callback.SimplePasswordValidationCallbackHandler">
<property name="users">
<props>
</props>
</property>
</bean>
<sws:static-wsdl id="employeeTransfer" location="/WEB-INF/wsdl/employeeTransfer.wsdl" />
实例化JAXBContext在执行时间方面是非常昂贵的操作。您应该定义一个具有单例作用域的Jaxb2Marshaller(在Spring3.0的OXM包中),以便在应用程序中只进行一次初始化。你能发布你的配置来看看你现在是怎么做的吗?“超过60%的时间都花在Springjar上了”,这并不能说明什么。它挂在哪个部件上,速度真的很慢,还是只有2ms的60%?你真的应该更具体,在哪些部分是缓慢的,你想优化。谢谢你的答复。总共需要7秒。但是,我们的java代码大约需要1.5秒。剩下的5.5秒用于spring框架的类。这是我们真正喜欢的配置文件或做一些事情来优化时间。我在您的配置中没有看到任何与Spring相关的bean。您是否在代码中手动初始化上下文?如果是,请发布相关的代码片段。