File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Web Services and the fly likes JAX-WS: when input soap validation fails Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "JAX-WS: when input soap validation fails" Watch "JAX-WS: when input soap validation fails" New topic
Author

JAX-WS: when input soap validation fails

jakob lind
Greenhorn

Joined: Jan 28, 2010
Posts: 1
I have created a web service with JAX-WS. When the input SOAP message is not well formed or can not be validated, a soap fault is returned automatically to the caller. I dont want the caller to receive this standard SOAP message but i want to create an own custom SOAP fault.

So if the call looks like this (note Envelope1, its not valid):
<soapenv:Envelope1 xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header/>
<soapenv:Body>
<ns3:Request>
hello
</ns3:Request>
</soapenv:Body>
</soapenv:Envelope>

a default return message is something like this:
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Body>
<S:Fault xmlns:ns4="http://www.w3.org/2003/05/soap-envelope">
<faultcode>S:Client</faultcode>
<faultstring>Couldn't create SOAP message due to exception: unexpected XML tag. expected: {http://schemas.xmlsoap.org/soap/envelope/}Envelope but found: {http://schemas.xmlsoap.org/soap/envelope/}Envelope1</faultstring>
</S:Fault>
</S:Body>
</S:Envelope>

I want the return message to be something like this:
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Body>
<S:Fault xmlns:ns4="http://www.w3.org/2003/05/soap-envelope">
<faultcode>S:Client</faultcode>
<faultstring>My own custom SOAP message!</faultstring>
</S:Fault>
</S:Body>
</S:Envelope>

I have tried to get this to work the whole day, but i cant figure out how to do it. So if someone could help me I would be really glad!
somia razzaq
Ranch Hand

Joined: Jan 26, 2010
Posts: 44
jakob lind wrote:I have created a web service with JAX-WS. When the input SOAP message is not well formed or can not be validated, a soap fault is returned automatically to the caller. I dont want the caller to receive this standard SOAP message but i want to create an own custom SOAP fault.

So if the call looks like this (note Envelope1, its not valid):
<soapenv:Envelope1 xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header/>
<soapenv:Body>
<ns3:Request>
hello
</ns3:Request>
</soapenv:Body>
</soapenv:Envelope>

a default return message is something like this:
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Body>
<S:Fault xmlns:ns4="http://www.w3.org/2003/05/soap-envelope">
<faultcode>S:Client</faultcode>
<faultstring>Couldn't create SOAP message due to exception: unexpected XML tag. expected: {http://schemas.xmlsoap.org/soap/envelope/}Envelope but found: {http://schemas.xmlsoap.org/soap/envelope/}Envelope1</faultstring>
</S:Fault>
</S:Body>
</S:Envelope>

I want the return message to be something like this:
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Body>
<S:Fault xmlns:ns4="http://www.w3.org/2003/05/soap-envelope">
<faultcode>S:Client</faultcode>
<faultstring>My own custom SOAP message!</faultstring>
</S:Fault>
</S:Body>
</S:Envelope>

I have tried to get this to work the whole day, but i cant figure out how to do it. So if someone could help me I would be really glad!



Hi
use this link "http://docs.sun.com/app/docs/doc/819-3669/bnbhr?a=view". May it help you.

Best Regards
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JAX-WS: when input soap validation fails
 
Similar Threads
Problem in Throwing Exception
What's Wrong with this simple WSDL
Why Getting Fault Code in SOAP Response Message
Error in Soap Response while implementing ws-security using Metro
Cannot find dispatch method for {http://www.ivan.com/additionservicetypes}addValuesRequest