How to canonicalize WSDL files in Java?

北战南征 提交于 2019-12-20 03:33:14

问题


I need to find differences in two WSDL files. I started by pretty-printing them like here, but I see there are same things (e.g. complexTypes) in the two files defined (for whatever stupid reason) in a different order. I want to canonicalize the files further, so I can later use things like standard diff to find the differences.

No idea if there's a defined canonical form for WSDL, I know there's Canonical XML, but I need to go a bit further and sort all the things whose order doesn't matter.


回答1:


You can download a Java program from http://www.jclark.com/xml/ which converts XML to Canonical XML. This should be applicable to WSDL files too.




回答2:


I ran through the tree recursively and sorted all children of nodes matching schema|wsdl:binding|wsdl:portType|wsdl:types|wsdl:definitions. I used this answer for pretty-printing the output. For whatever reason format.setLineWidth(65); doesn't work, so I had to join the lines using replaceAll("\\s*\n\\s*(?=[^\\s<])", " "). It seems to work fine.



来源:https://stackoverflow.com/questions/6446904/how-to-canonicalize-wsdl-files-in-java

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!