gpt4 book ai didi

java - 仍然无法从端点访问 SoapHeader

转载 作者:行者123 更新时间:2023-12-02 05:26:20 25 4
gpt4 key购买 nike

我是网络服务新手。经过大量谷歌搜索并尝试了有关从端点访问 SoapHeader 的所有内容后,我仍然无法让它工作。我收到以下错误:

java.lang.IllegalStateException: No adapter for endpoint when adding SoapHeader in the method signature of the handling method.

如果删除 SoapHeader 参数,就不会遇到任何问题。

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:sws="http://www.springframework.org/schema/web-services"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/web-services
http://www.springframework.org/schema/web-services/web-services-2.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd">

<context:annotation-config />
<context:component-scan base-package="services" />
<sws:annotation-driven />

<sws:interceptors>
<bean id="validatingInterceptor"
class="org.springframework.ws.soap.server.endpoint.interceptor.PayloadValidatingInterceptor">
<property name="schema" value="/WEB-INF/schemas/cfPostBack2015.xsd" />
<property name="validateRequest" value="true"/>
<property name="validateResponse" value="true"/>
</bean>
<bean id="loggingInterceptor"
class="org.springframework.ws.server.endpoint.interceptor.PayloadLoggingInterceptor" />
</sws:interceptors>

<sws:static-wsdl id="postBackService2015"
location="/WEB-INF/schemas/postBackService2015.wsdl" />

<bean id="marshaller" class="org.springframework.oxm.xmlbeans.XmlBeansMarshaller" />
<bean id="marshallingPayloadMethodProcessor"
class="org.springframework.ws.server.endpoint.adapter.method.MarshallingPayloadMethodProcessor">
<constructor-arg ref="marshaller"/>
<constructor-arg ref="marshaller"/>
</bean>

<bean id="defaultMethodEndpointAdapter"
class="org.springframework.ws.server.endpoint.adapter.DefaultMethodEndpointAdapter">
<property name="methodArgumentResolvers">
<list>
<ref bean="marshallingPayloadMethodProcessor" />
</list>
</property>
<property name="methodReturnValueHandlers">
<list>
<ref bean="marshallingPayloadMethodProcessor" />
</list>
</property>
</bean>


<bean id="postbackService"
class="PostBackServiceImpl" />
<bean id="postBackEndpoint"
class="PostBackEndpoint">
<property name="postBackService" ref="postBackService" />
</bean>

</beans>

端点类:

package endpoints;

import javax.annotation.Resource;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ws.server.endpoint.annotation.Endpoint;
import org.springframework.ws.server.endpoint.annotation.PayloadRoot;
import org.springframework.ws.server.endpoint.annotation.RequestPayload;
import org.springframework.ws.server.endpoint.annotation.ResponsePayload;
import org.springframework.ws.soap.SoapHeader;

import PostBackService;
import cfPostBack.x2015.PostBackRequestDocument;
import cfPostBack.x2015.PostBackResponseDocument;

@Endpoint
public class PostBackServiceEndpoint {
private static final String TARGET_NAMESPACE =
"http://services/cfPostBack/2015/";

@Resource(name="postBackService")
private PostBackService postBackService;

@Autowired
public PostBackServiceEndpoint(PostBackService postBackService) {
this.postBackService = postBackService;
}

@PayloadRoot(localPart = "postBackRequest", namespace = TARGET_NAMESPACE)
@ResponsePayload
public PostBackResponseDocument getPostBackResponse(
@RequestPayload PostBackRequestDocument request, SoapHeader soapHeader)
throws Exception {

PostBackResponseDocument response =
postBackService.processPostBackRequest(request);

return response;
}

public void setPostBackService(PostBackService postBackService) {
this.postBackService = postBackService;
}
}

最佳答案

您可能需要将 org.springframework.ws.soap.server.endpoint.adapter.method.SoapMethodArgumentResolver bean 添加到 methodArgumentResolvers 列表中。

关于java - 仍然无法从端点访问 SoapHeader,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25980487/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com