30

Spring-WS with JMS の例に苦労しています。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?

私の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>

私のエンドポイントコードは

@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());
}

私のスキーマは

<?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>

私のクライアントリクエストは

<ns2:StoreImageRequest xmlns:ns2="http://www.springframework.org/spring-ws/samples/mtom"><ns2:name>spring-ws-logo.png</ns2:name></ns2:StoreImageRequest>

誰かが助けることができますか?

4

9 に答える 9

2

同様のエラーがありました。問題は、XSD/WSDL から生成されたリクエストとレスポンスが @XMLRootElement アノテーションを欠いていることです。エンドポイントに JAXBElement を追加することで問題が解決しました。

private static final String NAMESPACE_URI = "<targetNamespace>";

@Autowired
Service   service;

@PayloadRoot ( namespace = Endpoint.NAMESPACE_URI, localPart = "name" )
@ResponsePayload
public JAXBElement < Response > Create ( @RequestPayload JAXBElement < Request> request ) throws Exception
{
ObjectFactory factory = new ObjectFactory ( );
Response response = new Response ( );
Request req = request.getValue ( );

response  = this.service.call( req);

return factory.createResponse ( response );
}
于 2019-11-27T13:24:04.430 に答える
1

完全なエンドポイントがどのように見えるかはわかりませんが、クラスに注釈を付けるか、 or@Endpointを実装する必要があります。MessageHandlerPayloadEndpoint

あなたが遊ぶことができる他のものは、メソッドの署名です。Spring-WS のエンドポイント マッピングは非常にインテリジェントです。メソッド シグネチャから入力クラスと出力クラスを WSDL ファイルにマップしようとします。String は @ResponsePayLoad であり、 ではありませんStoreImageResponseか?

たとえば、これは私のエンドポイントの 1 つのメソッド シグネチャです。

@PayloadRoot(
    localPart = "GetHiredCandidatesRequest", 
    namespace = DEFAULT_NAMESPACE
)
@ResponsePayload
public GetHiredCandidatesResponse getCandidates (
    @RequestPayload GetHiredCandidatesRequest getCandidate,
    MessageContext messageContext) {
    ...
}

これは私の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>

どのようにマッピングされているか分かりますか?おそらく、署名にそのようなものが欠けています。

于 2013-01-23T09:55:23.667 に答える
0

まず、ガイドラインに従って、エンドポイントクラスが存在する必要があります。

@Endpoint
public class EmpEndpoint {

    @Autowired
    private EmpService empService;

    //This is like @RequestMapping of Spring MVC    
    @PayloadRoot(localPart = "EmpServiceRequest", namespace = "http://www.example.org/")
    @ResponsePayload
    public EmpServiceResponse getemployeeDetails(@RequestPayload EmpServiceRequest request) {
        EmpServiceResponse response = new ObjectFactory().createEmpServiceResponse();
        List<Employee> l = empService.getemployeeDetails(request.getName());
        response.setName(l.get(0).getName());
        response.setEmail(l.get(0).getEmail());
        return response;
    }
}

PayloadRootとその他のアノテーション (リクエストとレスポンス)を持つ1 つのサービスとその 実装クラス

これを spring-servlet.xml に配置します

  <!-- To detect @Endpoint -->
<sws:annotation-driven/>

<!-- To detect @Service, @Component etc -->
<context:component-scan base-package="your package for eg com.employee" />
于 2013-02-14T10:12:47.473 に答える