Коллеги, помогите с простой ситуацией
Раньше веб сервисы писал на IBM Websphere Message Broker. Там валидация сообщений выполнялась прозрачно, без дополнительных настроек. Сейчас пробую написать первый сервис под Websphere Application Server 8.5 и не могу понять как сделать валидацию входящего сообщения.
Написал простой сервис. WSDL:
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
50.
51.
<?xml version="1.0" encoding="UTF-8"?><wsdl:definitions name="Test" targetNamespace="http://mycompany.com.ua/test/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://mycompany.com.ua/test/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<wsdl:types>
<xsd:schema targetNamespace="http://mycompany.com.ua/test/">
<xsd:element name="PlusOne">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="in" type="xsd:int"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="PlusOneResponse">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="out" type="xsd:int"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
</wsdl:types>
<wsdl:message name="PlusOneRequest">
<wsdl:part element="tns:PlusOne" name="parameters"/>
</wsdl:message>
<wsdl:message name="PlusOneResponse">
<wsdl:part element="tns:PlusOneResponse" name="parameters"/>
</wsdl:message>
<wsdl:portType name="Test">
<wsdl:operation name="PlusOne">
<wsdl:input message="tns:PlusOneRequest"/>
<wsdl:output message="tns:PlusOneResponse"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="TestSOAP" type="tns:Test">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" />
<wsdl:operation name="PlusOne">
<soap:operation soapAction="http://mycompany.com.ua/test/PlusOne" />
<wsdl:input>
<soap:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="Test">
<wsdl:port binding="tns:TestSOAP" name="TestSOAP">
<soap:address location="http://localhost:9080/TST.VALIDATION/Test"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
Его имплементация:
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
package ua.com.mycompany.test;
import com.sun.xml.internal.ws.developer.SchemaValidation;
@javax.jws.WebService (endpointInterface="ua.com.mycompany.test.Test",
targetNamespace="http://mycompany.com.ua/test/", serviceName="Test",
portName="TestSOAP", wsdlLocation="WEB-INF/wsdl/Test.wsdl")
public class TestSOAPImpl{
public int plusOne(int in) {
System.out.println(in);
return in+1;
}
}
Вызываю сервис из SOAPUI
Request
1.
2.
3.
4.
5.
6.
7.
8.
9.
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:test="http://mycompany.com.ua/test/">
<soapenv:Header/>
<soapenv:Body>
<test:PlusOne>
<in>test</in>
</test:PlusOne>
</soapenv:Body>
</soapenv:Envelope>
Response
1.
2.
3.
4.
5.
6.
7.
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<a:PlusOneResponse xmlns:a="http://mycompany.com.ua/test/">
<out>1</out>
</a:PlusOneResponse>
</soapenv:Body>
</soapenv:Envelope>
Вопрос: почему не возникает эксепшен? Как сделать валидацию входящего сообщения?
Аннотация
@SchemaValidation почемуто не работает Либо я ее не туда ставлю, пробовал
1.
2.
3.
@SchemaValidation
@javax.jws.WebService (endpointInterface="ua.com.mycompany.test.Test", targetNamespace="http://mycompany.com.ua/test/", serviceName="Test", portName="TestSOAP", wsdlLocation="WEB-INF/wsdl/Test.wsdl")
public class TestSOAPImpl{
и
1.
2.
3.
4.
5.
6.
@SchemaValidation
@WebService(name = "Test", targetNamespace = "http://mycompany.com.ua/test/")
@XmlSeeAlso({
ObjectFactory.class
})
public interface Test {
http://sharavara.com