@SchemaValidation を含む jaxws Web サービスがあります。
@SchemaValidation(handler = MySchemaValidationHandler.class)
@WebService(portName = "MyService", serviceName = "MyService", targetNamespace = "urn:com.my.urn", wsdlLocation = "/wsdls/mywsdl.wsdl", endpointInterface = "com.my.MyService")
@BindingType("http://schemas.xmlsoap.org/wsdl/soap/http")
public class MyServiceImpl
implements MyService {
@Resource
WebServiceContext wsContext;
public void myOperation(Holder<XMLGregorianCalendar> tag1, Holder<XMLGregorianCalendar> tag2, Holder<String> message) {
...
}
}
xsd には、次の例があります。
<xsd:choice>
<xsd:element name="tag1" type="xsd:dateTime" minOccurs="0"/>
<xsd:element name="tag2" type="xsd:dateTime" minOccurs="0"/>
</xsd:choice>
空のタグでリクエストを送信すると、フィールド形式に関するエラーが表示されます (日付形式の制限に適合しません)。
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:com.my.urn">
<soapenv:Header/>
<soapenv:Body>
<urn:myOperation>
<Tag1>value1</Tag1>
<Tag2></Tag2>
</urn:myOperation>
</soapenv:Body>
</soapenv:Envelope>
リクエストの説明には、必須タグと選択タグがあり、応答で正しいエラー メッセージを返さなければならないため、ハンドラでそのようなエラーをスキップすることはできません。また、変更も xsd も wsdl もできません
論理的に空のタグは、タグの欠落と同じ意味です。検証で空のタグを欠落として扱うにはどうすればよいですか、または検証の前に空のタグを削除するにはどうすればよいですか? ありがとう。