<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title>Answers to: Can I avoid 'Unexpected subelement' errors when the service-provider introduces new properties?</title><link>https://answers.axonivy.com/questions/3294/can-i-avoid-unexpected-subelement-errors-when-the-service-provider-introduces-new-properties</link><description>&lt;p&gt;I have a soap client call that invokes a remote service. Unfortunately the service provider is updating the service definition frequently and introduces new properties or changes the property order. Therefore I can no longer call it, the mapping of the response fails with:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;ADBException: Unexpected subelement theID
Exception: org.apache.axis2.databinding.ADBException: Unexpected subelement theID
AxisFault: org.apache.axis2.databinding.ADBException: Unexpected subelement theID
BpmError: ivy:error:webservice:exception
RequestException: ivy:error:webservice:exception
Problem while processing request 'http://127.0.0.1:8081/ivy/pro/designer/finElcaUser/163B11CD193F9801/start.ivp'
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I've also tried the new Webservice stack of Axon.ivy 7.1 based on CXF. But it fails with a similar issue:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;UnmarshalException: unexpected element (uri:"", local:"theID"). Expected elements are &amp;lt;{}firstname&amp;gt;,&amp;lt;{}lastname&amp;gt;
    SAXParseException2: unexpected element (uri:"", local:"theID"). Expected elements are &amp;lt;{}firstname&amp;gt;,&amp;lt;{}lastname&amp;gt;
    javax.xml.bind.UnmarshalException
 - with linked exception:
[com.sun.istack.internal.SAXParseException2; lineNumber: 1; columnNumber: 218; unexpected element (uri:"", local:"theID"). Expected elements are &amp;lt;{}firstname&amp;gt;,&amp;lt;{}lastname&amp;gt;]
    Fault: Unmarshalling Error: unexpected element (uri:"", local:"theID"). Expected elements are &amp;lt;{}firstname&amp;gt;,&amp;lt;{}lastname&amp;gt; 
    Web Service Element: Call to &lt;a href="http://localhost:8082/ivy/ws/designer/elcaMock/163B11ABE3388EE4"&gt;http://localhost:8082/ivy/ws/designer/elcaMock/163B11ABE3388EE4&lt;/a&gt; (Operation[name=getPersons,port=DocServicePort,parameters=[]]) failed!
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;Is there any way to read the response in a compliant way and ignore new properties introduced by the provider?&lt;/strong&gt;
the roundtrip is huge if I have to re-generate the client stack every-time  when the provider makes changes.&lt;/p&gt;</description><atom:link href="https://answers.axonivy.com/questions/3294/can-i-avoid-unexpected-subelement-errors-when-the-service-provider-introduces-new-properties" rel="self"></atom:link><language>en</language><lastBuildDate>Wed, 30 May 2018 09:38:27 -0400</lastBuildDate><item><title>Answer by Reguel Wermelinger</title><link>https://answers.axonivy.com/questions/3294/can-i-avoid-unexpected-subelement-errors-when-the-service-provider-introduces-new-properties/3295</link><description>&lt;p&gt;&lt;strong&gt;CXF can easily ignore that exception&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;You can disable the schema validation as described here: &lt;a href="http://mail-archives.apache.org/mod_mbox/cxf-users/201001.mbox/%3C201001291547.56047.dkulp@apache.org%3E"&gt;http://mail-archives.apache.org/mod_mbox/cxf-users/201001.mbox/%3C201001291547.56047.dkulp@apache.org%3E&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;Within Axon.ivy 7.1 you just have to pack this property into a custom feature:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;package com.axonivy;

import ch.ivyteam.ivy.webservice.exec.feature.WebServiceClientFeature;
import ch.ivyteam.ivy.webservice.exec.feature.WebServiceClientFeatureContext;

public class CompliantSchemaValidation implements WebServiceClientFeature {

    @Override
    public void initialize(WebServiceClientFeatureContext context) {
        context.getBindingProvider().getRequestContext()
            .put("set-jaxb-validation-event-handler",  "false");
    }

}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And then use in in your client configuration.... Then these unexpected subElement exceptions are gone.
&lt;img alt="alt text" src="https://answers.axonivy.com/upfiles/cxfDisabledSchemaValidationFeature.png"&gt;&lt;/p&gt;
&lt;p&gt;Another solution could be to set a specific event handler and only ignore these unexepted SubElement exceptions. But I didn't test it: &lt;a href="http://whileonefork.blogspot.com/2010/11/cxf-backwards-compatibility-adding.html"&gt;http://whileonefork.blogspot.com/2010/11/cxf-backwards-compatibility-adding.html&lt;/a&gt;&lt;/p&gt;
&lt;hr&gt;
&lt;p&gt;&lt;strong&gt;AXIS2 needs dirty handwork&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;If you can not migrate to Axon.ivy 7.1 or newer you can also patch Axis2 client to ignore new properties.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;add AXiS2 dependencies to your project classpath&lt;/li&gt;
&lt;li&gt;introduce a new source folder (e.g. &lt;code&gt;src_axis&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;add the contents of your webservice client jar (&lt;code&gt;lib_ws/client/xyz.JAR&lt;/code&gt;) to your new source folder&lt;/li&gt;
&lt;li&gt;remove the original client jar from the classpath&lt;/li&gt;
&lt;li&gt;patch the factory classes of your beans. E.g. uncomment all occurences of AdbException with &lt;code&gt;Unexpected subelement&lt;/code&gt; as message.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;img alt="alt text" src="https://answers.axonivy.com/upfiles/axis2_manualFactoryPatch_oMspoLW.png"&gt;&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Reguel Wermelinger</dc:creator><pubDate>Wed, 30 May 2018 09:38:27 -0400</pubDate><guid>https://answers.axonivy.com/questions/3294/can-i-avoid-unexpected-subelement-errors-when-the-service-provider-introduces-new-properties/3295</guid></item></channel></rss>