You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by ch...@apache.org on 2005/05/30 05:13:41 UTC
svn commit: r179006 - in /webservices/axis/trunk/java/modules/wsdl:
src/org/apache/axis/wsdl/builder/wsdl4j/ src/org/apache/wsdl/
src/org/apache/wsdl/extensions/ src/org/apache/wsdl/extensions/impl/
src/org/apache/wsdl/impl/ test/org/apache/wsdl/
Author: chathura
Date: Sun May 29 20:13:40 2005
New Revision: 179006
URL: http://svn.apache.org/viewcvs?rev=179006&view=rev
Log:
Added the multipart support. Note: The WSDL 2.0 does not identify a notion of Multipart. It has a messagereference which will point to a QName in the schema types section of the WSDL. If the parsing WSDL 1.1 has a multipart how it will be handled is in the following manner. The type or the element of the individual parts will be extracted and a new complex type will be formed containing those elements as the complexcontent. If a given message is reused in a operation then the same Qname will be used which refer to the same complextype. THe name of the New Complextype will be that of the WSDl 1.1 Message.
Modified:
webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis/wsdl/builder/wsdl4j/WSDLPump.java
webservices/axis/trunk/java/modules/wsdl/src/org/apache/wsdl/WSDLConstants.java
webservices/axis/trunk/java/modules/wsdl/src/org/apache/wsdl/WSDLInterface.java
webservices/axis/trunk/java/modules/wsdl/src/org/apache/wsdl/WSDLOperation.java
webservices/axis/trunk/java/modules/wsdl/src/org/apache/wsdl/extensions/ExtensionConstants.java
webservices/axis/trunk/java/modules/wsdl/src/org/apache/wsdl/extensions/impl/ExtensionFactoryImpl.java
webservices/axis/trunk/java/modules/wsdl/src/org/apache/wsdl/impl/WSDLInterfaceImpl.java
webservices/axis/trunk/java/modules/wsdl/src/org/apache/wsdl/impl/WSDLOperationImpl.java
webservices/axis/trunk/java/modules/wsdl/test/org/apache/wsdl/InterfaceTest.java
webservices/axis/trunk/java/modules/wsdl/test/org/apache/wsdl/WOMBuilderTest.java
Modified: webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis/wsdl/builder/wsdl4j/WSDLPump.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis/wsdl/builder/wsdl4j/WSDLPump.java?rev=179006&r1=179005&r2=179006&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis/wsdl/builder/wsdl4j/WSDLPump.java (original)
+++ webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis/wsdl/builder/wsdl4j/WSDLPump.java Sun May 29 20:13:40 2005
@@ -16,6 +16,7 @@
package org.apache.axis.wsdl.builder.wsdl4j;
import java.util.Iterator;
+import java.util.LinkedList;
import java.util.List;
import java.util.Map;
@@ -25,6 +26,7 @@
import javax.wsdl.BindingOutput;
import javax.wsdl.Definition;
import javax.wsdl.Input;
+import javax.wsdl.Message;
import javax.wsdl.Operation;
import javax.wsdl.Output;
import javax.wsdl.Part;
@@ -34,10 +36,12 @@
import javax.wsdl.Types;
import javax.wsdl.extensions.ExtensibilityElement;
import javax.wsdl.extensions.UnknownExtensibilityElement;
+import javax.wsdl.extensions.schema.Schema;
import javax.wsdl.extensions.soap.SOAPAddress;
import javax.xml.namespace.QName;
import org.apache.axis.wsdl.builder.WSDLComponentFactory;
+import org.apache.crimson.tree.XmlDocument;
import org.apache.wsdl.Component;
import org.apache.wsdl.MessageReference;
import org.apache.wsdl.WSDLBinding;
@@ -47,13 +51,17 @@
import org.apache.wsdl.WSDLDescription;
import org.apache.wsdl.WSDLEndpoint;
import org.apache.wsdl.WSDLExtensibilityAttribute;
+import org.apache.wsdl.WSDLExtensibilityElement;
import org.apache.wsdl.WSDLInterface;
import org.apache.wsdl.WSDLOperation;
import org.apache.wsdl.WSDLService;
import org.apache.wsdl.WSDLTypes;
import org.apache.wsdl.extensions.DefaultExtensibilityElement;
+import org.apache.wsdl.extensions.ExtensionConstants;
import org.apache.wsdl.extensions.ExtensionFactory;
import org.apache.wsdl.impl.WSDLProcessingException;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
/**
* @author chathura@opensource.lk
@@ -67,6 +75,9 @@
private Definition wsdl4jParsedDefinition;
private WSDLComponentFactory wsdlComponenetFactory;
+
+
+ private List resolvedMultipartMessageList = new LinkedList();
public WSDLPump(WSDLDescription womDefinition,
Definition wsdl4jParsedDefinition) {
@@ -116,9 +127,12 @@
Types wsdl4jTypes = wsdl4JDefinition.getTypes();
if (null != wsdl4jTypes) {
WSDLTypes wsdlTypes = this.wsdlComponenetFactory.createTypes();
- Iterator wsdl4jelmentsIterator = wsdl4jTypes
- .getExtensibilityElements().iterator();
- this.copyExtensibleElements(wsdlTypes.getExtensibilityElements(),
+
+// Schema schema = (Schema)wsdlTypes.getExtensibilityElements();
+// Element element = schema.getElement();
+
+
+ this.copyExtensibleElements(wsdl4jTypes.getExtensibilityElements(),
wsdlTypes);
this.womDefinition.setTypes(wsdlTypes);
@@ -237,6 +251,9 @@
this.populateBindingOperation(wsdlBindingOperation,
wsdl4jBindingOperation,
wsdl4JBinding.getQName().getNamespaceURI());
+ wsdlBindingOperation.setOperation(
+ wsdlInterface.getOperation(wsdl4jBindingOperation.getOperation().getName())
+ );
this.copyExtensibleElements(
wsdl4jBindingOperation.getExtensibilityElements(),
wsdlBindingOperation);
@@ -267,7 +284,7 @@
/////////////////////////////////////////////////////////////////////////////
//////////////////////////// Internal Component Copying ///////////////////
- //TODO Faults ??
+ //TODO Faults
public void populateOperations(WSDLOperation wsdlOperation,
Operation wsdl4jOperation, String nameSpaceOfTheOperation) {
//Copy Name Attrebute
@@ -281,51 +298,130 @@
MessageReference wsdlInputMessage = this.wsdlComponenetFactory
.createMessageReference();
wsdlInputMessage.setDirection(WSDLConstants.WSDL_MESSAGE_DIRECTION_IN);
-
- //Get all the in parts and create a new Element out of it and add it to
- // the Types.
- //TODO
-
- if (wsdl4jInputMessage.getMessage().getParts().size() > 1)
- throw new WSDLProcessingException("Multipart Parsing not Supported");
- Iterator inputIterator = wsdl4jInputMessage.getMessage().getParts()
- .values().iterator();
- if (inputIterator.hasNext()) {
- Part part = ((Part) inputIterator.next());
- QName element;
- if (null != (element = part.getTypeName())) {
- wsdlInputMessage.setElement(element);
- } else {
- wsdlInputMessage.setElement(part.getElementName());
- }
- }
+ wsdlInputMessage.setMessageLabel(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
+ this.populateMessageReference(wsdlInputMessage, wsdl4jInputMessage.getMessage());
+ this.copyExtensibleElements(
+ (wsdl4jInputMessage.getMessage()).getExtensibilityElements(),
+ wsdlInputMessage
+ );
wsdlOperation.setInputMessage(wsdlInputMessage);
+
//Create an output message and add
Output wsdl4jOutputMessage = wsdl4jOperation.getOutput();
MessageReference wsdlOutputMessage =
this.wsdlComponenetFactory.createMessageReference();
wsdlOutputMessage.setDirection(WSDLConstants.WSDL_MESSAGE_DIRECTION_OUT);
+ wsdlOutputMessage.setMessageLabel(WSDLConstants.MESSAGE_LABEL_OUT_VALUE);
- if (wsdl4jOutputMessage.getMessage().getParts().size() > 1)
- throw new WSDLProcessingException("Multipart Parsing not Supported");
- Iterator outputIterator =
- wsdl4jOutputMessage.getMessage().getParts().values().iterator();
- if (outputIterator.hasNext()) {
- Part outPart = ((Part) outputIterator.next());
- QName typeName;
- if (null != (typeName = outPart.getTypeName())) {
- wsdlOutputMessage.setElement(typeName);
- } else {
- wsdlOutputMessage.setElement(outPart.getElementName());
- }
- }
+ this.populateMessageReference(wsdlOutputMessage, wsdl4jOutputMessage.getMessage());
+ this.copyExtensibleElements(
+ (wsdl4jOutputMessage.getMessage()).getExtensibilityElements(),
+ wsdlOutputMessage
+ );
wsdlOperation.setOutputMessage(wsdlOutputMessage);
+
+
//Set the MEP
wsdlOperation.setMessageExchangePattern(WSDL11MEPFinder
.getMEP(wsdl4jOperation));
}
+ private void populateMessageReference(MessageReference womMessage, Message wsdl4jMessage){
+ if (wsdl4jMessage.getParts().size() > 1){
+ // Multipart Message
+
+ // Check whether this message parts have been made to a type
+ Iterator multipartListIterator = this.resolvedMultipartMessageList.iterator();
+ boolean multipartAlreadyResolved = false;
+ while(multipartListIterator.hasNext() && !multipartAlreadyResolved){
+ QName temp = (QName)multipartListIterator.next();
+ multipartAlreadyResolved = wsdl4jMessage.getQName().equals(temp);
+ }
+ if(multipartAlreadyResolved){
+ //This message with multiple parts has resolved and a new type has been
+ //made out of it earlier.
+ //FIXME Actual element name should it be xs:, if yes change the qname added to the
+ //resolvedmessage list too.
+ womMessage.setElement(wsdl4jMessage.getQName());
+ }else{
+ //Get the list of multiparts of the message and create a new Element
+ //out of it and add it to the schema.
+ Map parts = wsdl4jMessage.getParts();
+ Element element = null;
+ WSDLTypes types = womDefinition.getTypes();
+ if(null == types){
+ XmlDocument newDoc = new XmlDocument();
+
+ Element schemaElement = newDoc.createElement("schema");//http://www.w3.org/2001/XMLSchema
+ types =wsdlComponenetFactory.createTypes();
+ ExtensionFactory extensionFactory = wsdlComponenetFactory.createExtensionFactory();
+ org.apache.wsdl.extensions.Schema typesElement = (org.apache.wsdl.extensions.Schema)extensionFactory.getExtensionElement(ExtensionConstants.SCHEMA);
+ typesElement.setElelment(schemaElement);
+ types.addExtensibilityElement(typesElement);
+ this.womDefinition.setTypes(types);
+ }
+ Iterator schemaEIIterator = types.getExtensibilityElements().iterator();
+ while(schemaEIIterator.hasNext()){
+ WSDLExtensibilityElement temp = (WSDLExtensibilityElement)schemaEIIterator.next();
+ if(ExtensionConstants.SCHEMA.equals(temp.getType())){
+ element = ((org.apache.wsdl.extensions.Schema)temp).getElelment();
+ break;
+ }
+ }
+
+ Document doc = element.getOwnerDocument();
+ String name = wsdl4jMessage.getQName().getLocalPart();
+ Element newElement = doc.createElement("complexType");
+ newElement.setAttribute("name", name);
+
+ Element cmplxContent = doc.createElement("complexContent");
+ Element child;
+ Iterator iterator = parts.keySet().iterator();
+ while(iterator.hasNext()){
+ Part part = (Part)parts.get(iterator.next());
+ QName elementName = part.getElementName();
+ if(null == elementName){
+ elementName = part.getTypeName();
+ }
+
+
+ child = doc.createElement("element");
+ child.setAttribute("name", "var"+elementName.getLocalPart());
+ child.setAttribute("type", elementName.getNamespaceURI()+":"+elementName.getLocalPart());
+ cmplxContent.appendChild(child);
+ }
+
+
+ newElement.appendChild(cmplxContent);
+
+ element.appendChild(newElement);
+ //Now since a new type is created augmenting the parts add the QName
+ //of the newly created type as the messageReference's name.
+ womMessage.setElement(wsdl4jMessage.getQName());
+ //Add this message as a resolved message, so that incase some other
+ //operation refer to the same message the if above will take a hit
+ //and the cashed QName can be used instead of crating another type
+ //for the same message.
+
+ this.resolvedMultipartMessageList.add(wsdl4jMessage.getQName());
+
+ }
+ }else{
+ //Only one part so copy the QName of the referenced type.
+ Iterator outputIterator =
+ wsdl4jMessage.getParts().values().iterator();
+ if (outputIterator.hasNext()) {
+ Part outPart = ((Part) outputIterator.next());
+ QName typeName;
+ if (null != (typeName = outPart.getTypeName())) {
+ womMessage.setElement(typeName);
+ } else {
+ womMessage.setElement(outPart.getElementName());
+ }
+ }
+ }
+ }
private void populateBindingOperation(
WSDLBindingOperation wsdlBindingOperation,
@@ -334,17 +430,16 @@
wsdlBindingOperation.setName(new QName(nameSpaceOfTheBindingOperation,
wsdl4jBindingOperation.getName()));
-
BindingInput wsdl4jInputBinding =
wsdl4jBindingOperation.getBindingInput();
WSDLBindingMessageReference wsdlInputBinding =
this.wsdlComponenetFactory.createWSDLBindingMessageReference();
-
wsdlInputBinding.setDirection(WSDLConstants.WSDL_MESSAGE_DIRECTION_IN);
//TODO Faults
this.copyExtensibleElements(wsdl4jInputBinding.getExtensibilityElements(),
wsdlInputBinding);
wsdlBindingOperation.setInput(wsdlInputBinding);
+
BindingOutput wsdl4jOutputBinding = wsdl4jBindingOperation
.getBindingOutput();
@@ -355,7 +450,7 @@
//TODO Faults
this.copyExtensibleElements(wsdl4jOutputBinding.getExtensibilityElements(),
wsdlOutputBinding);
- wsdlBindingOperation.setInput(wsdlOutputBinding);
+ wsdlBindingOperation.setOutput(wsdlOutputBinding);
}
@@ -454,7 +549,16 @@
extensibilityElement.setRequired(required.booleanValue());
}
component.addExtensibilityElement(extensibilityElement);
- } else {
+ }else if(wsdl4jElement instanceof Schema) {
+ Schema schema = (Schema)wsdl4jElement;
+ org.apache.wsdl.extensions.Schema extensibilityElement = (org.apache.wsdl.extensions.Schema)extensionFactory.getExtensionElement(schema.getElementType());
+ extensibilityElement.setElelment(schema.getElement());
+ Boolean required = schema.getRequired();
+ if(null != required){
+ extensibilityElement.setRequired(required.booleanValue());
+ }
+ component.addExtensibilityElement(extensibilityElement);
+ }else {
// throw new AxisError(
// "An Extensible item "+wsdl4jElement.getElementType()+" went unparsed during WSDL Parsing");
}
Modified: webservices/axis/trunk/java/modules/wsdl/src/org/apache/wsdl/WSDLConstants.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/wsdl/src/org/apache/wsdl/WSDLConstants.java?rev=179006&r1=179005&r2=179006&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/wsdl/src/org/apache/wsdl/WSDLConstants.java (original)
+++ webservices/axis/trunk/java/modules/wsdl/src/org/apache/wsdl/WSDLConstants.java Sun May 29 20:13:40 2005
@@ -29,24 +29,17 @@
*/
public static final String WSDL1_1_NAMESPACE = "http://schemas.xmlsoap.org/wsdl/";
-// /**
-// * Field WSDL_NAMESPACES
-// */
-// public static final String[] WSDL_NAMESPACES = { WSDL2_0_NAMESPACE,
-// WSDL1_1_NAMESPACE };
-//
-//
+
/**
* Field WSDL_MESSAGE_DIRECTION_IN
*/
- public static final String WSDL_MESSAGE_DIRECTION_IN = "In";
-
- // TODO Verify weather the value is right with the spec.
+ public static final String WSDL_MESSAGE_DIRECTION_IN = "in";
+
/**
* Field WSDL_MESSAGE_DIRECTION_OUT
*/
- public static final String WSDL_MESSAGE_DIRECTION_OUT = "Out";
+ public static final String WSDL_MESSAGE_DIRECTION_OUT = "out";
// ////////////////////////////////////////////////////////////////
// /////////////Message Exchange Pattern Constants/////////////////
@@ -122,6 +115,8 @@
* In-Optional-Out, Out-In, Out-Optional-In.
*/
public static final int MESSAGE_LABEL_IN = 0;
+
+ public static final String MESSAGE_LABEL_IN_VALUE = "In";
/**
* Constant to represent the message label "Out" which is used by the
@@ -130,5 +125,7 @@
*
*/
public static final int MESSAGE_LABEL_OUT = 1;
+
+ public static final String MESSAGE_LABEL_OUT_VALUE = "Out";
}
Modified: webservices/axis/trunk/java/modules/wsdl/src/org/apache/wsdl/WSDLInterface.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/wsdl/src/org/apache/wsdl/WSDLInterface.java?rev=179006&r1=179005&r2=179006&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/wsdl/src/org/apache/wsdl/WSDLInterface.java (original)
+++ webservices/axis/trunk/java/modules/wsdl/src/org/apache/wsdl/WSDLInterface.java Sun May 29 20:13:40 2005
@@ -132,4 +132,6 @@
* @param styleDefault
*/
public void setStyleDefault(String styleDefault);
+
+
}
Modified: webservices/axis/trunk/java/modules/wsdl/src/org/apache/wsdl/WSDLOperation.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/wsdl/src/org/apache/wsdl/WSDLOperation.java?rev=179006&r1=179005&r2=179006&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/wsdl/src/org/apache/wsdl/WSDLOperation.java (original)
+++ webservices/axis/trunk/java/modules/wsdl/src/org/apache/wsdl/WSDLOperation.java Sun May 29 20:13:40 2005
@@ -128,5 +128,5 @@
*
* @return
*/
- public String getTargetnemespace();
+ public String getTargetnamespace();
}
Modified: webservices/axis/trunk/java/modules/wsdl/src/org/apache/wsdl/extensions/ExtensionConstants.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/wsdl/src/org/apache/wsdl/extensions/ExtensionConstants.java?rev=179006&r1=179005&r2=179006&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/wsdl/src/org/apache/wsdl/extensions/ExtensionConstants.java (original)
+++ webservices/axis/trunk/java/modules/wsdl/src/org/apache/wsdl/extensions/ExtensionConstants.java Sun May 29 20:13:40 2005
@@ -28,5 +28,7 @@
* The Type name for the SOAP Address defined in the Port/Endpoint
*/
public static final QName SOAP_ADDRESS = new QName("http://schemas.xmlsoap.org/wsdl/soap/", "address");
+
+ public static final QName SCHEMA = new QName("http://www.w3.org/2001/XMLSchema", "schema");
}
Modified: webservices/axis/trunk/java/modules/wsdl/src/org/apache/wsdl/extensions/impl/ExtensionFactoryImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/wsdl/src/org/apache/wsdl/extensions/impl/ExtensionFactoryImpl.java?rev=179006&r1=179005&r2=179006&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/wsdl/src/org/apache/wsdl/extensions/impl/ExtensionFactoryImpl.java (original)
+++ webservices/axis/trunk/java/modules/wsdl/src/org/apache/wsdl/extensions/impl/ExtensionFactoryImpl.java Sun May 29 20:13:40 2005
@@ -36,6 +36,8 @@
public WSDLExtensibilityElement getExtensionElement(QName qName){
if(qName.equals(SOAP_ADDRESS))
return new SOAPAddressImpl();
+ if(qName.equals(SCHEMA))
+ return new SchemaImpl();
return new DefaultExtensibilityElementImpl();
Modified: webservices/axis/trunk/java/modules/wsdl/src/org/apache/wsdl/impl/WSDLInterfaceImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/wsdl/src/org/apache/wsdl/impl/WSDLInterfaceImpl.java?rev=179006&r1=179005&r2=179006&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/wsdl/src/org/apache/wsdl/impl/WSDLInterfaceImpl.java (original)
+++ webservices/axis/trunk/java/modules/wsdl/src/org/apache/wsdl/impl/WSDLInterfaceImpl.java Sun May 29 20:13:40 2005
@@ -70,7 +70,7 @@
* @return
*/
public HashMap getAllOperations() {
- HashMap all = (HashMap) this.operations;
+ HashMap all = this.operations;
if (this.superInterfaces.size() == 0) {
return all;
} else {
@@ -94,8 +94,8 @@
thisOperation = (WSDLOperation) thisIterator.next();
if ((thisOperation.getName() == superInterfaceOperation.getName())
&& !tobeAdded) {
- if (thisOperation.getTargetnemespace().equals(
- superInterfaceOperation.getTargetnemespace())) {
+ if (thisOperation.getTargetnamespace().equals(
+ superInterfaceOperation.getTargetnamespace())) {
// Both are the same Operation; the one inherited and
// the one that is already in the map(may or maynot be inherited)
@@ -113,7 +113,7 @@
if (tobeAdded) {
// This one is not in the list already developped
- all.put(superInterfaceOperation.getName(),
+ all.put(superInterfaceOperation.getName().getLocalPart(),
superInterfaceOperation);
}
}
@@ -220,7 +220,7 @@
throw new WSDLProcessingException(
"The Operation name cannot be null (required)");
}
- this.operations.put(operation.getName(), operation);
+ this.operations.put(operation.getName().getLocalPart(), operation);
}
/**
Modified: webservices/axis/trunk/java/modules/wsdl/src/org/apache/wsdl/impl/WSDLOperationImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/wsdl/src/org/apache/wsdl/impl/WSDLOperationImpl.java?rev=179006&r1=179005&r2=179006&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/wsdl/src/org/apache/wsdl/impl/WSDLOperationImpl.java (original)
+++ webservices/axis/trunk/java/modules/wsdl/src/org/apache/wsdl/impl/WSDLOperationImpl.java Sun May 29 20:13:40 2005
@@ -209,7 +209,7 @@
*
* @return
*/
- public String getTargetnemespace() {
+ public String getTargetnamespace() {
if (null != this.name) {
return this.name.getNamespaceURI();
}
Modified: webservices/axis/trunk/java/modules/wsdl/test/org/apache/wsdl/InterfaceTest.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/wsdl/test/org/apache/wsdl/InterfaceTest.java?rev=179006&r1=179005&r2=179006&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/wsdl/test/org/apache/wsdl/InterfaceTest.java (original)
+++ webservices/axis/trunk/java/modules/wsdl/test/org/apache/wsdl/InterfaceTest.java Sun May 29 20:13:40 2005
@@ -1,17 +1,17 @@
/*
* Copyright 2004,2005 The Apache Software Foundation.
*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
*/
package org.apache.wsdl;
@@ -22,73 +22,84 @@
import java.util.Iterator;
public class InterfaceTest extends AbstractTestCase {
- public InterfaceTest(String testName) {
- super(testName);
- }
-
- public void testGetAllOperations() {
- WSDLOperation op;
- WSDLInterface intfc;
- WSDLInterface[] array = new WSDLInterface[5];
- int interfaceCounter = 5;
- int operationCounter = 5;
- for (int j = 0; j < interfaceCounter; j++) {
- intfc = new WSDLInterfaceImpl();
- intfc.setName(new QName(WSDLConstants.WSDL2_0_NAMESPACE, "inteface" + j));
- for (int i = 0; i < operationCounter; i++) {
- op = new WSDLOperationImpl();
- op.setName(new QName(WSDLConstants.WSDL1_1_NAMESPACE, "op" + i + "of inteface" + j));
- assertNotNull(op.getName());
- intfc.setOperation(op);
- }
- if (j > 0) {
- intfc.addSuperInterface(array[j - 1]);
- }
- array[j] = intfc;
- }
- //System.out.println(array[0].getAllOperations().size());
- assertEquals(((WSDLOperation) array[0].getAllOperations().get(new QName(WSDLConstants.WSDL1_1_NAMESPACE, "op0of inteface0"))).getName().getLocalPart(), "op0of inteface0");
- assertEquals(((WSDLOperation) array[0].getAllOperations().get(new QName(WSDLConstants.WSDL1_1_NAMESPACE, "op1of inteface0"))).getName().getLocalPart(), "op1of inteface0");
- assertEquals(array[interfaceCounter - 1].getAllOperations().size(), interfaceCounter * operationCounter);
- assertEquals(interfaceCounter * operationCounter, array[interfaceCounter - 1].getAllOperations().size());
- Iterator iter = array[1].getAllOperations().keySet().iterator();
- while (iter.hasNext()) {
- assertNotNull(((WSDLOperation) array[interfaceCounter - 1].getAllOperations().get(iter.next())).getName());
- }
- for (int j = 0; j < interfaceCounter; j++) {
- for (int i = 0; i < operationCounter; i++) {
- assertEquals(((WSDLOperation) array[interfaceCounter - 1].getAllOperations().get(new QName(WSDLConstants.WSDL1_1_NAMESPACE, "op" + j + "of inteface" + i))).getName().getLocalPart(), "op" + j + "of inteface" + i);
- }
- }
-
- }
-
- /**
- * When a interface inherit two or more Interfaces the inherited operation
- * who have the same QName should be the same Operation.
- */
- public void testInheritedOperationResolution() throws Exception {
- WSDLOperation op;
- WSDLInterface intfc;
- WSDLInterface[] array = new WSDLInterface[5];
- int interfaceCounter = 5;
- int operationCounter = 5;
- for (int i = 0; i < interfaceCounter; i++) {
- intfc = new WSDLInterfaceImpl();
- for (int j = 0; j < operationCounter; j++) {
- op = new WSDLOperationImpl();
- op.setName(new QName(WSDLConstants.WSDL1_1_NAMESPACE, "operation" + j));
- intfc.setOperation(op);
- }
- intfc.setName(new QName(WSDLConstants.WSDL2_0_NAMESPACE, "Interface" + i));
- array[i] = intfc;
- }
- WSDLInterface inheritedInterface = new WSDLInterfaceImpl();
- for (int i = 0; i < array.length; i++) {
- inheritedInterface.addSuperInterface(array[i]);
- }
- assertEquals(inheritedInterface.getAllOperations().size(), 5);
+ public InterfaceTest(String testName) {
+ super(testName);
+ }
+
+ public void testGetAllOperations() {
+ WSDLOperation op;
+ WSDLInterface intfc;
+ WSDLInterface[] array = new WSDLInterface[5];
+ int interfaceCounter = 5;
+ int operationCounter = 5;
+ for (int j = 0; j < interfaceCounter; j++) {
+ intfc = new WSDLInterfaceImpl();
+ intfc.setName(new QName(WSDLConstants.WSDL2_0_NAMESPACE, "inteface"
+ + j));
+ for (int i = 0; i < operationCounter; i++) {
+ op = new WSDLOperationImpl();
+ op.setName(new QName(WSDLConstants.WSDL1_1_NAMESPACE, "op" + i
+ + "of inteface" + j));
+ assertNotNull(op.getName());
+ intfc.setOperation(op);
+ }
+ if (j > 0) {
+ intfc.addSuperInterface(array[j - 1]);
+ }
+ array[j] = intfc;
+ }
+ assertEquals(((WSDLOperation) array[0].getOperation("op0of inteface0"))
+ .getName().getLocalPart(), "op0of inteface0");
+ assertEquals(((WSDLOperation) array[0].getOperation("op1of inteface0"))
+ .getName().getLocalPart(), "op1of inteface0");
+ assertEquals(array[interfaceCounter - 1].getAllOperations().size(),
+ interfaceCounter * operationCounter);
+ assertEquals(interfaceCounter * operationCounter,
+ array[interfaceCounter - 1].getAllOperations().size());
+ Iterator iter = array[1].getAllOperations().keySet().iterator();
+ while (iter.hasNext()) {
+ assertNotNull(((WSDLOperation) array[interfaceCounter - 1]
+ .getAllOperations().get(iter.next())).getName());
+ }
+ for (int j = 0; j < interfaceCounter; j++) {
+ for (int i = 0; i < operationCounter; i++) {
+ WSDLOperation operation = (WSDLOperation) array[interfaceCounter - 1]
+ .getAllOperations().get("op" + j + "of inteface" + i);
+ assertEquals((operation).getName().getLocalPart(), "op" + j
+ + "of inteface" + i);
+ }
+ }
+
+ }
+
+ /**
+ * When a interface inherit two or more Interfaces the inherited operation
+ * who have the same QName should be the same Operation.
+ */
+ public void testInheritedOperationResolution() throws Exception {
+ WSDLOperation op;
+ WSDLInterface intfc;
+ WSDLInterface[] array = new WSDLInterface[5];
+ int interfaceCounter = 5;
+ int operationCounter = 5;
+ for (int i = 0; i < interfaceCounter; i++) {
+ intfc = new WSDLInterfaceImpl();
+ for (int j = 0; j < operationCounter; j++) {
+ op = new WSDLOperationImpl();
+ op.setName(new QName(WSDLConstants.WSDL1_1_NAMESPACE,
+ "operation" + j));
+ intfc.setOperation(op);
+ }
+ intfc.setName(new QName(WSDLConstants.WSDL2_0_NAMESPACE,
+ "Interface" + i));
+ array[i] = intfc;
+ }
+ WSDLInterface inheritedInterface = new WSDLInterfaceImpl();
+ for (int i = 0; i < array.length; i++) {
+ inheritedInterface.addSuperInterface(array[i]);
+ }
+ assertEquals(inheritedInterface.getAllOperations().size(), 5);
- }
+ }
}
Modified: webservices/axis/trunk/java/modules/wsdl/test/org/apache/wsdl/WOMBuilderTest.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/wsdl/test/org/apache/wsdl/WOMBuilderTest.java?rev=179006&r1=179005&r2=179006&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/wsdl/test/org/apache/wsdl/WOMBuilderTest.java (original)
+++ webservices/axis/trunk/java/modules/wsdl/test/org/apache/wsdl/WOMBuilderTest.java Sun May 29 20:13:40 2005
@@ -47,12 +47,12 @@
private void initialize() throws Exception {
if (null == this.womDescription) {
- InputStream in = new FileInputStream(this.getTestResourceFile("SeismicService.wsdl"));
+ InputStream in = new FileInputStream(getTestResourceFile("InteropTest.wsdl"));
this.womDescription = WOMBuilderFactory.getBuilder(WOMBuilderFactory.WSDL11).build(in);
}
if (null == wsdl4jDefinition) {
WSDLReader reader = WSDLFactory.newInstance().newWSDLReader();
- Document doc = Utils.newDocument(new FileInputStream(this.getTestResourceFile("SeismicService.wsdl")));
+ Document doc = Utils.newDocument(new FileInputStream(getTestResourceFile("InteropTest.wsdl")));
this.wsdl4jDefinition = reader.readWSDL(null, doc);
}
}
@@ -80,8 +80,13 @@
Iterator womOperationIterator = wsdlInterface.getAllOperations().values().iterator();
Iterator wsdl4jOprationIterator = porttype.getOperations().iterator();
//Will only work if the order is retained in the iteration
- while (womOperationIterator.hasNext() & wsdl4jOprationIterator.hasNext()) {
- this.operationsWaliking((WSDLOperation) womOperationIterator.next(), (Operation) wsdl4jOprationIterator.next());
+ while (wsdl4jOprationIterator.hasNext()) {
+ Operation wsdl4jOperation = (Operation) wsdl4jOprationIterator.next();
+ this.operationsWaliking(wsdlInterface.getOperation(wsdl4jOperation.getName()), wsdl4jOperation);
+ }
+ while(womOperationIterator.hasNext() ){
+ WSDLOperation womOperation = (WSDLOperation)womOperationIterator.next();
+ this.operationsWaliking(womOperation, porttype.getOperation(womOperation.getName().getLocalPart(), null,null));
}
}