简体   繁体   中英

Decouple WSDL from client's app

I have a java web service client consuming web services. The client is generated using WSDL2Java tool. All works fine until the web service provider changes one of the schema objects by adding a non-required field. When the web service is called, the response is supposed to return an array of these schema objects and since the returned objects have an extra field - everything breaks. From what I understand there is a way to allow for such changes without breaking the client application.
Could you point me in the right direction on how to solve this? Any suggestion is appreciated. Thank you, Nadia

Try try using different binding options for your client. If I am not wrong using JAXBRI (od JiBX) should solve the issue. try WSDL2Java -d jaxbri The default is adb more info is in here

The web service is not conforming to the WSDL? Maybe you can edirt the WSDL and add the non-required field

Or is the WSDL changed? If the WSDL was changed you need to re-generate your code by WSDL2Java tool.

This problem is generally hard to solve, which is why client-facing XML schemas shouldn't change very often. You can try disabling schema validation, but if the schema changes too much, your client aplication will still blow up.

The recommended enterprisey way to do this (in the jargon: 'loose coupling') is to have a separate layer of domain objects and map between the generated Java classes and your domain objects. You just update the mappings when the schema changes, which shouldn't penetrate too far into the layers of your application. But you still need to recompile the application every time the schema changes.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM