How to remove unwanted SOAP header elements in JAX-WS
In our current webservice project with JAX-WS in Â JDeveloper Â 184.108.40.206 we have a challenge with calling a webservice. This webservice from a remote organisation does not accept specific SOAP header elements our client application creates – although we followed the contract of the WSDL correctly. Of course this webservice must follow it as well as we have to, but for now we donâ€™t have a choice but to make a workaround. Â How can we remove unwanted elements from a SOAP header? In this blog I will show you how you can do that using a JAX-WS SOAPHandler that inspects the SOAP header and removes specific addressing elements.
In the WSDL file the element Â <wsaw:UsingAddressing wsdl:required=”true”/> is present. Following the contract of the WSDL – this means that the SOAP header must contain addressing elements. The runtime libraries of JAX-WS take care of Â this and creates in the SOAP header the elements (see picture):
This remote webservice cannot accept <wsa:To>, <wsa:ReplyTo>, <FaultTo> elements (validation of incoming SOAP requests will fail), but <wsa:MessageId> and <wsa:Action> are mandatory. We cannot simply removeÂ <wsaw:UsingAddressing wsdl:required=”true”/> from the WSDL and regenerate our client proxy in JDeveloper, because then we miss also the mandatory MessageId and Action elements.
We can use a JAX-WS SOAPHandler to inspectÂ the SOAP header and remove certain elements. Â In the handleMessage() method we can get the SOAP header , retrieve the direct child elements of this header, inspect them and delete the unwanted ones:
Now the elements are removed from the SOAP header and we can call the webservice without validation errors:
Download this SoapHandler: Â SOAPHandler
- Java Callout in Mediator to Automatically Deal With Empty Elements
- First Steps with Apache WSIF – Calling out to WSIF-alized SOAP WebServices and Java Classes
- Unit testing with XFire â€“ How to test your SOAP server with a WSDL file
- Publish a WebService from a POJA (plain old Java application) – that is: out of the container using EndPoint class
- Publishing Java based WebServices using JAX-WS in JDeveloper 11g
This entry was posted by Frank Houweling on May 16, 2011 at 1:08 am, and is filed under General, J(2)EE/Java, Java, Java, JEE, OAS and WebLogic Server, Oracle, SOA & Oracle Fusion Middleware, Software Development. Follow any responses to this post through RSS 2.0.You can skip to the end and leave a response. Pinging is currently not allowed.
- JDeveloper code templates
- Running Oracle Designer Generation from Ant and Hudson
- OTN Yathra 2013 – Spreading the story of Oracle across India – (Half time)
- Dear Java/JEE developer – why should you care about ADF?
- ADF interaction with business service – an ongoing discussion
- OOW 2012: The yearly AMIS Review from Oracle Open World and JavaOne – slides available
- Kom kennismaken met AMIS en doe mee met uitdagende projecten
- JavaOne 2012: The Big Stories
- JavaOne 2012: Thinking Through Java Enterprise Performance (BOF 4712)
- Uitnodiging: Kom kennismaken met AMIS