1 16 17 package org.apache.wsdl; 18 19 import org.apache.axis2.wsdl.WSDLVersionWrapper; 20 import org.apache.axis2.wsdl.builder.WOMBuilderFactory; 21 import org.apache.wsdl.extensions.ExtensionConstants; 22 import org.apache.wsdl.extensions.Schema; 23 import org.w3c.dom.Element ; 24 import org.w3c.dom.Node ; 25 import org.w3c.dom.NodeList ; 26 27 import javax.wsdl.Definition; 28 import javax.xml.namespace.QName ; 29 import java.io.FileInputStream ; 30 import java.io.InputStream ; 31 import java.util.Iterator ; 32 33 37 public class MessageReuseTest extends AbstractTestCase { 38 39 private WSDLDescription womDescription; 40 41 private Definition wsdl4jDefinition; 42 43 public MessageReuseTest(String arg) { 44 super(arg); 45 } 46 47 protected void setUp() throws Exception { 48 49 WSDLVersionWrapper wsdlVersionWrapper = null; 50 if (null == this.womDescription) { 51 InputStream in = new FileInputStream (getTestResourceFile("BookQuote.wsdl")); 52 wsdlVersionWrapper = WOMBuilderFactory.getBuilder(WOMBuilderFactory.WSDL11).build(in); 53 this.womDescription = wsdlVersionWrapper.getDescription(); 54 } 55 if (null == wsdl4jDefinition) { 56 this.wsdl4jDefinition = wsdlVersionWrapper.getDefinition(); 57 } 58 59 } 60 61 public void testMultipartmessageReuse() throws Exception { 62 63 WSDLInterface interface1 = this.womDescription.getInterface( 64 new QName ("http://www.Monson-Haefel.com/jwsbook/BookQuote", 65 "BookQuote")); 66 WSDLOperation operation1 = (WSDLOperation) interface1.getAllOperations() 67 .get("getBookPrice"); 68 QName element1 = operation1.getInputMessage().getElement(); 69 WSDLOperation operation2 = (WSDLOperation)interface1.getAllOperations().get("getBookPriceNonRobust"); 70 QName element2 = operation2.getInputMessage().getElement(); 71 assertEquals(element1, element2); 72 73 Iterator iterator = womDescription.getTypes().getExtensibilityElements().iterator(); 74 Schema types= null; 75 while(iterator.hasNext()){ 76 WSDLExtensibilityElement temp = (WSDLExtensibilityElement)iterator.next(); 77 if(ExtensionConstants.SCHEMA.equals(temp.getType())){ 78 types = (Schema)temp; 79 } 80 } 81 int numberOfBookQuote_getBookPrice = 0; 82 NodeList childNodes = types.getElelment().getChildNodes(); 83 for(int i=0; i< childNodes.getLength(); i++){ 84 Node item = childNodes.item(i); 85 if(item instanceof Element ){ 86 Element temp = (Element )item; 87 if("complexType".equals(temp.getNodeName()) && 88 "BookQuote_getBookPrice".equals(temp.getAttribute("name"))){ 89 numberOfBookQuote_getBookPrice++; 90 } 91 92 } 93 } 94 assertEquals(numberOfBookQuote_getBookPrice, 1); 95 96 97 } 98 } | Popular Tags |