我在JAX-WS
上部署了SOAP
Weblogic 12.2
Web服务
我希望对请求进行验证,以在响应中包含自定义错误消息。
在Internet上搜索时,我发现了@SchemaValidation批注。 我工作正常,但我不想在控制台中看到异常,我想在响应中添加自定义消息。
我的服务等级类似于
import javax.annotation.Resource;
import javax.jws.WebService;
import javax.xml.ws.WebServiceContext;
import com.sun.xml.ws.developer.SchemaValidation;
@WebService(endpointInterface="...",name="MyService",serviceName="MyService")
@SchemaValidation(handler=MyServiceValidationHandler.class)
public class MyServiceImpl implements MyService
{
@Resource
private WebServiceContext webServiceContext;
@Override
public MySrviceResponse dispatch(MyServiceRequest request)
{
System.out.println("..4..");
....
}
}
还有我的经理
import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;
import com.sun.xml.ws.developer.ValidationErrorHandler;
public class MyServiceValidationHandler extends ValidationErrorHandler
{
public static final String WARNING = "SchemaValidationWarning";
public static final String ERROR = "SchemaValidationError";
public static final String FATAL_ERROR = "SchemaValidationFatalError";
@Override
public void warning(SAXParseException exception) throws SAXException
{
System.out.println("..1.." + exception);
packet.invocationProperties.put(WARNING, exception);
}
@Override
public void error(SAXParseException exception) throws SAXException
{
System.out.println("..2.." + exception);
packet.invocationProperties.put(ERROR, exception);
}
@Override
public void fatalError(SAXParseException exception) throws SAXException
{
System.out.println("..3.." + exception);
packet.invocationProperties.put(FATAL_ERROR, exception);
}
}
在发送“错误的”肥皂消息后,我可以在控制台中看到
..2..org.xml.sax.SAXParseException; cvc-datatype-valid.1.2.1: '?' is not a valid value for 'integer'.
..2..org.xml.sax.SAXParseException; cvc-type.3.1.3: The value '?' of element 'testNbr' is not valid.
但是端点的代码没有执行。
我想念什么?