XML/WSDL Comparison tool

前端 未结 3 1996
情歌与酒
情歌与酒 2021-02-02 14:06

There is no surprise for those who work with web-services a lot that they get updated from time to time. And you always need to track changes of these updates.

In my par

相关标签:
3条回答
  • 2021-02-02 14:17

    The raised question is actually very common for any system that is built on top of SOA. You typically have a few consumers for a WSDL, or a few services that use the same WSDL, and now that WSDL needs to be updated.

    • Do we have to update all clients and server at the same time (that is expensive!)
    • If we do a staged deployment, what operations in the WSDL are affected (broken) if the updated client calls a non-updated service?
    • And other way around, can some clients be updated later?
    • How the XML structure changes? Can those changes be tolerated by some parsers (for example, some parsers do not break if they find a new element in the end of the sequence, but do break if it is found in the middle).

    And no, neither diff for WSDL nor diff for generated XML can reliably help.

    In addition to schema changes, WSDL can change the way the payload is structured (body/header), encoding/qualification, SOAP Action, binding properties - any of which can cause the loss of interoperability.

    To make things even more tricky, some types of changes made in input break the "updated to old" scenario, while in the output they should be considered non-breaking. For instance, a new optional element in request would break the old service if passed, but the same element in response will not be generated by the old service (because it doesn't know about it), and the element lack will be tolerated by the updated client because the element is optional.

    My team faces these tasks roughty once a week. Up until recently we did a manual diff of the WSDL/schema files and tried to figure out the impact. Sometimes it is obvious, but sometimes our approach led to mistakes. We needed a better way.

    Membrane SOA was some help. Unfortunately, in some occasions it fails to detect the changes in schema, erroneously reporting an operation as not impacted, while in fact it is broken. It is also not immediately clear from the output what scenario ("old to updated" or "updated to old") is reported.

    So after a couple of years of pain I had to write my own code that answers the questions above in a way I can directly provide to our BAs/PMs as supporting documentation for the impact assessment.

    See here: https://wsdldiff.mockmotor.com/

    1. Upload your WSDL and schemas:

    Upload WSDLs

    1. The service will give you the impact summary: are the changes breaking, and what deployment scenario will be affected:

    Upload WSDLs

    1. Each operation is marked as having a breaking or non-breaking change in both ports and bindings:

    Upload WSDLs

    1. You can take a look at the details of a breaking change (i.e. what schema/wsdl change causes it). Here for example a mandatory element was added into the middle of a sequence:

    Upload WSDLs

    That is not to say that one should blindly rely on tools such as this one, but it saves a lot of time when doing the impact assessment.

    0 讨论(0)
  • 2021-02-02 14:27

    This may only be a partial solution but you could analyse the old and new WSDL in SOAPui.

    You should be able to tell from the generated methods and example requests what has changed whether it be types or methods.

    hope that is some help

    0 讨论(0)
  • 2021-02-02 14:41

    http://membrane-soa.org has a Java API for comparing WSDL in their SOA Model.

    package sample.wsdl;
    
    import java.util.List;
    import com.predic8.wsdl.*;
    import com.predic8.wsdl.diff.WsdlDiffGenerator;
    import com.predic8.soamodel.Difference;
    
    public class CompareWSDL {
    
      public static void main(String[] args) {
        compare();
      }
    
      private static void compare(){
        WSDLParser parser = new WSDLParser();
    
        Definitions wsdl1 = parser.parse("resources/diff/1/article.wsdl");
    
        Definitions wsdl2 = parser.parse("resources/diff/2/article.wsdl");
    
        WsdlDiffGenerator diffGen = new WsdlDiffGenerator(wsdl1, wsdl2);
        List<Difference> lst = diffGen.compare();
        for (Difference diff : lst) {
          dumpDiff(diff, "");
        }
      }
    
      private static void dumpDiff(Difference diff, String level) {
        System.out.println(level + diff.getDescription());
        for (Difference localDiff : diff.getDiffs()){
          dumpDiff(localDiff, level + "  ");
        }
      }
    }
    

    After executing you get the output shown in listing 2. It is a List of differences between the two WSDL documents.

    Port ArticleServicePTPort removed.
    Port ArticleServicePTPort2 added.
    Operation create removed.
    Operation create2 added.
    Schema http://predic8.com/wsdl/material/ArticleService/1/ has changed:
      Element createResponse has changed:
        ComplexType  has changed:
          Sequence has changed:
            Element NewElementForTest added.
    

    For an example of the output from the tool, http://www.service-repository.com/ offers an online WSDL Comparator tool that returns a report of the differences between two WSDL. The report is not a simple XML diff.

    0 讨论(0)
提交回复
热议问题