use*_*865 17 java spring-ws jms
我正在努力使用带有JMS示例的Spring-WS.我按照Spring的建议设置了Spring-WS和JMS接线.但我一直得到以下错误.我不知道如何绕过这个问题,任何帮助将不胜感激:
[org.springframework.ws.soap.server.endpoint.SoapFaultAnnotationExceptionResolver] -
Resolving exception from endpoint
[org.springframework.ws.samples.mtom.ws.ImageRepositoryEndpoint@1c8b0b1]:
java.lang.IllegalStateException: No adapter for endpoint
[org.springframework.ws.samples.mtom.ws.ImageRepositoryEndpoint@1c8b0b1]:
Is your endpoint annotated with @Endpoint, or does it implement a supported interface like MessageHandler or PayloadEndpoint?
[org.springframework.ws.soap.server.endpoint.SimpleSoapExceptionResolver] - Resolving exception from endpoint
[org.springframework.ws.samples.mtom.ws.ImageRepositoryEndpoint@1c8b0b1]:
java.lang.IllegalStateException: No adapter for endpoint [org.springframework.ws.samples.mtom.ws.ImageRepositoryEndpoint@1c8b0b1]:
Is your endpoint annotated with @Endpoint, or does it implement a supported interface like MessageHandler or PayloadEndpoint?
[org.springframework.ws.soap.server.SoapMessageDispatcher] -
Endpoint invocation resulted in exception - responding with Fault
java.lang.IllegalStateException: No adapter for endpoint [org.springframework.ws.samples.mtom.ws.ImageRepositoryEndpoint@1c8b0b1]:
Is your endpoint annotated with @Endpoint, or does it implement a supported interface like MessageHandler or PayloadEndpoint?
Run Code Online (Sandbox Code Playgroud)
我的Web服务接线是
<bean id="imageRepository"
class="org.springframework.ws.samples.mtom.service.StubImageRepository" />
<!-- JMS WIRING TO WS START -->
<bean id="messageFactory" class="org.springframework.ws.soap.saaj.SaajSoapMessageFactory" />
<bean id="messageDispatcher"
class="org.springframework.ws.soap.server.SoapMessageDispatcher">
<property name="endpointMappings">
<bean
class="org.springframework.ws.server.endpoint.mapping.PayloadRootAnnotationMethodEndpointMapping">
<property name="defaultEndpoint">
<bean
class="org.springframework.ws.samples.mtom.ws.ImageRepositoryEndpoint">
<constructor-arg ref="imageRepository" />
</bean>
</property>
</bean>
</property>
</bean>
<bean
class="org.springframework.jms.listener.DefaultMessageListenerContainer">
<property name="connectionFactory" ref="jmsConnectionFactory" />
<property name="destinationName" value="WS.JMS.EXAMPLE.V1.IMAGE.REPO.REQUEST" />
<property name="messageListener">
<bean
class="org.springframework.ws.transport.jms.WebServiceMessageListener">
<property name="messageFactory" ref="messageFactory" />
<property name="messageReceiver" ref="messageDispatcher" />
</bean>
</property>
</bean>
Run Code Online (Sandbox Code Playgroud)
我的终点代码是
@PayloadRoot(localPart = "StoreImageRequest", namespace = "http://www.springframework.org/spring-ws/samples/mtom")
@ResponsePayload
public String store(@RequestPayload JAXBElement<Image> requestElement) throws IOException {
Image request = requestElement.getValue();
return imageRepository.storeImage(request.getName());
}
Run Code Online (Sandbox Code Playgroud)
我的架构是
<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.springframework.org/spring-ws/samples/mtom"
xmlns:tns="http://www.springframework.org/spring-ws/samples/mtom"
xmlns:xmime="http://www.w3.org/2005/05/xmlmime" elementFormDefault="qualified">
<element name="StoreImageRequest" type="tns:Image"/>
<element name="LoadImageRequest" type="string"/>
<element name="LoadImageResponse" type="tns:Image"/>
<complexType name="Image">
<sequence>
<element name="name" type="string"/>
</sequence>
</complexType>
</schema>
Run Code Online (Sandbox Code Playgroud)
我的客户请求是
<ns2:StoreImageRequest xmlns:ns2="http://www.springframework.org/spring-ws/samples/mtom"><ns2:name>spring-ws-logo.png</ns2:name></ns2:StoreImageRequest>
Run Code Online (Sandbox Code Playgroud)
有人可以帮忙吗?
lu_*_*_ko 55
我有一个类似的错误消息.我的问题出在我从XSD生成的请求和响应类中.它错过了@XMLRootElement注释.这导致操作的描述(在WSDL中)和实现的方法的描述(在Endpoint中)不匹配.将JAXBElement添加到我的端点方法解决了我的问题.
import javax.xml.bind.JAXBElement;
@PayloadRoot(namespace = "http://foo.bar/books", localPart = "GetBook")
@ResponsePayload
public JAXBElement<MyReponse> getBook(@RequestPayload JAXBElement<MyRequest> myRequest) {
...
Run Code Online (Sandbox Code Playgroud)
有关更多详细信息,请参阅此博客:spring-ws:没有端点适配器
我正在使用 WSDL 文件并按如下方式操作,然后它起作用了。
@PayloadRoot(namespace = "http://www.myservice/v1.0/query", localPart = "queryRequest")
@ResponsePayload
public JAXBElement<QueryResponse> queryAddrLocation(@RequestPayload JAXBElement<QueryRequest> queryRequest) {
System.out.println("Welcome to " + queryRequest);
return createJaxbElement(new QueryResponse(), QueryResponse.class);
}
private <T> JAXBElement<T> createJaxbElement(T object, Class<T> clazz) {
return new JAXBElement<>(new QName(clazz.getSimpleName()), clazz, object);
}
Run Code Online (Sandbox Code Playgroud)
我不确定你的完整端点看起来如何,但该类应该用注释@Endpoint或者它应该实现MessageHandler或PayloadEndpoint。
您可以使用的另一件事是方法签名。Spring-WS 的端点映射非常智能:它尝试将方法签名中的输入和输出类映射到 WSDL 文件。您确定 @ResponsePayLoad 是 String,而不是 吗StoreImageResponse?
例如,这是我的端点之一的方法签名
@PayloadRoot(
localPart = "GetHiredCandidatesRequest",
namespace = DEFAULT_NAMESPACE
)
@ResponsePayload
public GetHiredCandidatesResponse getCandidates (
@RequestPayload GetHiredCandidatesRequest getCandidate,
MessageContext messageContext) {
...
}
Run Code Online (Sandbox Code Playgroud)
在我的 WSDL 中定义如下:
<wsdl:operation name="GetHiredCandidates">
<wsdl:input message="tns:GetHiredCandidatesRequest" name="GetHiredCandidatesRequest"></wsdl:input>
<wsdl:output message="tns:GetHiredCandidatesResponse" name="GetHiredCandidatesResponse"></wsdl:output>
</wsdl:operation>
Run Code Online (Sandbox Code Playgroud)
你看到它是如何映射的吗?也许您的签名中缺少类似的内容。
| 归档时间: |
|
| 查看次数: |
20171 次 |
| 最近记录: |