You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by aj...@apache.org on 2005/10/13 05:39:10 UTC
svn commit: r320633 - in /webservices/axis2/trunk/java/modules:
codegen/src/org/apache/axis2/databinding/schema/
codegen/src/org/apache/axis2/wsdl/codegen/emitter/
codegen/src/org/apache/axis2/wsdl/codegen/extension/
tool/src/org/apache/axis2/tool/core...
Author: ajith
Date: Wed Oct 12 20:38:45 2005
New Revision: 320633
URL: http://svn.apache.org/viewcvs?rev=320633&view=rev
Log:
1.Updated the SimpleDBExtension.java to feed the namespace mappings from the root element
2.Updated the WSDLPump to create schemas wrapping parts. The routine is still blocked by a boolean but it seems to be working!
Modified:
webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/TypeMap.java
webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/emitter/MultiLanguageClientEmitter.java
webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/extension/SimpleDBExtension.java
webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/extension/WSDLValidatorExtension.java
webservices/axis2/trunk/java/modules/tool/src/org/apache/axis2/tool/core/ServiceFileCreator.java
webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/builder/wsdl4j/WSDL1ToWOMBuilder.java
webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/builder/wsdl4j/WSDLPump.java
webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/writer/WOMtoWSDL11Writer.java
webservices/axis2/trunk/java/modules/wsdl/test-resources/BookQuote.wsdl
Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/TypeMap.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/TypeMap.java?rev=320633&r1=320632&r2=320633&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/TypeMap.java (original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/TypeMap.java Wed Oct 12 20:38:45 2005
@@ -28,19 +28,8 @@
private static Map typeMap = new HashMap();
static{
-// If SOAP 1.1 over the wire, map wrapper classes to XSD primitives.
+ // If SOAP 1.1 over the wire, map wrapper classes to XSD primitives.
addTypemapping(SchemaConstants.XSD_STRING, java.lang.String.class.getName());
- addTypemapping(SchemaConstants.XSD_BOOLEAN, java.lang.Boolean.class.getName());
- addTypemapping(SchemaConstants.XSD_DOUBLE, java.lang.Double.class.getName());
- addTypemapping(SchemaConstants.XSD_FLOAT, java.lang.Float.class.getName());
- addTypemapping(SchemaConstants.XSD_INT, java.lang.Integer.class.getName());
- addTypemapping(SchemaConstants.XSD_INTEGER, java.math.BigInteger.class.getName()
- );
- addTypemapping(SchemaConstants.XSD_DECIMAL, java.math.BigDecimal.class.getName()
- );
- addTypemapping(SchemaConstants.XSD_LONG, java.lang.Long.class.getName());
- addTypemapping(SchemaConstants.XSD_SHORT, java.lang.Short.class.getName());
- addTypemapping(SchemaConstants.XSD_BYTE, java.lang.Byte.class.getName());
// The XSD Primitives are mapped to java primitives.
addTypemapping(SchemaConstants.XSD_BOOLEAN, boolean.class.getName());
@@ -50,6 +39,8 @@
addTypemapping(SchemaConstants.XSD_LONG, long.class.getName());
addTypemapping(SchemaConstants.XSD_SHORT, short.class.getName());
addTypemapping(SchemaConstants.XSD_BYTE, byte.class.getName());
+ addTypemapping(SchemaConstants.XSD_ANY, Object.class.getName());
+ addTypemapping(SchemaConstants.XSD_ANYTYPE, Object.class.getName());
}
private static void addTypemapping(QName name,String str) {
Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/emitter/MultiLanguageClientEmitter.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/emitter/MultiLanguageClientEmitter.java?rev=320633&r1=320632&r2=320633&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/emitter/MultiLanguageClientEmitter.java (original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/emitter/MultiLanguageClientEmitter.java Wed Oct 12 20:38:45 2005
@@ -905,19 +905,21 @@
private void addSOAPAction(Document doc,
Element rootElement,
WSDLBindingOperation binding) {
- Iterator extIterator = binding.getExtensibilityElements().iterator();
+ List extensibilityElements = binding.getExtensibilityElements();
boolean actionAdded = false;
- while (extIterator.hasNext()) {
- WSDLExtensibilityElement element = (WSDLExtensibilityElement) extIterator.next();
- if (ExtensionConstants.SOAP_11_OPERATION.equals(element.getType())) {
- addAttribute(doc,
- "soapaction",
- ((SOAPOperation) element).getSoapAction(),
- rootElement);
- actionAdded = true;
+ if (extensibilityElements!=null && !extensibilityElements.isEmpty()){
+ Iterator extIterator = extensibilityElements.iterator();
+ while (extIterator.hasNext()) {
+ WSDLExtensibilityElement element = (WSDLExtensibilityElement) extIterator.next();
+ if (ExtensionConstants.SOAP_11_OPERATION.equals(element.getType())) {
+ addAttribute(doc,
+ "soapaction",
+ ((SOAPOperation) element).getSoapAction(),
+ rootElement);
+ actionAdded = true;
+ }
}
}
-
if (!actionAdded) {
addAttribute(doc, "soapaction", "", rootElement);
}
@@ -1171,7 +1173,7 @@
String AttribName,
String attribValue,
Element element) {
- XSLTUtils.addAttribute(document,AttribName,attribValue,element);
+ XSLTUtils.addAttribute(document,AttribName,attribValue,element);
}
Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/extension/SimpleDBExtension.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/extension/SimpleDBExtension.java?rev=320633&r1=320632&r2=320633&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/extension/SimpleDBExtension.java (original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/extension/SimpleDBExtension.java Wed Oct 12 20:38:45 2005
@@ -64,7 +64,14 @@
XmlSchemaCollection schemaColl = new XmlSchemaCollection();
//add the namespace map here. it is absolutely needed
- Schema schema = null;
+ Map nsMap = configuration.getWom().getNamespaces();
+ Iterator keys = nsMap.keySet().iterator();
+ String key;
+ while (keys.hasNext()) {
+ key = (String) keys.next();
+ schemaColl.mapNamespace(key,(String)nsMap.get(key));
+ }
+ Schema schema;
if (ExtensionConstants.SCHEMA.equals(extensiblityElt.getType())) {
schema = (Schema) extensiblityElt;
@@ -94,11 +101,11 @@
JavaTypeMapper mapper = new JavaTypeMapper();
//get the processed element map and transfer it to the type mapper
Map processedMap = schemaCompiler.getProcessedElementmap();
- Iterator keys = processedMap.keySet().iterator();
- QName key;
- while (keys.hasNext()) {
- key =(QName)keys.next();
- mapper.addTypeMapping(key,processedMap.get(key));
+ Iterator processedkeys = processedMap.keySet().iterator();
+ QName qNameKey;
+ while (processedkeys.hasNext()) {
+ qNameKey =(QName)processedkeys.next();
+ mapper.addTypeMapping(qNameKey,processedMap.get(qNameKey));
}
//set the type mapper to the config
Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/extension/WSDLValidatorExtension.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/extension/WSDLValidatorExtension.java?rev=320633&r1=320632&r2=320633&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/extension/WSDLValidatorExtension.java (original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/extension/WSDLValidatorExtension.java Wed Oct 12 20:38:45 2005
@@ -62,8 +62,9 @@
NamedNodeMap attributes = schemaElement.getAttributes();
for (int i = 0; i < attributes.getLength(); i++) {
+
if (TARGETNAMESPACE_STRING.equalsIgnoreCase(
- attributes.item(i).getLocalName())){
+ attributes.item(i).getNodeName())){
targetnamespaceFound = true;
break;
}
Modified: webservices/axis2/trunk/java/modules/tool/src/org/apache/axis2/tool/core/ServiceFileCreator.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/tool/src/org/apache/axis2/tool/core/ServiceFileCreator.java?rev=320633&r1=320632&r2=320633&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/tool/src/org/apache/axis2/tool/core/ServiceFileCreator.java (original)
+++ webservices/axis2/trunk/java/modules/tool/src/org/apache/axis2/tool/core/ServiceFileCreator.java Wed Oct 12 20:38:45 2005
@@ -43,7 +43,7 @@
}
-
+ //todo Fix this!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
private XmlDocument getServiceModel(String serviceName,String className,ArrayList methods){
XmlDocument doc = new XmlDocument();
Element rootElement = doc.createElement("interface");
Modified: webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/builder/wsdl4j/WSDL1ToWOMBuilder.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/builder/wsdl4j/WSDL1ToWOMBuilder.java?rev=320633&r1=320632&r2=320633&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/builder/wsdl4j/WSDL1ToWOMBuilder.java (original)
+++ webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/builder/wsdl4j/WSDL1ToWOMBuilder.java Wed Oct 12 20:38:45 2005
@@ -18,6 +18,9 @@
import org.apache.axis2.util.XMLUtils;
import org.apache.axis2.wsdl.WSDLVersionWrapper;
+import org.apache.axis2.wsdl.writer.WOMWriterFactory;
+import org.apache.axis2.wsdl.writer.WOMWriter;
+import org.apache.axis2.wsdl.writer.WriterException;
import org.apache.axis2.wsdl.builder.WOMBuilder;
import org.apache.axis2.wsdl.builder.WSDLComponentFactory;
import org.apache.wsdl.WSDLDescription;
@@ -37,84 +40,87 @@
public class WSDL1ToWOMBuilder implements WOMBuilder {
- /**
- * Buils a WOM and a WSDL4J object model from given the URI of the WSDL file and
- * will be returned as a wrapper object WSDLVersionWrapper.
- * @param in InputStream from which the WSDL document can be read in.
- * @return WSDLVersionWrapper which contains both the WSDL 2.0 and WSDL 1.1
- * object models.
- * @throws WSDLException
- */
+ /**
+ * Buils a WOM and a WSDL4J object model from given the URI of the WSDL file and
+ * will be returned as a wrapper object WSDLVersionWrapper.
+ * @param in InputStream from which the WSDL document can be read in.
+ * @return WSDLVersionWrapper which contains both the WSDL 2.0 and WSDL 1.1
+ * object models.
+ * @throws WSDLException
+ */
public WSDLVersionWrapper build(InputStream in) throws WSDLException {
- return build(in, null);
+ return build(in, null);
}
-
+
/**
- * Buils a WOM and a WSDL4J object model from given the URI of the WSDL file and
- * will be returned as a wrapper object WSDLVersionWrapper. A WSDL Component Factory
- * can be passed into the builder using which the WOM component can be built out of.
- * For example: The Enigne uses the WOM's components in the context hierarchy but
- * those are extended components.
- * (<code>ServiceDescription</code> extends <code>WSDLService</code>.)
- * So when deployment build the WOM it would prefer to get a <code>ServiceDescription</code>
- * built in place of a <code>WSDLService</code>. This can be achieved by passing the
- * correct Component Factory that will instanciate the correct object for the WOM builder.
- * @param in InputStream from which the WSDL document can be read in.
- * @param wsdlComponentFactory The ComponentFactory that will be used to create the
- * WOm components out of.
- * @return WSDLVersionWrapper which contains both the WSDL 2.0 and WSDL 1.1
- * object models.
- * @throws WSDLException
- */
- public WSDLVersionWrapper build(InputStream in,
- WSDLComponentFactory wsdlComponentFactory) throws WSDLException {
- if(null == wsdlComponentFactory){
- wsdlComponentFactory = new WSDLDescriptionImpl();
- }
- WSDLDescription wsdlDescription = wsdlComponentFactory.createDescription();
+ * Buils a WOM and a WSDL4J object model from given the URI of the WSDL file and
+ * will be returned as a wrapper object WSDLVersionWrapper. A WSDL Component Factory
+ * can be passed into the builder using which the WOM component can be built out of.
+ * For example: The Enigne uses the WOM's components in the context hierarchy but
+ * those are extended components.
+ * (<code>ServiceDescription</code> extends <code>WSDLService</code>.)
+ * So when deployment build the WOM it would prefer to get a <code>ServiceDescription</code>
+ * built in place of a <code>WSDLService</code>. This can be achieved by passing the
+ * correct Component Factory that will instanciate the correct object for the WOM builder.
+ * @param in InputStream from which the WSDL document can be read in.
+ * @param wsdlComponentFactory The ComponentFactory that will be used to create the
+ * WOm components out of.
+ * @return WSDLVersionWrapper which contains both the WSDL 2.0 and WSDL 1.1
+ * object models.
+ * @throws WSDLException
+ */
+ public WSDLVersionWrapper build(InputStream in,
+ WSDLComponentFactory wsdlComponentFactory) throws WSDLException {
+ if(null == wsdlComponentFactory){
+ wsdlComponentFactory = new WSDLDescriptionImpl();
+ }
+ WSDLDescription wsdlDescription = wsdlComponentFactory.createDescription();
Definition wsdl1Definition = this.readInTheWSDLFile(in);
WSDLPump pump = new WSDLPump(wsdlDescription, wsdl1Definition);
pump.pump();
+
+
+
return new WSDLVersionWrapper(wsdlDescription, wsdl1Definition);
}
-
+
/**
- * Buils a WOM and a WSDL4J object model from given the URI of the WSDL file and
- * will be returned as a wrapper object WSDLVersionWrapper.
- * @param uri URI pointing to the WSDL document.
- * @return WSDLVersionWrapper which contains both the WSDL 2.0 and WSDL 1.1
- * object models.
- * @throws WSDLException
- */
- public WSDLVersionWrapper build(String uri) throws WSDLException {
+ * Buils a WOM and a WSDL4J object model from given the URI of the WSDL file and
+ * will be returned as a wrapper object WSDLVersionWrapper.
+ * @param uri URI pointing to the WSDL document.
+ * @return WSDLVersionWrapper which contains both the WSDL 2.0 and WSDL 1.1
+ * object models.
+ * @throws WSDLException
+ */
+ public WSDLVersionWrapper build(String uri) throws WSDLException {
return build(uri, null);
}
- /**
- * Buils a WOM and a WSDL4J object model from given the URI of the WSDL file and
- * will be returned as a wrapper object WSDLVersionWrapper. A WSDL Component Factory
- * can be passed into the builder using which the WOM component can be built out of.
- * For example: The Enigne uses the WOM's components in the context hierarchy but
- * those are extended components.
- * (<code>ServiceDescription</code> extends <code>WSDLService</code>.)
- * So when deployment build the WOM it would prefer to get a <code>ServiceDescription</code>
- * built in place of a <code>WSDLService</code>. This can be achieved by passing the
- * correct Component Factory that will instanciate the correct object for the WOM builder.
- * @param uri URI pointing to the WSDL document.
- * @param wsdlComponentFactory The ComponentFactory that will be used to create the
- * WOm components out of.
- * @return WSDLVersionWrapper which contains both the WSDL 2.0 and WSDL 1.1
- * object models.
- * @throws WSDLException
- */
+ /**
+ * Buils a WOM and a WSDL4J object model from given the URI of the WSDL file and
+ * will be returned as a wrapper object WSDLVersionWrapper. A WSDL Component Factory
+ * can be passed into the builder using which the WOM component can be built out of.
+ * For example: The Enigne uses the WOM's components in the context hierarchy but
+ * those are extended components.
+ * (<code>ServiceDescription</code> extends <code>WSDLService</code>.)
+ * So when deployment build the WOM it would prefer to get a <code>ServiceDescription</code>
+ * built in place of a <code>WSDLService</code>. This can be achieved by passing the
+ * correct Component Factory that will instanciate the correct object for the WOM builder.
+ * @param uri URI pointing to the WSDL document.
+ * @param wsdlComponentFactory The ComponentFactory that will be used to create the
+ * WOm components out of.
+ * @return WSDLVersionWrapper which contains both the WSDL 2.0 and WSDL 1.1
+ * object models.
+ * @throws WSDLException
+ */
public WSDLVersionWrapper build(String uri,
WSDLComponentFactory wsdlComponentFactory) throws WSDLException {
- if(null == wsdlComponentFactory){
- wsdlComponentFactory = new WSDLDescriptionImpl();
- }
+ if(null == wsdlComponentFactory){
+ wsdlComponentFactory = new WSDLDescriptionImpl();
+ }
WSDLDescription wsdlDescription = wsdlComponentFactory.createDescription();
Definition wsdl1Definition = this.readInTheWSDLFile(uri);
@@ -123,6 +129,7 @@
wsdlComponentFactory);
pump.pump();
+
return new WSDLVersionWrapper(wsdlDescription, wsdl1Definition);
}
@@ -152,9 +159,9 @@
return reader.readWSDL(baseURI, doc);
}
-
+
private Definition readInTheWSDLFile(InputStream in) throws WSDLException {
-
+
WSDLReader reader =
WSDLFactory.newInstance().newWSDLReader();
Modified: webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/builder/wsdl4j/WSDLPump.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/builder/wsdl4j/WSDLPump.java?rev=320633&r1=320632&r2=320633&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/builder/wsdl4j/WSDLPump.java (original)
+++ webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/builder/wsdl4j/WSDLPump.java Wed Oct 12 20:38:45 2005
@@ -52,16 +52,27 @@
public class WSDLPump {
- private static final String XSD_TYPE = "type";
- private static final String XSD_SEQUENCE = "sequence";
+ private static final String XMLSCHEMA_NAMESPACE_URI = "http://www.w3.org/2001/XMLSchema";
+ private static final String XMLSCHEMA_NAMESPACE_PREFIX = "xs";
+ private static final String XSD_SCHEMA_QUALIFIED_NAME =XMLSCHEMA_NAMESPACE_PREFIX + ":schema";
+ private static final String XSD_SEQUENCE_QUALIFIED_NAME =XMLSCHEMA_NAMESPACE_PREFIX + ":sequence";
+ private static final String XSD_COMPLEXTYPE_QUALIFIED_NAME = XMLSCHEMA_NAMESPACE_PREFIX + ":complexType";
+ private static final String XSD_ELEMENT_QUALIFIED_NAME = XMLSCHEMA_NAMESPACE_PREFIX + ":element";
+
private static final String XSD_NAME = "name";
- private static final String XSD_COMPLEXTYPE = "complexType";
private static final String XSD_TARGETNAMESPACE = "targetNamespace";
private static final String XMLNS_AXIS2WRAPPED = "xmlns:axis2wrapped";
- private static final String NAMESPACE_XMLSCHEMA = "http://www.w3.org/2001/XMLSchema";
- private static final String XSD_ELEMENT = "element";
+ private static final String XSD_TYPE = "type";
private static final String BOUND_INTERFACE_NAME = "BoundInterface";
+ //////////////////////////////////////////
+ //this needs to be set by the code generator
+ //however make it false by default to avoid nasty surprises
+ private boolean wrap = false;
+ //////////////////////////////////////////
+
+ private static int nsCount=0;
+
private WSDLDescription womDefinition;
private Definition wsdl4jParsedDefinition;
@@ -104,6 +115,9 @@
this.copyExtensibleElements(
wsdl4JDefinition.getExtensibilityElements(), wsdlDefinition, null);
+ //we need to populate some flags here. Firstly soap stlye
+
+
/////////////////////////////////////////////////////////////////////
// Order of the following items shouldn't be changed unless you //
// really know what you are doing. Reason being the components that //
@@ -157,6 +171,9 @@
}
}
+
+
+
///////////////////(2)Copy the Interfaces///////////////////////////
//copy the Interfaces: Get the PortTypes from WSDL4J parse OM and
// copy it to the
@@ -416,16 +433,23 @@
}
+ /**
+ * Generates a referenceQName
+ * @param wsdl4jMessage
+ * @return
+ */
private QName generateReferenceQname(Message wsdl4jMessage) {
QName referenceQName = null;
- if (wsdl4jMessage.getParts().size() > 1) {
+ //do the wrapping if required
+ if (wrap) {
Map parts = wsdl4jMessage.getParts();
- Iterator i = parts.keySet().iterator();
- Part thisPart = (Part)(parts.get(i.next()));
- if (thisPart.getElementName() != null) {
- throw new RuntimeException(
- "We don't support multiple element parts in a WSDL message");
- }
+
+ // Iterator partsItertator = parts.keySet().iterator();
+ // Part thisPart = (Part)(parts.get(partsItertator.next()));
+ // if (thisPart.getElementName() != null) {
+ // throw new RuntimeException(
+ // "We don't support multiple element parts in a WSDL message");
+ // }
// Multipart Message
@@ -435,6 +459,7 @@
// happening for document style.
// TODO : sanity check
+
// Check whether this message parts have been made to a type
Iterator multipartListIterator = this.resolvedMultipartMessageList.iterator();
boolean multipartAlreadyResolved = false;
@@ -458,100 +483,117 @@
//If types is null create a new one to be used for multipart
//resolution if any.
- if (null == types) {
- DocumentBuilder documentBuilder = null;
- try {
- documentBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
- } catch (ParserConfigurationException e) {
- throw new RuntimeException(e);
- }
- Document newDoc = documentBuilder.newDocument();
- Element newSchemaElement = newDoc.createElementNS("http://www.w3.org/2001/XMLSchema", "schema");
+ if (null == types) {
+ //create a new types section
types = wsdlComponentFactory.createTypes();
- ExtensionFactory extensionFactory = wsdlComponentFactory.createExtensionFactory();
- org.apache.wsdl.extensions.Schema typesElement = (org.apache.wsdl.extensions.Schema) extensionFactory.getExtensionElement(
- ExtensionConstants.SCHEMA);
- typesElement.setElement(newSchemaElement);
- types.addExtensibilityElement(typesElement);
this.womDefinition.setTypes(types);
}
+ //create a new Schema extensions element
+ ExtensionFactory extensionFactory = wsdlComponentFactory.createExtensionFactory();
+ org.apache.wsdl.extensions.Schema schemaExtensibilityElement = (org.apache.wsdl.extensions.Schema) extensionFactory.getExtensionElement(
+ ExtensionConstants.SCHEMA);
+ types.addExtensibilityElement(schemaExtensibilityElement);
+
- //
- Iterator schemaEIIterator = types.getExtensibilityElements()
- .iterator();
- while (schemaEIIterator.hasNext()) {
- WSDLExtensibilityElement temp = (WSDLExtensibilityElement) schemaEIIterator.next();
- if (ExtensionConstants.SCHEMA.equals(temp.getType())) {
- schemaElement =
- ((org.apache.wsdl.extensions.Schema) temp).getElement();
- break;
- }
+ //add a schema DOM element
+ DocumentBuilder documentBuilder = null;
+ try {
+ documentBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
+ } catch (ParserConfigurationException e) {
+ throw new RuntimeException(e);
}
+ Document newDoc = documentBuilder.newDocument();
+ schemaElement = newDoc.createElementNS(XMLSCHEMA_NAMESPACE_URI, XSD_SCHEMA_QUALIFIED_NAME);
+ schemaExtensibilityElement.setElement(schemaElement);
+
+ //add the namespace declarations
+ String targetNamespaceUri = wsdl4jMessage.getQName().getNamespaceURI();
+ if (targetNamespaceUri.trim().equals("")){
+ targetNamespaceUri = getTemporaryNamespaceUri();
+ }
+
+ schemaElement.setAttribute(XMLNS_AXIS2WRAPPED,
+ targetNamespaceUri);
+ schemaElement.setAttribute(XSD_TARGETNAMESPACE,targetNamespaceUri);
+ schemaElement.setAttribute("xmlns:"+XMLSCHEMA_NAMESPACE_PREFIX,XMLSCHEMA_NAMESPACE_URI);
- schemaElement.setAttribute(WSDLPump.XMLNS_AXIS2WRAPPED, schemaElement.getAttribute(WSDLPump.XSD_TARGETNAMESPACE));
+ //add the complex type
Document doc = schemaElement.getOwnerDocument();
String name = wsdl4jMessage.getQName().getLocalPart();
- Element newType = doc.createElementNS(WSDLPump.NAMESPACE_XMLSCHEMA, WSDLPump.XSD_COMPLEXTYPE);
- newType.setAttribute(WSDLPump.XSD_NAME, name);
+ Element newComplexType = doc.createElementNS(WSDLPump.XMLSCHEMA_NAMESPACE_URI, WSDLPump.XSD_COMPLEXTYPE_QUALIFIED_NAME);
+ newComplexType.setAttribute(WSDLPump.XSD_NAME, name);
-
- Element cmplxContent = doc.createElementNS(WSDLPump.NAMESPACE_XMLSCHEMA, WSDLPump.XSD_SEQUENCE);
+ // add the sequence
+ // Note - we model the complex type as a sequence!
+ Element cmplxContentSequence = doc.createElementNS(WSDLPump.XMLSCHEMA_NAMESPACE_URI, WSDLPump.XSD_SEQUENCE_QUALIFIED_NAME);
Element child;
Element relaventElementInSchemaReferedByPart = null;
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();
- }
+ //the part name
+ String elementName = part.getName();
+ //the type name
+ QName schemaTypeName = part.getTypeName();
+ //see whether this type is already present in one of the schemas
NodeList allSchemaElements = schemaElement.getChildNodes();
for(int idx = 0; idx < allSchemaElements.getLength(); idx++){
if(allSchemaElements.item(idx).getNodeType() == Node.ELEMENT_NODE &&
- allSchemaElements.item(idx).getLocalName().equals(WSDLPump.XSD_ELEMENT)
- && elementName.getLocalPart().equals(((Element)allSchemaElements.item(idx)).getAttribute(WSDLPump.XSD_NAME))){
+ allSchemaElements.item(idx).getLocalName().equals(WSDLPump.XSD_ELEMENT_QUALIFIED_NAME)
+ && elementName.equals(((Element)allSchemaElements.item(idx)).getAttribute(WSDLPump.XSD_NAME))){
relaventElementInSchemaReferedByPart = (Element)allSchemaElements.item(idx);
break;
}
}
- child = doc.createElementNS(WSDLPump.NAMESPACE_XMLSCHEMA, WSDLPump.XSD_ELEMENT);
- child.setAttribute(WSDLPump.XSD_NAME, elementName.getLocalPart());
- if(null != relaventElementInSchemaReferedByPart){
-
+ child = doc.createElementNS(WSDLPump.XMLSCHEMA_NAMESPACE_URI, WSDLPump.XSD_ELEMENT_QUALIFIED_NAME);
+ child.setAttribute(WSDLPump.XSD_NAME, elementName);
+ if(null != relaventElementInSchemaReferedByPart){
child.setAttribute(WSDLPump.XSD_TYPE,
relaventElementInSchemaReferedByPart.getAttribute(WSDLPump.XSD_TYPE));
}else{
- child.setAttribute(WSDLPump.XSD_TYPE, elementName.getLocalPart());
+ String prefix = null;
+ if (XMLSCHEMA_NAMESPACE_URI.equals(schemaTypeName.getNamespaceURI())){
+ prefix = XMLSCHEMA_NAMESPACE_PREFIX;
+ }else{
+ prefix = schemaTypeName.getPrefix();
+ }
+ child.setAttribute(WSDLPump.XSD_TYPE, prefix +":"+schemaTypeName.getLocalPart());
}
- cmplxContent.appendChild(child);
-
+ cmplxContentSequence.appendChild(child);
}
- newType.appendChild(cmplxContent);
-
- schemaElement.appendChild(newType);
+ newComplexType.appendChild(cmplxContentSequence);
+ schemaElement.appendChild(newComplexType);
- Element newElement = doc.createElementNS(WSDLPump.NAMESPACE_XMLSCHEMA, WSDLPump.XSD_ELEMENT);
+ Element newElement = doc.createElementNS(WSDLPump.XMLSCHEMA_NAMESPACE_URI, WSDLPump.XSD_ELEMENT_QUALIFIED_NAME);
newElement.setAttribute(WSDLPump.XSD_NAME,
wsdl4jMessage.getQName().getLocalPart());
newElement.setAttribute(WSDLPump.XSD_TYPE,
"axis2wrapped:"+wsdl4jMessage.getQName().getLocalPart());
schemaElement.appendChild(newElement);
+
+ //////////////////////////////////////////////////////
+ // System.out.println("schema = " + schemaElement);
+ //////////////////////////////////////////////////////
+
//Now since a new type is created augmenting the parts add the QName
- //of the newly created type as the messageReference's name.
+ //of the newly created Element as the messageReference's name.
+ //coincidentally it'll be the messages QName!
+
referenceQName = 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 creating another type
//for the same message.
- this.resolvedMultipartMessageList.add(wsdl4jMessage.getQName());
+ this.resolvedMultipartMessageList.add(referenceQName);
}
} else {
@@ -733,7 +775,7 @@
//right now there's no known header binding!. Ignore the copying of values for now
component.addExtensibilityElement(soapHeaderExtensibilityElement);
}else if (ExtensionConstants.SOAP_12_BINDING.equals(unknown.getElementType())){
- org.apache.wsdl.extensions.SOAPBinding soapBindingExtensibiltyElement = (org.apache.wsdl.extensions.SOAPBinding) extensionFactory
+ org.apache.wsdl.extensions.SOAPBinding soapBindingExtensibiltyElement = (org.apache.wsdl.extensions.SOAPBinding) extensionFactory
.getExtensionElement(wsdl4jElement.getElementType());
Element element = unknown.getElement();
soapBindingExtensibiltyElement.setTransportURI(element.getAttribute("transport"));
@@ -741,7 +783,7 @@
component.addExtensibilityElement(soapBindingExtensibiltyElement);
} else if (ExtensionConstants.SOAP_12_ADDRESS.equals(unknown.getElementType())){
- org.apache.wsdl.extensions.SOAPAddress soapAddressExtensibiltyElement = (org.apache.wsdl.extensions.SOAPAddress) extensionFactory
+ org.apache.wsdl.extensions.SOAPAddress soapAddressExtensibiltyElement = (org.apache.wsdl.extensions.SOAPAddress) extensionFactory
.getExtensionElement(wsdl4jElement.getElementType());
Element element = unknown.getElement();
soapAddressExtensibiltyElement.setLocationURI(element.getAttribute("location"));
@@ -880,5 +922,9 @@
attribute.setValue(value);
component.addExtensibleAttributes(attribute);
}
+ }
+
+ private String getTemporaryNamespaceUri(){
+ return "urn:tempNs"+nsCount++ ;
}
}
Modified: webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/writer/WOMtoWSDL11Writer.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/writer/WOMtoWSDL11Writer.java?rev=320633&r1=320632&r2=320633&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/writer/WOMtoWSDL11Writer.java (original)
+++ webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/writer/WOMtoWSDL11Writer.java Wed Oct 12 20:38:45 2005
@@ -146,7 +146,7 @@
if (endPointMap!=null && !endPointMap.isEmpty()){
Iterator it = endPointMap.values().iterator();
while (it.hasNext()) {
- writePorttype((WSDLEndpoint)it.next(),writer);
+ writePort((WSDLEndpoint)it.next(),writer);
}
}
WriterUtil.writeEndElement("service",defaultWSDLPrefix,writer);
@@ -159,7 +159,7 @@
* @param endpoint
* @param outWriter
*/
- private void writePorttype(WSDLEndpoint endpoint,Writer outWriter) throws IOException{
+ private void writePort(WSDLEndpoint endpoint,Writer outWriter) throws IOException{
WriterUtil.writeStartElement("port",defaultWSDLPrefix,outWriter);
WriterUtil.writeAttribute("name",endpoint.getName().getLocalPart(),outWriter);
QName name = endpoint.getBinding().getName();
@@ -168,7 +168,7 @@
handleExtensibiltyElements(endpoint.getExtensibilityElements(),outWriter);
- WriterUtil.writeEndElement("port",outWriter);
+ WriterUtil.writeEndElement("port",defaultWSDLPrefix,outWriter);
}
/**
* Find the SOAPns prefix
@@ -518,15 +518,15 @@
WSDLBindingMessageReference input = bindingOp.getInput();
if (input!=null){
WriterUtil.writeStartElement(BINDING_INPUT,defaultWSDLPrefix,outWriter);
- WriterUtil.writeCompactEndElement(outWriter);
+ WriterUtil.writeCloseStartElement(outWriter);
handleExtensibiltyElements(input.getExtensibilityElements(),outWriter);
WriterUtil.writeEndElement(BINDING_INPUT,defaultWSDLPrefix,outWriter);
}
WSDLBindingMessageReference output = bindingOp.getInput();
- if (input!=null){
+ if (output!=null){
WriterUtil.writeStartElement(BINDING_OUTPUT,defaultWSDLPrefix,outWriter);
- WriterUtil.writeCompactEndElement(outWriter);
+ WriterUtil.writeCloseStartElement(outWriter);
handleExtensibiltyElements(output.getExtensibilityElements(),outWriter);
WriterUtil.writeEndElement(BINDING_OUTPUT,defaultWSDLPrefix,outWriter);
}
Modified: webservices/axis2/trunk/java/modules/wsdl/test-resources/BookQuote.wsdl
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/wsdl/test-resources/BookQuote.wsdl?rev=320633&r1=320632&r2=320633&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/wsdl/test-resources/BookQuote.wsdl (original)
+++ webservices/axis2/trunk/java/modules/wsdl/test-resources/BookQuote.wsdl Wed Oct 12 20:38:45 2005
@@ -22,10 +22,11 @@
<output message="mh:BookQuote_getBookPriceResponse"/>
</operation>
</portType>
+ <!-- this binding seems not to be completed -->
<binding name="BookQuoteBinding" type="mh:BookQuote">
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="getBookPrice">
- <soap:operation/>
+ <soap:operation />
<input>
<soap:body use="literal" namespace="http://www.Monson-Haefel.com/jwsbook/BookQuote/BookQuote"/>
</input>