I have Jaxws Soap web service. My "myMethod" method have a decimal type field.
Here is my web service interface:
@WebService(name = "myWs", targetNamespace = "someNamespace")
@Local
public interface myWsPortType {
@WebMethod
@RequestWrapper(localName = "myMethod", className = "com.example.MyMethodRequest")
public Result myMethod(@WebParam(name = "parameters", mode = Mode.IN) MyMethodParameters parameters);
}
This is parameter class
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType()
public class MyMethodParameters implements java.io.Serializable {
@FieldValidation(maxLength = 12)
@XmlElement(name = "myField", required = false)
private java.math.BigDecimal myField;
}
Everything works correctly when I pass Correct type of data in myField.
But, the problem is that when I call myMethod and pass String value (instead of Decimal) as parameter no exception is thrown and myField's value is null
Here's Soap Request example
<soapenv:Envelope>
<soapenv:Header/>
<soapenv:Body>
<iss:myMethod>
<parameters>
<myField>test</myField>
</parameters>
</iss:myMethod>
</soapenv:Body>
</soapenv:Envelope>
How can I make my ws throw exception when incorrect data type is passed?
It lookls like the XSD Schema is generated just fine, what you are missing is the SchemaValidation annotation to tell JAX-WS to validate the requests and responses with the schema.
Just add @SchemaValidation
to your service:
@WebService(name = "myWs", targetNamespace = "someNamespace")
@SchemaValidation
@Local
public interface myWsPortType { ... }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With