SOAPメッセージのスキーマ検証に使用しているカスタムSOAPハンドラーがあります。Webサービスで動作します。他の人にも使用できるようにしたいと思います。検証自体を行うコードは非常に一般的です。実際に入力されるのは、検証に使用するスキーマの名前だけです。Springを使用してさまざまなサービスのSOAPハンドラーのさまざまなインスタンスを構成する方法/方法に頭を悩ませています。
Webサービスは次のように宣言されています。
@WebService(name = "MyService", ...)
@SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.BARE)
@HandlerChain(file="handler-chain.xml")
public interface MyService
{
....
}
ファイルは次のhandler-chain.xml
ようになります。
<?xml version="1.0" encoding="UTF-8"?>
<handler-chains xmlns="http://java.sun.com/xml/ns/javaee">
<handler-chain>
<handler>
<handler-name>com.ws.MyCustomSoapHandler</handler-name>
<handler-class>com.ws.MyCustomSoapHandler</handler-class>
</handler>
</handler-chain>
</handler-chains>
カスタムSOAPハンドラー内には、次のものがあります。
public class MyCustomSoapHandler implements SOAPHandler<SOAPMessageContext>
{
//assume getter/setter for this.
private String schemaLocation = "schema/validation/service1.xsd";
@Override
public boolean handleMessage(SOAPMessageContext context)
{
...
//This is the only place where the schema needs to vary
schema = schemaFactory.newSchema(this.getClass().getClassLoader().getResource(schemaLocation));
Springを使用してに基づいて複数のBeanを作成しMyCustomSoapHandler
、それらに異なる値を与えることができることは知っていますschemaLocation
が、それらのBeanをアプリケーションの正しいWebサービスに接続するにはどうすればよいですか?それは通り抜けるhandler-chain.xml
でしょうか?それともプログラムで行う必要がありますか?