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/10/10 04:20:32 UTC
svn commit: r312529 - in
/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/extensions:
SchemaUtility.java XMLBeans/XMLBeansSchemaUtility.java
Author: chinthaka
Date: Sun Oct 9 19:20:23 2005
New Revision: 312529
URL: http://svn.apache.org/viewcvs?rev=312529&view=rev
Log:
portType and message element generation seems to be completed. Schema generation seems still gives some problems with the WSDLWriter.
Modified:
webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/extensions/SchemaUtility.java
webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/extensions/XMLBeans/XMLBeansSchemaUtility.java
Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/extensions/SchemaUtility.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/extensions/SchemaUtility.java?rev=312529&r1=312528&r2=312529&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/extensions/SchemaUtility.java (original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/extensions/SchemaUtility.java Sun Oct 9 19:20:23 2005
@@ -36,20 +36,28 @@
* code was generated by him and reurns appropriate boolean depending on the result.
*
* @param serviceDescription
- * @return
+ * @return boolean
*/
public boolean isRelevant(ServiceDescription serviceDescription) throws AxisFault;
/**
* isRelevant() must be called before calling this method.
- * This will return the complete schema of the given service.
- *
+ * This will fill the given definition element with the information that can be extracted from
+ * the deployed service archive
* @param serviceDescription
- * @return
* @throws AxisFault
*/
- public void getSchema(ServiceDescription serviceDescription, Definition definition) throws AxisFault;
+ public void fillInformationFromServiceDescription(ServiceDescription serviceDescription, Definition definition) throws AxisFault;
+
+ /**
+ * isRelevant() must be called before calling this method.
+ * This will fill the given definition element with the information that can be extracted from
+ * the deployed service archive
+ * @param serviceDescription
+ * @return Definition
+ * @throws AxisFault
+ */
+ public Definition fillInformationFromServiceDescription(ServiceDescription serviceDescription) throws AxisFault;
- public void createMessagesAndPortTypes(ServiceDescription serviceDescription, Definition definition) throws AxisFault;
}
Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/extensions/XMLBeans/XMLBeansSchemaUtility.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/extensions/XMLBeans/XMLBeansSchemaUtility.java?rev=312529&r1=312528&r2=312529&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/extensions/XMLBeans/XMLBeansSchemaUtility.java (original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/extensions/XMLBeans/XMLBeansSchemaUtility.java Sun Oct 9 19:20:23 2005
@@ -1,5 +1,6 @@
package org.apache.axis2.databinding.extensions.XMLBeans;
+import com.ibm.wsdl.DefinitionImpl;
import com.ibm.wsdl.InputImpl;
import com.ibm.wsdl.MessageImpl;
import com.ibm.wsdl.OperationImpl;
@@ -64,6 +65,7 @@
public class XMLBeansSchemaUtility implements SchemaUtility {
protected Log log = LogFactory.getLog(getClass());
+ private Definition definition;
public boolean isRelevant(ServiceDescription serviceDescription) throws AxisFault {
try {
@@ -94,7 +96,23 @@
}
}
- public void getSchema(ServiceDescription serviceDescription, Definition definition) throws AxisFault {
+ public void fillInformationFromServiceDescription(ServiceDescription serviceDescription, Definition definition) throws AxisFault {
+ this.definition = definition;
+
+ // first fill the schema information
+ getSchema(serviceDescription);
+
+ // now fill port type and message elements
+ createMessagesAndPortTypes(serviceDescription);
+ }
+
+ public Definition fillInformationFromServiceDescription(ServiceDescription serviceDescription) throws AxisFault {
+ this.definition = new DefinitionImpl();
+ this.fillInformationFromServiceDescription(serviceDescription, this.definition);
+ return definition;
+ }
+
+ private void getSchema(ServiceDescription serviceDescription) throws AxisFault {
if (!isRelevant(serviceDescription)) {
return;
}
@@ -150,7 +168,7 @@
}
- public void createMessagesAndPortTypes(ServiceDescription serviceDescription, Definition definition) throws AxisFault {
+ private void createMessagesAndPortTypes(ServiceDescription serviceDescription) throws AxisFault {
HashMap mappings = readMappings(serviceDescription);
@@ -159,34 +177,40 @@
ClassLoader classLoader = serviceDescription.getClassLoader();
String serviceClassName = (String) serviceDescription.getParameter("ServiceClass").getValue();
+ // create PortType with class name
PortType portType = new PortTypeImpl();
portType.setQName(serviceDescription.getName());
definition.addPortType(portType);
+ portType.setUndefined(false);
Class serviceImplementation = classLoader.loadClass(serviceClassName);
Method[] methods = serviceImplementation.getMethods();
- Iterator operationDescIter = serviceDescription.getOperations().values().iterator();
-
+ // add messages to the definition and operations to the port type
Operation wsdlOperation;
Input wsdlOperationInput;
Output wsdlOperationOutput;
-
+ Iterator operationDescIter = serviceDescription.getOperations().values().iterator();
while (operationDescIter.hasNext()) {
OperationDescription operation = (OperationDescription) operationDescIter.next();
QName methodName = operation.getName();
Method method = getMethod(methods, methodName.getLocalPart());
- Class returnType = method.getReturnType();
-
+ // create operation
wsdlOperation = new OperationImpl();
wsdlOperation.setName(methodName.getLocalPart());
+ wsdlOperation.setUndefined(false);
+ // create Output message and add that to the definition
+ Class returnType = method.getReturnType();
Message message = getMessage(mappings, returnType);
definition.addMessage(message);
+
+ // add the same message as the output of the operation
wsdlOperationOutput = new OutputImpl();
wsdlOperationOutput.setMessage(message);
+ wsdlOperation.setOutput(wsdlOperationOutput);
Class[] parameterTypes = method.getParameterTypes();
for (int i = 0; i < parameterTypes.length; i++) {
@@ -195,12 +219,11 @@
wsdlOperationInput = new InputImpl();
wsdlOperationInput.setMessage(message);
definition.addMessage(message);
+ wsdlOperation.setInput(wsdlOperationInput);
}
portType.addOperation(wsdlOperation);
}
- portType.setUndefined(false);
-
} catch (ClassNotFoundException e) {
log.error("Can not load the service " + serviceDescription + " from the given class loader");
@@ -211,8 +234,12 @@
private Message getMessage(HashMap mappings, Class returnType) {
String mappingName = (String) mappings.get(returnType.getName());
+
+ // First create message
Message message = new MessageImpl();
message.setQName(new QName(mappingName));
+
+ // create the part of the message
Part part = new PartImpl();
part.setName("param");
part.setElementName(new QName(mappingName));
@@ -241,8 +268,6 @@
String javaclass = mappingElement.getFirstChildWithName(new QName(XMLBeansExtension.JAVA_NAME)).getText();
mappings.put(javaclass, messageName);
}
-
-
}
}
return mappings;