The problem was asked before \"Apache AXIS Ignore/Skip additional element while parsing\" in 2012 for Apache Axis 2. Is there no workaround yet for Axis 1.4?
Pro
We always go through this hell due to bad vendors writing these services.
So, unfortunately, there's no way out using parameters for WSDL2JAVA, BUT there is a workaround, you'll to re-generate stubs at least once:
xs:sequence
with xs:all
. This allows elements to be returned in any order, and helps fix a lot of cases, as well as generated stub code which makes it easier for step while(!reader.isStartElement() && !reader.isEndElement())
reader.next();
if(reader.isStartElement())
// A start element we are not expecting indicates a trailing invalid
// property
throw new org.apache.axis2.databinding.ADBException("Unexpected subelement " + reader.getLocalName());
Have this:
while(!reader.isStartElement() && !reader.isEndElement())
reader.next();
// if(reader.isStartElement())
// A start element we are not expecting indicates a trailing invalid
// property
// The below is commented, to prevent unexpected result parameters from causing an exception
// (As well as the condition above is removed)
// throw new org.apache.axis2.databinding.ADBException("Unexpected subelement " + reader.getLocalName());
It's tested and works at least better than no solution.
Not having used Axis 1.4, but after a quick glance at the docs.
You can add a Handler to your code. You should be able even do this without having to recompile it, it that's an issue. A Handler wraps the underlying web service, it's called before the service is invoked, and after it returns. It's sorta like a Servlet Filter, but for Web Services.
The Handler has full access to the SOAP body before it gets sent forward for processing. So you can use this as an opportunity to remove elements that you don't like.
Dig a bit and you'll find you eventually get a DOM element that represents your SOAP body, so you can play primitive DOM games to add/delete nodes, etc. and set that back all within the Handler.
Your service will never see the new nodes in the edit SOAP body.
All that said, you may well be able to even do this using a Servlet Filter as well.
Try using Metro library instead of Axis, it worked for me in October 2014. Please, ignore this suggestion if you must use Axis library.
Using Axis 2 library to create a Java client that calls .NET WCF service (communicating over the Internet securely), we got errors generating Java client class from WSDL. As a workaround, we switched to a different library, Metro 2.3, and we were able to generate Java client that runs without any problems.
One of the important steps to getting a successful secure web service call from Java was configuring client and server certificates.