Compare WSDL Java API
The following listing shows how to compare two WSDL documents with Java and Membrane 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("samples/diff/original/article.wsdl");
Definitions wsdl2 = parser.parse("samples/diff/modified/article.wsdl");
WsdlDiffGenerator diffGen = new WsdlDiffGenerator(wsdl1, wsdl2);
List<Difference> lst = diffGen.compare();
for (Difference diff : lst) {
System.out.println(diff.dump());
}
}
private static void dumpDiff(Difference diff, String level) {
System.out.println(level + diff.getDescription());
for (Difference localDiff : diff.getDiffs()){
dumpDiff(localDiff, level + " ");
}
}
}
Listing 1: Simple WSDL Diff
After executing you get the output shown in listing 2 listing the differences between the two WSDL documents.
Definitions has changed:
Types has changed:
Schema http://predic8.com/wsdl/material/ArticleService/1/ has changed:
Element createResponse has changed:
ComplexType has changed:
Sequence has changed:
Element NewElementForTest added.
ComplexType GetAllType has changed:
Annotation removed.
Imported schema http://predic8.com/material/1/ has changed:
Element manufacturer added.
ComplexType ArticleType has changed:
Annotation added.
Sequence has changed:
Position of element name changed from 1 to 2.
Position of element description changed from 2 to 3.
Position of element price changed from 3 to 5.
Position of element id changed from 4 to 1.
Element availability added.
Imported schema http://predic8.com/common/1/ has changed:
ComplexType PersonType has changed:
Sequence has changed:
Element id has changed:
The type of element 'id' has changed from xsd:string to tns:IdentifierType.
Documentation has changed.
PortType ArticleServicePT has changed:
Operation create-2 removed.
Operation generate added.
Operation create has changed:
Input has changed:
Message createRequest has changed:
Part parameters has changed:
Element create has changed:
ComplexType CreateType has changed:
Sequence has changed:
Element article has changed:
ComplexType ArticleType has changed:
Annotation added.
Sequence has changed:
Position of element name changed from 1 to 2.
Position of element description changed from 2 to 3.
Position of element price changed from 3 to 5.
Position of element id changed from 4 to 1.
Element availability added.
Output has changed:
Message createResponse has changed:
Part parameters has changed:
Element createResponse has changed:
ComplexType has changed:
Sequence has changed:
Element NewElementForTest added.
Operation get has changed:
Output has changed:
Message getResponse has changed:
Part parameters has changed:
Element getResponse has changed:
ComplexType GetResponseType has changed:
Sequence has changed:
Element article has changed:
ComplexType ArticleType has changed:
Annotation added.
Sequence has changed:
Position of element name changed from 1 to 2.
Position of element description changed from 2 to 3.
Position of element price changed from 3 to 5.
Position of element id changed from 4 to 1.
Element availability added.
Operation getAll has changed:
Input has changed:
Message getAllRequest has changed:
Part parameters has changed:
Element getAll has changed:
ComplexType GetAllType has changed:
Annotation removed.
Service ArticleService has changed:
Port ArticleServicePTPort removed.
Port ArticleServicePTPort2 added.