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 2006/02/08 11:44:06 UTC
svn commit: r375917 - in /webservices/axis2/trunk/java/modules:
adb/src/org/apache/axis2/databinding/utils/
codegen/src/org/apache/axis2/wsdl/codegen/
codegen/src/org/apache/axis2/wsdl/codegen/emitter/
codegen/src/org/apache/axis2/wsdl/codegen/extensio...
Author: ajith
Date: Wed Feb 8 02:44:04 2006
New Revision: 375917
URL: http://svn.apache.org/viewcvs?rev=375917&view=rev
Log:
Fixed a number of minor issues
1. The relative loading of schemas had a problem. Fixed the issue but improvements are possible
2. Fixed a possible bug in the SimpleElementReaderStateMachine.java
3. Halffway through unwrapping the schemas
Added:
webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/builder/SchemaUnwrapper.java
Modified:
webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/Constants.java
webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/SimpleElementReaderStateMachine.java
webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/CodeGenConfiguration.java
webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/CodeGenerationEngine.java
webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/emitter/JavaEmitter.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/wsdl/src/org/apache/axis2/wsdl/builder/wsdl4j/WSDL1ToWOMBuilder.java
Modified: webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/Constants.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/Constants.java?rev=375917&r1=375916&r2=375917&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/Constants.java (original)
+++ webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/Constants.java Wed Feb 8 02:44:04 2006
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
+
public interface Constants {
static String NIL="nil";
Modified: webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/SimpleElementReaderStateMachine.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/SimpleElementReaderStateMachine.java?rev=375917&r1=375916&r2=375917&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/SimpleElementReaderStateMachine.java (original)
+++ webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/SimpleElementReaderStateMachine.java Wed Feb 8 02:44:04 2006
@@ -77,12 +77,12 @@
//test for the nillable attribute
if (currentState==START_ELEMENT_FOUND_STATE &&
- nillable){
- if (TRUE.equals(reader.getAttributeValue("",NIL))){
- text = null;
- //force the state to be null found
- currentState= NULLED_STATE;
- }
+ nillable){
+ if (TRUE.equals(reader.getAttributeValue("",NIL))){
+ text = null;
+ //force the state to be null found
+ currentState= NULLED_STATE;
+ }
}
if (currentState==TEXT_FOUND_STATE){
@@ -114,23 +114,34 @@
//start_document found at init
if (event==XMLStreamConstants.START_DOCUMENT && currentState==INIT_STATE){
currentState = STARTED_STATE;
- //start element found at init
+ //start element found at init
}else if (event==XMLStreamConstants.START_ELEMENT && currentState==INIT_STATE){
if (elementNameToTest.equals(reader.getName())){
currentState = START_ELEMENT_FOUND_STATE;
}else{
currentState = STARTED_STATE;
}
- //start element found after started
+ //start element found after started
}else if (event==XMLStreamConstants.START_ELEMENT && currentState==STARTED_STATE) {
if (elementNameToTest.equals(reader.getName())){
currentState = START_ELEMENT_FOUND_STATE;
}
- //characteres found after starting
+ //characteres found after starting
}else if (event==XMLStreamConstants.CHARACTERS && currentState==START_ELEMENT_FOUND_STATE){
currentState = TEXT_FOUND_STATE;
- // end element found after characters
+ //End element found after starting This means we've found an empty element like <foo/>
+ }else if (event==XMLStreamConstants.END_ELEMENT && currentState==START_ELEMENT_FOUND_STATE){
+ //force the text to be empty!
+ text = "";
+
+ if (elementNameToTest.equals(reader.getName())){
+ currentState = END_ELEMENT_FOUND_STATE;
+ }else{
+ currentState = ILLEGAL_STATE;
+ }
+
+ // end element found after characters
} else if (event==XMLStreamConstants.END_ELEMENT && currentState==TEXT_FOUND_STATE){
if (elementNameToTest.equals(reader.getName())){
currentState = END_ELEMENT_FOUND_STATE;
@@ -138,19 +149,19 @@
currentState = ILLEGAL_STATE;
}
- //end has been reached
+ //end has been reached
}else if (currentState==END_ELEMENT_FOUND_STATE) {
currentState = FINISHED_STATE;
- //the element was found to be null and this state was forced.
- //we are sure here that the parser was at the START_ELEMENT_FOUND_STATE before
- //being forced. Hence we need to advance the parser upto the end element and
- //set the state to be end element found
+ //the element was found to be null and this state was forced.
+ //we are sure here that the parser was at the START_ELEMENT_FOUND_STATE before
+ //being forced. Hence we need to advance the parser upto the end element and
+ //set the state to be end element found
}else if (currentState==NULLED_STATE){
- while (event!= XMLStreamConstants.END_ELEMENT){
- event=reader.next();
- }
- currentState = END_ELEMENT_FOUND_STATE;
- //all other combinations are invalid
+ while (event!= XMLStreamConstants.END_ELEMENT){
+ event=reader.next();
+ }
+ currentState = END_ELEMENT_FOUND_STATE;
+ //all other combinations are invalid
}else{
currentState = ILLEGAL_STATE;
Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/CodeGenConfiguration.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/CodeGenConfiguration.java?rev=375917&r1=375916&r2=375917&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/CodeGenConfiguration.java (original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/CodeGenConfiguration.java Wed Feb 8 02:44:04 2006
@@ -31,6 +31,24 @@
private WSDLDescription wom;
+ private String baseURI;
+
+ public String getBaseURI() {
+ return baseURI;
+ }
+
+ public void setBaseURI(String baseURI) {
+ this.baseURI = baseURI;
+ }
+
+ public Map getConfigurationProperties() {
+ return configurationProperties;
+ }
+
+ public void setConfigurationProperties(Map configurationProperties) {
+ this.configurationProperties = configurationProperties;
+ }
+
public void setWom(WSDLDescription wom) {
this.wom = wom;
}
Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/CodeGenerationEngine.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/CodeGenerationEngine.java?rev=375917&r1=375916&r2=375917&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/CodeGenerationEngine.java (original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/CodeGenerationEngine.java Wed Feb 8 02:44:04 2006
@@ -33,6 +33,8 @@
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
+import java.net.URI;
+import java.io.File;
public class CodeGenerationEngine {
private Log log = LogFactory.getLog(getClass());
@@ -42,23 +44,36 @@
private CodeGenConfiguration configuration;
+ /**
+ *
+ * @param configuration
+ * @throws CodeGenerationException
+ */
public CodeGenerationEngine(CodeGenConfiguration configuration) throws CodeGenerationException {
this.configuration = configuration;
loadExtensions();
}
+ /**
+ *
+ * @param parser
+ * @throws CodeGenerationException
+ */
public CodeGenerationEngine(CommandLineOptionParser parser) throws CodeGenerationException {
WSDLDescription wom;
Map allOptions = parser.getAllOptions();
+ String wsdlUri;
try {
CommandLineOption option = (CommandLineOption)allOptions.get(CommandLineOptionConstants.WSDL2JavaConstants.WSDL_LOCATION_URI_OPTION);
- wom = this.getWOM(option.getOptionValue());
+ wsdlUri = option.getOptionValue();
+ wom = this.getWOM(wsdlUri);
} catch (WSDLException e) {
throw new CodeGenerationException(CodegenMessages.getMessage("engine.wsdlParsingException"), e);
}
configuration = new CodeGenConfiguration(wom, allOptions);
+ configuration.setBaseURI(getBaseURI(wsdlUri));
loadExtensions();
}
@@ -135,9 +150,15 @@
}
+ /**
+ *
+ * @param uri
+ * @return
+ * @throws WSDLException
+ */
private WSDLDescription getWOM(String uri) throws WSDLException {
//assume that the builder is always WSDL 1.1 - later we'll have to edit this to allow
- //WSDL ersion to be passed
+ //WSDL version to be passed
return WOMBuilderFactory.getBuilder(org.apache.wsdl.WSDLConstants.WSDL_1_1).build(uri)
.getDescription();
}
@@ -166,5 +187,23 @@
throw new CodeGenerationException(e);
}
+ }
+
+ /**
+ * calculates the base URI
+ * Needs improvement but works fine for now ;)
+ * @param currentURI
+ * @return
+ */
+ private String getBaseURI(String currentURI){
+ String baseURI= null;
+ if(currentURI.startsWith("http://")){
+ // current URI is a remote one
+ baseURI = currentURI.substring(0,currentURI.lastIndexOf("/"));
+ }else{
+ // the uri should be a file
+ baseURI = new File(currentURI).getParentFile().getAbsolutePath();
+ }
+ return baseURI;
}
}
Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/emitter/JavaEmitter.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/emitter/JavaEmitter.java?rev=375917&r1=375916&r2=375917&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/emitter/JavaEmitter.java (original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/emitter/JavaEmitter.java Wed Feb 8 02:44:04 2006
@@ -19,19 +19,25 @@
import org.apache.axis2.wsdl.codegen.CodeGenConfiguration;
import org.apache.axis2.wsdl.databinding.DefaultTypeMapper;
import org.apache.axis2.wsdl.databinding.TypeMapper;
+import org.apache.axis2.wsdl.builder.SchemaUnwrapper;
public class JavaEmitter extends MultiLanguageClientEmitter {
public JavaEmitter() {
+ super();
}
/**
* @param configuration
*/
public JavaEmitter(CodeGenConfiguration configuration) {
+ super();
this.configuration = configuration;
this.mapper = new DefaultTypeMapper();
+
+
+
}
/**
@@ -39,8 +45,11 @@
* @param mapper
*/
public JavaEmitter(CodeGenConfiguration configuration, TypeMapper mapper) {
+ super();
this.configuration = configuration;
this.mapper = mapper;
+
+
}
}
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=375917&r1=375916&r2=375917&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 Feb 8 02:44:04 2006
@@ -35,6 +35,7 @@
import org.apache.axis2.wsdl.i18n.CodegenMessages;
import org.apache.axis2.wsdl.util.XSLTConstants;
import org.apache.axis2.wsdl.util.XSLTIncludeResolver;
+import org.apache.axis2.wsdl.builder.SchemaUnwrapper;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.wsdl.MessageReference;
@@ -142,7 +143,7 @@
/**
* This information holder keeps the necessary information of
- * what to codegen. The service, port, binding (and the porttype)
+ * what to codegen. The service, port, binding (and the WSDLinterface)
* if the service and binding tags are missing then only the
* portype wil be there
* This will get populated before executing any code generation
@@ -152,6 +153,11 @@
protected TypeMapper mapper;
protected URIResolver resolver;
+
+ protected MultiLanguageClientEmitter() {
+ // put whatever is needed here
+ }
+
//~--- methods ------------------------------------------------------------
/**
@@ -321,7 +327,7 @@
* Creates the DOM tree for the Ant build. Uses the interface.
*/
protected Document createDOMDocumentForAntBuild() {
- WSDLInterface wsdlInterface = infoHolder.getPorttype();
+ WSDLInterface wsdlInterface = infoHolder.getWSDLinterface();
WSDLService service = infoHolder.getService();
Document doc = getEmptyDocument();
Element rootElement = doc.createElement("ant");
@@ -349,7 +355,7 @@
*/
protected Document createDOMDocumentForCallbackHandler() {
Document doc = getEmptyDocument();
- WSDLInterface boundInterface = infoHolder.getPorttype();
+ WSDLInterface boundInterface = infoHolder.getWSDLinterface();
WSDLBinding axisBinding = infoHolder.getBinding();
Element rootElement = doc.createElement("callback");
@@ -371,7 +377,7 @@
*/
protected Document createDOMDocumentForInterface(boolean writeDatabinders) {
Document doc = getEmptyDocument();
- WSDLInterface wsdlInterface = infoHolder.getPorttype();
+ WSDLInterface wsdlInterface = infoHolder.getWSDLinterface();
WSDLBinding axisBinding = infoHolder.getBinding();
Element rootElement = doc.createElement("interface");
String localPart = getCoreClassName(wsdlInterface);
@@ -409,7 +415,7 @@
* Creates the DOM tree for implementations.
*/
protected Document createDOMDocumentForInterfaceImplementation() throws Exception {
- WSDLInterface boundInterface = infoHolder.getPorttype();
+ WSDLInterface boundInterface = infoHolder.getWSDLinterface();
WSDLBinding binding = infoHolder.getBinding();
String packageName = configuration.getPackageName();
String localPart = getCoreClassName(boundInterface);
@@ -466,7 +472,7 @@
}
protected Document createDOMDocumentForServiceXML() {
- WSDLInterface boundInterface = infoHolder.getPorttype();
+ WSDLInterface boundInterface = infoHolder.getWSDLinterface();
WSDLBinding axisBinding = infoHolder.getBinding();
WSDLService service = infoHolder.getService();
Document doc = getEmptyDocument();
@@ -478,7 +484,7 @@
axisBinding));
} else {
- // service is missing. However we can derive a service name from the porttype
+ // service is missing. However we can derive a service name from the WSDLinterface
doc.appendChild(getServiceElement(boundInterface.getName().getLocalPart(), coreClassName, doc,
boundInterface, axisBinding));
}
@@ -494,7 +500,7 @@
protected Document createDOMDocumentForSkeleton() {
Document doc = getEmptyDocument();
Element rootElement = doc.createElement("interface");
- WSDLInterface boundInterface = infoHolder.getPorttype();
+ WSDLInterface boundInterface = infoHolder.getWSDLinterface();
WSDLBinding axisBinding = infoHolder.getBinding();
// name the skeleton after the binding's name !
@@ -512,7 +518,7 @@
}
protected Document createDOMDocumentForTestCase() {
- WSDLInterface boundInterface = infoHolder.getPorttype();
+ WSDLInterface boundInterface = infoHolder.getWSDLinterface();
WSDLBinding binding = infoHolder.getBinding();
String localPart = getCoreClassName(boundInterface);
Document doc = getEmptyDocument();
@@ -609,7 +615,7 @@
protected Document createDocumentForMessageReceiver(String mep) {
WSDLBinding binding = infoHolder.getBinding();
- WSDLInterface boundInterface = infoHolder.getPorttype();
+ WSDLInterface boundInterface = infoHolder.getWSDLinterface();
Document doc = getEmptyDocument();
Element rootElement = doc.createElement("interface");
@@ -699,7 +705,7 @@
axisBinding = infoHolder.getBinding();
- WSDLInterface wsInterface = infoHolder.getPorttype();
+ WSDLInterface wsInterface = infoHolder.getWSDLinterface();
if (axisBinding == null) {
@@ -751,6 +757,9 @@
* @see org.apache.axis2.wsdl.codegen.emitter.Emitter#emitStub()
*/
public void emitStub() throws CodeGenerationException {
+
+ SchemaUnwrapper.unwrap(configuration.getWom());
+
try {
// get the interface
@@ -792,7 +801,7 @@
* @throws Exception
*/
private void emitStubBinding() throws Exception {
- WSDLInterface axisInterface = infoHolder.getPorttype();
+ WSDLInterface axisInterface = infoHolder.getWSDLinterface();
// see the comment at updateMapperClassnames for details and reasons for
// calling this method
@@ -830,7 +839,7 @@
* @throws Exception
*/
private void emitStubInterface() throws Exception {
- WSDLInterface axisInterface = infoHolder.getPorttype();
+ WSDLInterface axisInterface = infoHolder.getWSDLinterface();
if (mapper.isObjectMappingPresent()) {
updateMapperForInterface(axisInterface);
@@ -1062,7 +1071,7 @@
WSDLBinding binding = selectedEndpoint.getBinding();
infoHolder.setBinding(binding);
- infoHolder.setPorttype(binding.getBoundInterface());
+ infoHolder.setWSDLinterface(binding.getBoundInterface());
} else {
// having no endpoints?? this is surely an exception
@@ -1089,7 +1098,7 @@
Iterator porttypeIterator = wsdlInterfaces.values().iterator();
- info.setPorttype((WSDLInterface) porttypeIterator.next());
+ info.setWSDLinterface((WSDLInterface) porttypeIterator.next());
}
}
@@ -1599,12 +1608,12 @@
/**
* A simple class for keeping the information of the
- * relevant service/port/binding/porttype combination
+ * relevant service/port/binding/WSDLinterface combination
*/
private class InformationHolder {
private WSDLBinding binding;
private WSDLEndpoint port;
- private WSDLInterface porttype;
+ private WSDLInterface WSDLinterface;
private WSDLService service;
private HashMap propertyMap = new HashMap();
@@ -1626,8 +1635,8 @@
return port;
}
- public WSDLInterface getPorttype() {
- return porttype;
+ public WSDLInterface getWSDLinterface() {
+ return WSDLinterface;
}
public WSDLService getService() {
@@ -1644,8 +1653,8 @@
this.port = port;
}
- public void setPorttype(WSDLInterface porttype) {
- this.porttype = porttype;
+ public void setWSDLinterface(WSDLInterface WSDLinterface) {
+ this.WSDLinterface = WSDLinterface;
}
public void setService(WSDLService service) {
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=375917&r1=375916&r2=375917&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 Feb 8 02:44:04 2006
@@ -43,6 +43,9 @@
*/
public class SimpleDBExtension extends AbstractDBProcessingExtension {
+ /**
+ *
+ */
public void engage() {
//test the databinding type. If not just fall through
if (testFallThrough(configuration.getDatabindingType())) {
@@ -63,6 +66,13 @@
WSDLExtensibilityElement extensiblityElt;
Vector xmlSchemaTypeVector = new Vector();
XmlSchemaCollection schemaColl = new XmlSchemaCollection();
+ //add the base uri
+ if (configuration.getBaseURI()!=null){
+ schemaColl.setBaseUri(configuration.getBaseURI());
+ }
+
+
+
for (int i = 0; i < typesArray.size(); i++) {
extensiblityElt = (WSDLExtensibilityElement) typesArray.get(i);
@@ -154,6 +164,10 @@
}
+ /**
+ *
+ * @param options
+ */
private void setUserparameters(CompilerOptions options){
Map propertyMap = configuration.getProperties();
if (propertyMap.containsKey(SchemaConstants.SchemaCompilerArguments.WRAP_SCHEMA_CLASSES)){
@@ -178,6 +192,10 @@
}
+ /**
+ *
+ * @param options
+ */
private void setDefaultOptions(CompilerOptions options) {
File outputDir = new File(configuration.getOutputLocation(), "src");
if(!outputDir.exists()) {
Added: webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/builder/SchemaUnwrapper.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/builder/SchemaUnwrapper.java?rev=375917&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/builder/SchemaUnwrapper.java (added)
+++ webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/builder/SchemaUnwrapper.java Wed Feb 8 02:44:04 2006
@@ -0,0 +1,87 @@
+package org.apache.axis2.wsdl.builder;
+
+import org.apache.wsdl.WSDLDescription;
+import org.apache.wsdl.WSDLBinding;
+import org.apache.wsdl.WSDLInterface;
+import org.apache.wsdl.WSDLOperation;
+import org.apache.ws.commons.schema.XmlSchemaElement;
+
+import java.util.Map;
+/*
+ * 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
+ *
+ * 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.
+ */
+
+/**
+ * The purpose of the schema unwrapper is to walk the schema and figure out
+ * the expandable items. The schema unwrapper works off the WOM and attaches
+ * the unwrapping information to the metadata bags of the relevant messageReference
+ * objects
+ */
+public class SchemaUnwrapper {
+
+ public static void unwrap(WSDLDescription description){
+ //first start with the bindings (if present), else we
+ //switch back to the interfaces list
+ //BTW we use the WSDL 2.0 terminology here
+
+ Map bindings = description.getBindings();
+ Map interfaces = description.getWsdlInterfaces();
+
+ if (bindings != null && !bindings.isEmpty()){
+ //process bindings
+ WSDLBinding[] bindingsArray = (WSDLBinding[])
+ bindings.values().toArray(new WSDLBinding[bindings.size()]);
+ for (int i = 0; i < bindingsArray.length; i++) {
+ unwrapSchemaForInterface(bindingsArray[i].getBoundInterface(),description);
+
+ }
+
+ }else if (interfaces!=null && !interfaces.isEmpty()){
+ //process the interfaces (porttypes)
+ WSDLInterface[] interfacesArray = (WSDLInterface[])
+ interfaces.values().toArray(new WSDLInterface[interfaces.size()]);
+ for (int i = 0; i < interfacesArray.length; i++) {
+ unwrapSchemaForInterface(interfacesArray[i],description);
+ }
+
+
+ }
+
+ }
+
+ /**
+ * Process a single wsdlInterface
+ * @param wsdlInterface
+ * @param decription
+ */
+ private static void unwrapSchemaForInterface(WSDLInterface wsdlInterface,WSDLDescription decription){
+
+ Map operationsMap = wsdlInterface.getOperations();
+ if (!operationsMap.isEmpty()){
+ WSDLOperation[] operations = (WSDLOperation[])
+ operationsMap.values().toArray(new WSDLOperation[operationsMap.size()]);
+ WSDLOperation operation;
+ for (int i = 0; i < operations.length; i++) {
+ operation = operations[i];
+ //process Schema
+ XmlSchemaElement elt = operation.getInputMessage().getElementSchema();
+ System.out.println("elt = " + elt);
+ }
+ }
+
+
+ }
+
+}
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=375917&r1=375916&r2=375917&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 Feb 8 02:44:04 2006
@@ -20,6 +20,7 @@
import org.apache.axis2.wsdl.WSDLVersionWrapper;
import org.apache.axis2.wsdl.builder.WOMBuilder;
import org.apache.axis2.wsdl.builder.WSDLComponentFactory;
+import org.apache.axis2.wsdl.builder.SchemaUnwrapper;
import org.apache.wsdl.WSDLDescription;
import org.apache.wsdl.impl.WSDLDescriptionImpl;
import org.w3c.dom.Document;
@@ -77,8 +78,6 @@
pump.pump();
-
-
return new WSDLVersionWrapper(wsdlDescription, wsdl1Definition);
}
@@ -144,7 +143,14 @@
reader.setFeature("javax.wsdl.importDocuments", true);
File file = new File(uri);
- String baseURI = file.getParentFile()!=null?file.getParentFile().toURI().toString():null;
+ String baseURI;
+
+ if (uri.startsWith("http://")){
+ baseURI = uri;
+ } else{
+ baseURI = file.getParentFile()!=null?file.getParentFile().toURI().toString():null;
+ }
+
Document doc;
try {