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 di...@apache.org on 2009/02/07 15:18:14 UTC
svn commit: r741899 - in /webservices/axis2/trunk/java/modules:
adb-codegen/src/org/apache/axis2/schema/writer/
codegen/src/org/apache/axis2/wsdl/codegen/emitter/
codegen/src/org/apache/axis2/wsdl/template/c/
Author: dimuthu
Date: Sat Feb 7 14:18:13 2009
New Revision: 741899
URL: http://svn.apache.org/viewvc?rev=741899&view=rev
Log:
templates and codes to support custom faults for axis2/c generated code, fixing jira issue AXIS2C-1344, https://issues.apache.org/jira/browse/AXIS2C-1344
Modified:
webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/writer/CStructWriter.java
webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/emitter/CEmitter.java
webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/c/ServiceSkeleton.xsl
webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/c/SkelHeaderTemplate.xsl
webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/c/SkelSourceTemplate.xsl
webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/c/StubHeaderTemplate.xsl
webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/c/StubSourceTemplate.xsl
Modified: webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/writer/CStructWriter.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/writer/CStructWriter.java?rev=741899&r1=741898&r2=741899&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/writer/CStructWriter.java (original)
+++ webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/writer/CStructWriter.java Sat Feb 7 14:18:13 2009
@@ -55,7 +55,7 @@
import java.util.List;
import java.util.Map;
-import com.ibm.wsdl.util.xml.DOM2Writer;
+//import com.ibm.wsdl.util.xml.DOM2Writer;
/**
* Java Bean writer for the schema compiler.
Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/emitter/CEmitter.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/emitter/CEmitter.java?rev=741899&r1=741898&r2=741899&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/emitter/CEmitter.java (original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/emitter/CEmitter.java Sat Feb 7 14:18:13 2009
@@ -49,11 +49,9 @@
import javax.xml.namespace.QName;
import java.io.File;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
+import java.util.*;
-import com.ibm.wsdl.util.xml.DOM2Writer;
+// import com.ibm.wsdl.util.xml.DOM2Writer;
public class CEmitter extends AxisServiceBasedMultiLanguageEmitter {
protected static final String C_STUB_PREFIX = "axis2_stub_";
@@ -235,6 +233,7 @@
Element rootElement = doc.createElement("class");
addAttribute(doc, "name", stubName, rootElement);
+ addAttribute(doc, "caps-name", stubName.toUpperCase(), rootElement);
addAttribute(doc, "prefix", stubName, rootElement); //prefix to be used by the functions
addAttribute(doc, "qname", serviceName + "|" + serviceTns, rootElement);
addAttribute(doc, "servicename", serviceCName, rootElement);
@@ -312,6 +311,7 @@
// only the name is used
addAttribute(doc, "name", skelName, rootElement);
+ addAttribute(doc, "caps-name", skelName.toUpperCase(), rootElement);
addAttribute(doc, "package", "", rootElement);
String serviceName = axisService.getName();
String serviceTns = axisService.getTargetNamespace();
@@ -326,6 +326,12 @@
rootElement.appendChild(getUniqueListofFaults(doc));
doc.appendChild(rootElement);
+
+
+ /////////////////////////////////////////////////////
+ // System.out.println(DOM2Writer.nodeToString(rootElement));
+ /////////////////////////////////////////////////////
+
return doc;
}
@@ -340,6 +346,7 @@
// only the name is used
addAttribute(doc, "name", svcSkelName, rootElement);
+ addAttribute(doc, "caps-svc-name", skelName.toUpperCase(), rootElement);
addAttribute(doc, "prefix", svcSkelName, rootElement); //prefix to be used by the functions
String serviceName = axisService.getName();
String serviceTns = axisService.getTargetNamespace();
@@ -454,6 +461,7 @@
String opNS = axisOperation.getName().getNamespaceURI();
addAttribute(doc, "name", opCName, methodElement);
+ addAttribute(doc, "caps-name", opCName.toUpperCase(), methodElement);
addAttribute(doc, "localpart", localPart, methodElement);
addAttribute(doc, "qname", localPart + "|" + opNS, methodElement);
@@ -510,6 +518,7 @@
String opNS = axisOperation.getName().getNamespaceURI();
addAttribute(doc, "name", opCName, methodElement);
+ addAttribute(doc, "caps-name", opCName.toUpperCase(), methodElement);
addAttribute(doc, "localpart", localPart, methodElement);
addAttribute(doc, "qname", localPart + "|" + opNS, methodElement);
@@ -792,6 +801,178 @@
}
/**
+ * A util method that returns a unique list of faults for a given mep
+ *
+ * @param doc
+ * @return DOM element
+ */
+ protected Element getUniqueListofFaultsofMep(Document doc, String mep) {
+
+ // list to keep fault message qnames for this mep
+ Set faultListForMep = new HashSet();
+
+ Iterator iter = this.axisService.getOperations();
+ AxisOperation axisOperation;
+
+ for (; iter.hasNext();) {
+ axisOperation = (AxisOperation) iter.next();
+ if (mep == null) {
+ // add the fault messages
+ addFaultMessages(axisOperation.getFaultMessages(), faultListForMep);
+ } else {
+ if (mep.equals(axisOperation.getMessageExchangePattern())) {
+ // add the fault messages
+ addFaultMessages(axisOperation.getFaultMessages(), faultListForMep);
+ }
+ }
+ }
+
+ Element rootElement = doc.createElement("fault-list");
+ Element faultElement;
+ String key;
+ Iterator iterator = faultListForMep.iterator();
+ while (iterator.hasNext()) {
+ faultElement = doc.createElement("fault");
+ key = (String) iterator.next();
+
+ //as for the name of a fault, we generate an exception
+ addAttribute(doc, "name",
+ (String) fullyQualifiedFaultClassNameMap.get(key),
+ faultElement);
+ addAttribute(doc, "shortName",
+ (String) faultClassNameMap.get(key),
+ faultElement);
+
+ //the type represents the type that will be wrapped by this
+ //name
+ String typeMapping =
+ this.mapper.getTypeMappingName((QName) faultElementQNameMap.get(key));
+ addAttribute(doc, "type", (typeMapping == null)
+ ? ""
+ : typeMapping, faultElement);
+ String attribValue = (String) instantiatableMessageClassNames.
+ get(key);
+
+ addAttribute(doc, "instantiatableType",
+ attribValue == null ? "" : attribValue,
+ faultElement);
+
+ String exceptionName = ((QName) faultElementQNameMap.get(key)).getLocalPart();
+ addAttribute(doc, "localname",
+ exceptionName == null ? "" : exceptionName,
+ faultElement);
+
+ addAttribute(doc, "caps-localname",
+ exceptionName == null ? "" : exceptionName.toUpperCase(),
+ faultElement);
+
+ // add an extra attribute to say whether the type mapping is
+ // the default
+ if (mapper.getDefaultMappingName().equals(typeMapping)) {
+ addAttribute(doc, "default", "yes", faultElement);
+ }
+ addAttribute(doc, "value", getParamInitializer(typeMapping),
+ faultElement);
+
+
+ rootElement.appendChild(faultElement);
+ }
+ return rootElement;
+ }
+
+
+ /**
+ * @param doc
+ * @param operation
+ * @return Returns the parameter element.
+ */
+ protected Element[] getFaultParamElements(Document doc, AxisOperation operation) {
+ ArrayList params = new ArrayList();
+ ArrayList faultMessages = operation.getFaultMessages();
+
+ if (faultMessages != null && !faultMessages.isEmpty()) {
+ Element paramElement;
+ AxisMessage msg;
+ for (int i = 0; i < faultMessages.size(); i++) {
+ paramElement = doc.createElement("param");
+ msg = (AxisMessage) faultMessages.get(i);
+
+ if (msg.getElementQName() == null) {
+ throw new RuntimeException("Element QName is null for " + msg.getName() + "!");
+ }
+
+ //as for the name of a fault, we generate an exception
+ String faultComment = "";
+ if (msg.getDocumentation() != null){
+ faultComment = msg.getDocumentation().trim();
+ }
+ addAttribute(doc, "comment", faultComment, paramElement);
+ addAttribute(doc, "name",
+ (String) fullyQualifiedFaultClassNameMap.get(msg.getName()),
+ paramElement);
+ addAttribute(doc, "shortName",
+ (String) faultClassNameMap.get(msg.getName()),
+ paramElement);
+
+ // attach the namespace and the localName
+ addAttribute(doc, "namespace",
+ msg.getElementQName().getNamespaceURI(),
+ paramElement);
+ addAttribute(doc, "localname",
+ msg.getElementQName().getLocalPart(),
+ paramElement);
+ addAttribute(doc, "caps-localname",
+ msg.getElementQName().getLocalPart().toUpperCase(),
+ paramElement);
+
+ if (msg.getElementQName() != null) {
+ Element qNameElement = doc.createElement("qname");
+ addAttribute(doc, "nsuri", msg.getElementQName().getNamespaceURI(), qNameElement);
+ addAttribute(doc, "localname", msg.getElementQName().getLocalPart(), qNameElement);
+ paramElement.appendChild(qNameElement);
+ }
+ //the type represents the type that will be wrapped by this
+ //name
+ String typeMapping =
+ this.mapper.getTypeMappingName(msg.getElementQName());
+ addAttribute(doc, "type", (typeMapping == null)
+ ? ""
+ : typeMapping, paramElement);
+
+ //add the short name
+ addShortType(paramElement, (msg.getElementQName() == null) ? null :
+ msg.getElementQName().getLocalPart());
+
+ String attribValue = (String) instantiatableMessageClassNames.
+ get(msg.getElementQName());
+ addAttribute(doc, "instantiatableType",
+ attribValue == null ? "" : attribValue,
+ paramElement);
+
+ // add an extra attribute to say whether the type mapping is
+ // the default
+ if (mapper.getDefaultMappingName().equals(typeMapping)) {
+ addAttribute(doc, "default", "yes", paramElement);
+ }
+ addAttribute(doc, "value", getParamInitializer(typeMapping),
+ paramElement);
+
+ Iterator iter = msg.getExtensibilityAttributes().iterator();
+ while (iter.hasNext()) {
+ // process extensibility attributes
+ }
+ params.add(paramElement);
+ }
+
+ return (Element[]) params.toArray(new Element[params.size()]);
+ } else {
+ return new Element[]{};//return empty array
+ }
+
+
+ }
+
+ /**
* Finds the output element.
*
* @param doc
Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/c/ServiceSkeleton.xsl
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/c/ServiceSkeleton.xsl?rev=741899&r1=741898&r2=741899&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/c/ServiceSkeleton.xsl (original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/c/ServiceSkeleton.xsl Sat Feb 7 14:18:13 2009
@@ -23,6 +23,7 @@
<!--Template for in out message receiver -->
<xsl:template match="/interface">
<xsl:variable name="skeletonname"><xsl:value-of select="@name"/></xsl:variable>
+ <xsl:variable name="caps_svc_name"><xsl:value-of select="@caps-svc-name"/></xsl:variable>
<xsl:variable name="qname"><xsl:value-of select="@qname"/></xsl:variable>
<xsl:variable name="method-prefix"><xsl:value-of select="@prefix"/></xsl:variable>
<xsl:variable name="svcop-prefix"><xsl:value-of select="@svcop_prefix"/></xsl:variable>
@@ -46,6 +47,23 @@
#ifdef __cplusplus
extern "C" {
#endif
+
+
+ /**
+ * creating a custom structure to wrap the axis2_svc_skeleton class
+ */
+ typedef struct {
+ axis2_svc_skeleton_t svc_skeleton;
+
+ /* union to keep all the exception objects */
+ union {
+ <xsl:for-each select="method">
+ <xsl:if test="fault">
+ <xsl:value-of select="$servicename"/>_<xsl:value-of select="@name"/><xsl:text>_fault </xsl:text> <xsl:value-of select="@name"/>_fault;
+ </xsl:if>
+ </xsl:for-each>
+ } fault;
+ }<xsl:value-of select="$method-prefix"/>_t;
/**
* functions prototypes
@@ -85,7 +103,6 @@
};
-
/**
* Following block distinguish the exposed part of the dll.
* create the instance
@@ -148,13 +165,16 @@
axis2_svc_skeleton_t* AXIS2_CALL
<xsl:value-of select="$method-prefix"/>_create(const axutil_env_t *env)
{
+ <xsl:value-of select="$method-prefix"/>_t *svc_skeleton_wrapper = NULL;
axis2_svc_skeleton_t *svc_skeleton = NULL;
+
/* Allocate memory for the structs */
- svc_skeleton = (axis2_svc_skeleton_t *)AXIS2_MALLOC(env->allocator,
- sizeof(axis2_svc_skeleton_t));
+ svc_skeleton_wrapper = (<xsl:value-of select="$method-prefix"/>_t *)AXIS2_MALLOC(env->allocator,
+ sizeof(<xsl:value-of select="$method-prefix"/>_t));
- svc_skeleton->ops = &<xsl:value-of select="$skeletonname"/>_svc_skeleton_ops_var;
+ svc_skeleton = (axis2_svc_skeleton_t*)svc_skeleton_wrapper;
+ svc_skeleton->ops = &<xsl:value-of select="$skeletonname"/>_svc_skeleton_ops_var;
return svc_skeleton;
}
@@ -164,7 +184,7 @@
<xsl:value-of select="$method-prefix"/>_init(axis2_svc_skeleton_t *svc_skeleton,
const axutil_env_t *env)
{
- /* Any initialization stuff of <xsl:value-of select="$svcname"/> goes here */
+ /* Nothing special in initialization <xsl:value-of select="$svcname"/> */
return AXIS2_SUCCESS;
}
@@ -365,7 +385,11 @@
axiom_node_t *input_header = NULL;
axiom_node_t *output_header = NULL;
axiom_node_t *header_base_node = NULL;
+
+ <xsl:value-of select="$method-prefix"/>_t *svc_skeleton_wrapper = NULL;
+ svc_skeleton_wrapper = (<xsl:value-of select="$method-prefix"/>_t*)svc_skeleton;
+
<xsl:for-each select="method">
<xsl:text>
</xsl:text>
@@ -537,7 +561,8 @@
<xsl:value-of select="$outputparam_types"/> ret_unwrapped = <xsl:value-of select="$svcop-prefix"/>_<xsl:value-of select="$method-name"/><xsl:text>(env</xsl:text>
<xsl:value-of select="$inputparam_values"/><xsl:for-each select="output/param[@location='soap_header']">,
<xsl:text>&_</xsl:text><xsl:value-of select="@name"/><xsl:value-of select="$position"/>
- </xsl:for-each>);
+ </xsl:for-each><xsl:if test="fault">,
+ (<xsl:value-of select="$servicename"/>_<xsl:value-of select="@name"/><xsl:text>_fault*</xsl:text>)&(svc_skeleton_wrapper->fault)</xsl:if>);
<xsl:choose>
<xsl:when test="output/param/@complextype">
ret_val<xsl:value-of select="$position"/> = <xsl:value-of select="substring-before(output/param/@type, '_t*')"/>_create_with_values(env,
@@ -569,15 +594,14 @@
ret_val<xsl:value-of select="$position"/> = <xsl:value-of select="$svcop-prefix"/>_<xsl:value-of select="$method-name"/><xsl:text>(env</xsl:text>
<xsl:value-of select="$inputparam_values"/><xsl:for-each select="output/param[@location='soap_header']">,
<xsl:text>&_</xsl:text><xsl:value-of select="@name"/><xsl:value-of select="$position"/>
- </xsl:for-each>);
+ </xsl:for-each><xsl:if test="fault">,
+ (<xsl:value-of select="$servicename"/>_<xsl:value-of select="@name"/><xsl:text>_fault*</xsl:text>)&(svc_skeleton_wrapper->fault)</xsl:if>);
</xsl:otherwise>
</xsl:choose>
<xsl:choose>
<xsl:when test="output/param/@type">
if ( NULL == ret_val<xsl:value-of select="$position"/> )
{
- AXIS2_ERROR_SET(env->error, AXIS2_ERROR_DATA_ELEMENT_IS_NULL, AXIS2_FAILURE);
- AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "NULL returnted from the business logic from <xsl:value-of select="$method-name"/> ");
<xsl:if test="input/param/@ours">
<xsl:value-of select="substring-before(input/param/@type, '_t*')"/>_free(input_val<xsl:value-of select="$position"/>, env);
</xsl:if>
@@ -707,10 +731,44 @@
{
axiom_node_t *error_node = NULL;
axiom_element_t *error_ele = NULL;
- error_ele = axiom_element_create(env, node, "fault", NULL,
- &error_node);
- axiom_element_set_text(error_ele, env, "<xsl:value-of select="$qname"/> failed",
- error_node);
+ axutil_error_codes_t error_code;
+ <xsl:value-of select="$method-prefix"/>_t *svc_skeleton_wrapper = NULL;
+
+ svc_skeleton_wrapper = (<xsl:value-of select="$method-prefix"/>_t*)svc_skeleton;
+
+ error_code = env->error->error_number;
+
+ if(error_code <= <xsl:value-of select="$caps_svc_name"/>_ERROR_NONE ||
+ error_code >= <xsl:value-of select="$caps_svc_name"/>_ERROR_LAST )
+ {
+ error_ele = axiom_element_create(env, node, "fault", NULL,
+ &error_node);
+ axiom_element_set_text(error_ele, env, "<xsl:value-of select="$qname"/> failed",
+ error_node);
+ }
+ <xsl:for-each select="method">
+ <xsl:variable name="caps_method_name" select="@caps-name"/>
+ <xsl:variable name="method_name" select="@name"/>
+ <xsl:for-each select="fault/param">
+ <xsl:variable name="fault-caps-name"><xsl:value-of select="$caps_svc_name"/>_<xsl:value-of select="$caps_method_name"/>_FAULT_<xsl:value-of select="@caps-localname"/></xsl:variable>
+
+ else if(error_code == <xsl:value-of select="$fault-caps-name"/>)
+ {
+ /* found which error code */
+ <xsl:value-of select="@type"/> adb_obj = NULL;
+
+ adb_obj = (<xsl:value-of select="@type"/>)svc_skeleton_wrapper->fault.<xsl:value-of select="$method_name"/>_fault.<xsl:value-of select="@shorttype"/>;
+ if(adb_obj)
+ {
+ error_node = <xsl:value-of select="substring-before(@type, '_t*')"/>_serialize(adb_obj, env, NULL, NULL, AXIS2_TRUE, NULL, NULL);
+ <xsl:value-of select="substring-before(@type, '_t*')"/>_free(adb_obj, env);
+ svc_skeleton_wrapper->fault.<xsl:value-of select="$method_name"/>_fault.<xsl:value-of select="@shorttype"/> = NULL;
+ }
+
+ }
+ </xsl:for-each>
+ </xsl:for-each>
+
return error_node;
}
Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/c/SkelHeaderTemplate.xsl
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/c/SkelHeaderTemplate.xsl?rev=741899&r1=741898&r2=741899&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/c/SkelHeaderTemplate.xsl (original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/c/SkelHeaderTemplate.xsl Sat Feb 7 14:18:13 2009
@@ -21,6 +21,7 @@
<xsl:output method="text"/>
<xsl:template match="/interface">
<xsl:variable name="svc_name"><xsl:value-of select="@name"/></xsl:variable>
+ <xsl:variable name="caps_svc_name"><xsl:value-of select="@caps-name"/></xsl:variable>
<xsl:variable name="method-prefix"><xsl:value-of select="@prefix"/></xsl:variable>
<xsl:variable name="qname"><xsl:value-of select="@qname"/></xsl:variable>
@@ -36,6 +37,7 @@
#include <axis2_svc_skeleton.h>
#include <axutil_log_default.h>
#include <axutil_error_default.h>
+ #include <axutil_error.h>
#include <axiom_text.h>
#include <axiom_node.h>
#include <axiom_element.h>
@@ -51,6 +53,10 @@
<xsl:variable name="outputtype" select="substring-before(@type, '_t*')"/>
#include "<xsl:value-of select="$outputtype"/>.h"
</xsl:for-each>
+ <xsl:for-each select="fault/param[@type!='' and contains(@type, 'adb_')]">
+ <xsl:variable name="faulttype" select="substring-before(@type, '_t*')"/>
+ #include "<xsl:value-of select="$faulttype"/>.h"
+ </xsl:for-each>
</xsl:for-each>
#ifdef __cplusplus
@@ -70,6 +76,21 @@
</xsl:variable>
<xsl:variable name="count"><xsl:value-of select="count(output/param)"/></xsl:variable>
+
+ <xsl:if test="fault">
+ /**
+ * the generated fault union for operation "<xsl:value-of select="@qname"/>",
+ * in a case you want to return a fault, put the appropriate adb object for
+ * the union variable pointer comes as the last parameter of the method
+ */
+ typedef union
+ {
+ <xsl:for-each select="fault/param">
+ <xsl:value-of select="@type"/><xsl:text> </xsl:text><xsl:value-of select="@shorttype"/>;
+ </xsl:for-each>
+ } <xsl:value-of select="$method-prefix"/>_<xsl:value-of select="@name"/><xsl:text>_fault</xsl:text>;
+ </xsl:if>
+
<!-- regardless of the sync or async status, the generated method signature would be just a usual
c function-->
/**
@@ -109,8 +130,27 @@
<xsl:value-of select="$inputparams"/><xsl:for-each select="output/param[@location='soap_header']">,
<xsl:variable name="outputtype"><xsl:value-of select="@type"/><xsl:if test="@ours">*</xsl:if></xsl:variable>
<xsl:value-of select="$outputtype"/><xsl:text> dp_</xsl:text><xsl:value-of select="@name"/><xsl:text> /* output header double ptr*/</xsl:text>
- </xsl:for-each> );
- </xsl:for-each>
+ </xsl:for-each><xsl:if test="fault">,
+ <xsl:value-of select="$method-prefix"/>_<xsl:value-of select="@name"/><xsl:text>_fault</xsl:text> *fault</xsl:if>);
+
+
+ </xsl:for-each><!-- end of for-each method -->
+
+ /** we have to reserve some error codes for adb and for custom messages */
+ #define <xsl:value-of select="$caps_svc_name"/>_ERROR_CODES_START (AXIS2_ERROR_LAST + 2000)
+
+ typedef enum
+ {
+ <xsl:value-of select="$caps_svc_name"/>_ERROR_NONE = <xsl:value-of select="$caps_svc_name"/>_ERROR_CODES_START,
+
+ <xsl:for-each select="method">
+ <xsl:variable name="caps_method_name" select="@caps-name"/>
+ <xsl:for-each select="fault/param">
+ <xsl:value-of select="$caps_svc_name"/>_<xsl:value-of select="$caps_method_name"/>_FAULT_<xsl:value-of select="@caps-localname"/>,
+ </xsl:for-each>
+ </xsl:for-each>
+ <xsl:value-of select="$caps_svc_name"/>_ERROR_LAST
+ } <xsl:value-of select="$method-prefix"/>_error_codes;
#ifdef __cplusplus
}
Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/c/SkelSourceTemplate.xsl
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/c/SkelSourceTemplate.xsl?rev=741899&r1=741898&r2=741899&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/c/SkelSourceTemplate.xsl (original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/c/SkelSourceTemplate.xsl Sat Feb 7 14:18:13 2009
@@ -87,7 +87,8 @@
<xsl:value-of select="$inputparams"/><xsl:for-each select="output/param[@location='soap_header']">,
<xsl:variable name="outputtype"><xsl:value-of select="@type"/><xsl:if test="@ours">*</xsl:if></xsl:variable>
<xsl:value-of select="$outputtype"/><xsl:text> dp_</xsl:text><xsl:value-of select="@name"/><xsl:text> /* output header double ptr*/</xsl:text>
- </xsl:for-each> )
+ </xsl:for-each><xsl:if test="fault">,
+ <xsl:value-of select="$method-prefix"/>_<xsl:value-of select="@name"/><xsl:text>_fault</xsl:text> *fault</xsl:if> )
{
/* TODO fill this with the necessary business logic */
<xsl:if test="$outputtype!=''">return (<xsl:value-of select="$outputtype"/>)NULL;</xsl:if>
@@ -95,5 +96,7 @@
}
</xsl:for-each>
+
+
</xsl:template>
</xsl:stylesheet>
Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/c/StubHeaderTemplate.xsl
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/c/StubHeaderTemplate.xsl?rev=741899&r1=741898&r2=741899&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/c/StubHeaderTemplate.xsl (original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/c/StubHeaderTemplate.xsl Sat Feb 7 14:18:13 2009
@@ -30,6 +30,7 @@
<xsl:variable name="method-prefix"><xsl:value-of select="@prefix"/></xsl:variable>
<xsl:variable name="qname"><xsl:value-of select="@qname"/></xsl:variable>
<xsl:variable name="servicename"><xsl:value-of select="@servicename"/></xsl:variable>
+ <xsl:variable name="caps_name"><xsl:value-of select="@caps-name"/></xsl:variable>
/**
* <xsl:value-of select="@name"/>.h
@@ -54,6 +55,11 @@
<xsl:variable name="outputtype" select="substring-before(@type, '_t*')"/>
#include "<xsl:value-of select="$outputtype"/>.h"
</xsl:for-each>
+
+ <xsl:for-each select="fault/param[@type!='' and contains(@type, 'adb_')]">
+ <xsl:variable name="faulttype" select="substring-before(@type, '_t*')"/>
+ #include "<xsl:value-of select="$faulttype"/>.h"
+ </xsl:for-each>
</xsl:for-each>
#ifdef __cplusplus
@@ -90,6 +96,23 @@
axis2_char_t* AXIS2_CALL
axis2_stub_get_endpoint_uri_of_<xsl:value-of select="$servicename"/>(const axutil_env_t *env);
+
+ <xsl:for-each select="method">
+ <xsl:if test="fault">
+ /**
+ * the generated fault union for operation "<xsl:value-of select="@name"/>",
+ * in a case you want to return a fault, put the appropriate adb object for
+ * the union variable pointer comes as the last parameter of the method
+ */
+ typedef union
+ {
+ <xsl:for-each select="fault/param">
+ <xsl:value-of select="@type"/><xsl:text> </xsl:text><xsl:value-of select="@shorttype"/>;
+ </xsl:for-each>
+ } axis2_stub_<xsl:value-of select="$servicename"/>_<xsl:value-of select="@name"/><xsl:text>_fault</xsl:text>;
+ </xsl:if>
+ </xsl:for-each>
+
<xsl:if test="$isSync='1'">
<xsl:for-each select="method">
<xsl:if test="@mep='10' or @mep='12'">
@@ -140,7 +163,8 @@
<xsl:value-of select="$inputparams"/><xsl:for-each select="output/param[@location='soap_header']">,
<xsl:variable name="outputtype"><xsl:value-of select="@type"/><xsl:if test="@ours">*</xsl:if></xsl:variable>
<xsl:value-of select="$outputtype"/><xsl:text> dp_</xsl:text><xsl:value-of select="@name"/><xsl:text> /* output header double ptr*/</xsl:text>
- </xsl:for-each>);
+ </xsl:for-each><xsl:if test="fault">,
+ axis2_stub_<xsl:value-of select="$servicename"/>_<xsl:value-of select="@name"/><xsl:text>_fault</xsl:text> *fault</xsl:if>);
</xsl:if>
</xsl:for-each>
</xsl:if> <!--close for test="$isSync='1'-->
@@ -199,7 +223,8 @@
axis2_status_t ( AXIS2_CALL *on_complete ) (const axutil_env_t *, <xsl:value-of select="$outputtype"/><xsl:text> _</xsl:text><xsl:value-of select="output/param/@name"/><xsl:for-each select="output/param[@location='soap_header']">,
<xsl:variable name="header_outputtype"><xsl:value-of select="@type"/></xsl:variable>
<xsl:value-of select="$header_outputtype"/><xsl:text> _</xsl:text><xsl:value-of select="@name"/>
- </xsl:for-each>, void *data) ,
+ </xsl:for-each><xsl:if test="fault">,
+ axis2_stub_<xsl:value-of select="$servicename"/>_<xsl:value-of select="@name"/><xsl:text>_fault</xsl:text> fault</xsl:if>, void *data),
axis2_status_t ( AXIS2_CALL *on_error ) (const axutil_env_t *, int exception, void *data) );
</xsl:if> <!--close for test="$mep='http://www.w3.org/2004/08/wsdl/in-out'"-->
@@ -238,6 +263,23 @@
</xsl:if>
</xsl:for-each>
+
+ /** we have to reserve some error codes for adb and for custom messages */
+ #define <xsl:value-of select="$caps_name"/>_ERROR_CODES_START (AXIS2_ERROR_LAST + 2000)
+
+ typedef enum
+ {
+ <xsl:value-of select="$caps_name"/>_ERROR_NONE = <xsl:value-of select="$caps_name"/>_ERROR_CODES_START,
+
+ <xsl:for-each select="method">
+ <xsl:variable name="caps_method_name" select="@caps-name"/>
+ <xsl:for-each select="fault/param">
+ <xsl:value-of select="$caps_name"/>_<xsl:value-of select="$caps_method_name"/>_FAULT_<xsl:value-of select="@caps-localname"/>,
+ </xsl:for-each>
+ </xsl:for-each>
+ <xsl:value-of select="$caps_name"/>_ERROR_LAST
+ } <xsl:value-of select="$method-prefix"/>_error_codes;
+
#ifdef __cplusplus
}
#endif
Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/c/StubSourceTemplate.xsl
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/c/StubSourceTemplate.xsl?rev=741899&r1=741898&r2=741899&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/c/StubSourceTemplate.xsl (original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/c/StubSourceTemplate.xsl Sat Feb 7 14:18:13 2009
@@ -31,6 +31,7 @@
<xsl:variable name="method-prefix"><xsl:value-of select="@prefix"/></xsl:variable> <!-- This is no longer using -->
<xsl:variable name="qname"><xsl:value-of select="@qname"/></xsl:variable>
<xsl:variable name="servicename"><xsl:value-of select="@servicename"/></xsl:variable>
+ <xsl:variable name="caps_name"><xsl:value-of select="@caps-name"/></xsl:variable>
/**
* <xsl:value-of select="@name"/>.c
@@ -243,7 +244,8 @@
<xsl:value-of select="$inputparams"/><xsl:for-each select="output/param[@location='soap_header']">,
<xsl:variable name="outputtype"><xsl:value-of select="@type"/><xsl:if test="@ours">*</xsl:if></xsl:variable>
<xsl:value-of select="$outputtype"/><xsl:text> dp_</xsl:text><xsl:value-of select="@name"/><xsl:text> /* output header double ptr*/</xsl:text>
- </xsl:for-each>)
+ </xsl:for-each><xsl:if test="fault">,
+ axis2_stub_<xsl:value-of select="$servicename"/>_<xsl:value-of select="@name"/><xsl:text>_fault</xsl:text> *fault</xsl:if>)
{
axis2_svc_client_t *svc_client = NULL;
axis2_options_t *options = NULL;
@@ -381,6 +383,92 @@
axutil_string_free(soap_act, env);
}
+ <xsl:if test="fault">
+ if (axis2_svc_client_get_last_response_has_fault (svc_client, env) && fault)
+ {
+ /* so it is a fault, will try to create soap elements */
+ axiom_soap_envelope_t *soap_envelope = NULL;
+ axiom_soap_body_t *soap_body = NULL;
+ axiom_soap_fault_t *soap_fault = NULL;
+
+ soap_envelope = axis2_svc_client_get_last_response_soap_envelope (svc_client, env);
+ if (soap_envelope)
+ {
+ soap_body = axiom_soap_envelope_get_body (soap_envelope, env);
+ }
+ if (soap_body)
+ {
+ soap_fault = axiom_soap_body_get_fault (soap_body, env);
+ }
+ if (soap_fault)
+ {
+ axiom_soap_fault_detail_t *soap_detail = NULL;
+ axiom_node_t *soap_detail_node = NULL;
+
+ soap_detail = axiom_soap_fault_get_detail(soap_fault, env);
+
+ if(soap_detail)
+ {
+ axiom_node_t *soap_detail_base_node = NULL;
+ soap_detail_base_node = axiom_soap_fault_detail_get_base_node(soap_detail, env);
+
+ if(soap_detail_base_node)
+ {
+ soap_detail_node = axiom_node_get_first_child(soap_detail_base_node, env);
+ /* somehow get an element node */
+ while(soap_detail_node && axiom_node_get_node_type(soap_detail_node, env) != AXIOM_ELEMENT)
+ {
+ soap_detail_node = axiom_node_get_next_sibling(soap_detail_node, env);
+ }
+ }
+ }
+ if(soap_detail_node)
+ {
+ axis2_char_t *detail_local_name = NULL;
+ axiom_element_t *soap_detail_ele = NULL;
+
+ soap_detail_ele = axiom_node_get_data_element(soap_detail_node, env);
+
+ if(soap_detail_ele)
+ {
+ detail_local_name = axiom_element_get_localname(soap_detail_ele, env);
+ }
+
+ if(!detail_local_name)
+ {
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_NULL_PARAM, AXIS2_FAILURE);
+ }
+ <xsl:variable name="caps_method_name" select="@caps-name"/>
+ <xsl:variable name="method_name" select="@name"/>
+ <xsl:for-each select="fault/param">
+ <xsl:variable name="fault-caps-name"><xsl:value-of select="$caps_name"/>_<xsl:value-of select="$caps_method_name"/>_FAULT_<xsl:value-of select="@caps-localname"/></xsl:variable>
+ else if(!axutil_strcmp(detail_local_name, "<xsl:value-of select="@localname"/>"))
+ {
+ <xsl:value-of select="@type"/> adb_obj = NULL;
+
+ AXIS2_ERROR_SET(env->error, <xsl:value-of select="$fault-caps-name"/>, AXIS2_FAILURE);
+
+ adb_obj = <xsl:value-of select="substring-before(@type, '_t*')"/>_create(env);
+ if(adb_obj)
+ {
+ if(<xsl:value-of select="substring-before(@type, '_t*')"/>_deserialize(adb_obj, env, &soap_detail_node, NULL, AXIS2_FALSE ) == AXIS2_FAILURE)
+ {
+ <xsl:value-of select="substring-before(@type, '_t*')"/>_free(adb_obj, env);
+ }
+
+ fault-><xsl:value-of select="@shorttype"/> = adb_obj;
+ }
+ else {
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
+ }
+ }
+ </xsl:for-each>
+ }
+ }
+ return NULL;
+ }
+ </xsl:if>
+
<!-- extract out the headers at this point -->
<xsl:if test="output/param[@location='soap_header']">
op_client = axis2_svc_client_get_op_client(svc_client, env);
@@ -584,7 +672,8 @@
axis2_status_t ( AXIS2_CALL *on_complete ) (const axutil_env_t *, <xsl:value-of select="$outputtype"/><xsl:text> _</xsl:text><xsl:value-of select="output/param/@name"/><xsl:for-each select="output/param[@location='soap_header']">,
<xsl:variable name="header_outputtype"><xsl:value-of select="@type"/></xsl:variable>
<xsl:value-of select="$header_outputtype"/><xsl:text> </xsl:text><xsl:value-of select="@name"/>
- </xsl:for-each>, void *data);
+ </xsl:for-each><xsl:if test="fault">,
+ axis2_stub_<xsl:value-of select="$servicename"/>_<xsl:value-of select="@name"/><xsl:text>_fault</xsl:text> fault</xsl:if>, void *data);
axis2_status_t ( AXIS2_CALL *on_error ) (const axutil_env_t *, int exception, void *data);
};
@@ -592,6 +681,7 @@
{
axis2_status_t ( AXIS2_CALL *on_error ) (const axutil_env_t *, int, void *data);
struct axis2_stub_<xsl:value-of select="$servicename"/>_<xsl:value-of select="@name"/>_callback_data* callback_data = NULL;
+
void *user_data = NULL;
axis2_status_t status;
@@ -615,10 +705,13 @@
axis2_status_t ( AXIS2_CALL *on_complete ) (const axutil_env_t *, <xsl:value-of select="$outputtype"/><xsl:text> _</xsl:text><xsl:value-of select="output/param/@name"/><xsl:for-each select="output/param[@location='soap_header']">,
<xsl:variable name="header_outputtype"><xsl:value-of select="@type"/></xsl:variable>
<xsl:value-of select="$header_outputtype"/><xsl:text> </xsl:text><xsl:value-of select="@name"/>
- </xsl:for-each>, void *data);
+ </xsl:for-each><xsl:if test="fault">,
+ axis2_stub_<xsl:value-of select="$servicename"/>_<xsl:value-of select="@name"/><xsl:text>_fault</xsl:text> fault</xsl:if>, void *data);
struct axis2_stub_<xsl:value-of select="$servicename"/>_<xsl:value-of select="@name"/>_callback_data* callback_data = NULL;
void *user_data = NULL;
axis2_status_t status = AXIS2_SUCCESS;
+ <xsl:if test="fault">axis2_stub_<xsl:value-of select="$servicename"/>_<xsl:value-of select="@name"/><xsl:text>_fault</xsl:text> fault;
+ </xsl:if>
<xsl:if test="output/param/@ours">
<!-- this means data binding is enable -->
@@ -639,6 +732,7 @@
callback_data = (struct axis2_stub_<xsl:value-of select="$servicename"/>_<xsl:value-of select="@name"/>_callback_data*)axis2_callback_get_data(callback);
+
soap_envelope = axis2_callback_get_envelope(callback, env);
if(soap_envelope)
{
@@ -646,8 +740,69 @@
soap_body = axiom_soap_envelope_get_body(soap_envelope, env);
if(soap_body)
{
+ axiom_soap_fault_t *soap_fault = NULL;
axiom_node_t *body_node = axiom_soap_body_get_base_node(soap_body, env);
- if(body_node)
+
+ <xsl:if test="fault">
+ soap_fault = axiom_soap_body_get_fault (soap_body, env);
+ if (soap_fault)
+ {
+ axiom_soap_fault_detail_t *soap_detail = NULL;
+ axiom_node_t *soap_detail_node = NULL;
+
+ soap_detail = axiom_soap_fault_get_detail(soap_fault, env);
+
+ if(soap_detail)
+ {
+ soap_detail_node = axiom_soap_fault_detail_get_base_node(soap_detail, env);
+ }
+ if(soap_detail_node)
+ {
+ axis2_char_t *detail_local_name = NULL;
+ axiom_element_t *soap_detail_ele = NULL;
+
+ if(axiom_node_get_node_type(soap_detail_node, env) == AXIOM_ELEMENT)
+ {
+ soap_detail_ele = axiom_node_get_data_element(soap_detail_node, env);
+ }
+
+ if(soap_detail_ele)
+ {
+ detail_local_name = axiom_element_get_localname(soap_detail_ele, env);
+ }
+
+ if(!detail_local_name)
+ {
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_NULL_PARAM, AXIS2_FAILURE);
+ }
+ <xsl:variable name="caps_method_name" select="@caps-name"/>
+ <xsl:variable name="method_name" select="@name"/>
+ <xsl:for-each select="fault/param">
+ <xsl:variable name="fault-caps-name"><xsl:value-of select="$caps_name"/>_<xsl:value-of select="$caps_method_name"/>_FAULT_<xsl:value-of select="@caps-localname"/></xsl:variable>
+ else if(!axutil_strcmp(detail_local_name, "<xsl:value-of select="@localname"/>"))
+ {
+ <xsl:value-of select="@type"/> adb_obj = NULL;
+
+ AXIS2_ERROR_SET(env->error, <xsl:value-of select="$fault-caps-name"/>, AXIS2_FAILURE);
+
+ adb_obj = <xsl:value-of select="substring-before(@type, '_t*')"/>_create(env);
+ if(adb_obj)
+ {
+ if(<xsl:value-of select="substring-before(@type, '_t*')"/>_deserialize(adb_obj, env, &soap_detail_node, NULL, AXIS2_FALSE ) == AXIS2_FAILURE)
+ {
+ <xsl:value-of select="substring-before(@type, '_t*')"/>_free(adb_obj, env);
+ }
+
+ fault.<xsl:value-of select="@shorttype"/> = adb_obj;
+ }
+ else {
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
+ }
+ }
+ </xsl:for-each>
+ }
+ }
+ else </xsl:if> <!-- else for checking the fault --> if(body_node)
{
ret_node = axiom_node_get_first_child(body_node, env);
}
@@ -768,20 +923,20 @@
if(ret_val == NULL) {
status = on_complete(env, (<xsl:value-of select="output/param/param/@type"/>)NULL<xsl:for-each select="output/param[@location='soap_header']">,
<xsl:text>_</xsl:text><xsl:value-of select="@name"/>
- </xsl:for-each>, user_data);
+ </xsl:for-each><xsl:if test="fault">, fault </xsl:if>, user_data);
}
else {
status = on_complete(env, <xsl:if test="output/param/@complextype">
<xsl:value-of select="substring-before(output/param/@complextype, '_t*')"/>_free_popping_value(
</xsl:if><xsl:value-of select="substring-before(output/param/@type, '_t*')"/>_free_popping_value(ret_val, env)<xsl:if test="output/param/@complextype">, env)</xsl:if><xsl:for-each select="output/param[@location='soap_header']">,
<xsl:text>_</xsl:text><xsl:value-of select="@name"/>
- </xsl:for-each>, user_data);
+ </xsl:for-each><xsl:if test="fault">, fault </xsl:if>, user_data);
}
</xsl:when>
<xsl:otherwise>
status = on_complete(env, ret_val<xsl:for-each select="output/param[@location='soap_header']">,
<xsl:text>_</xsl:text><xsl:value-of select="@name"/>
- </xsl:for-each>, user_data);
+ </xsl:for-each><xsl:if test="fault">, fault </xsl:if>, user_data);
</xsl:otherwise>
</xsl:choose>
</xsl:when>
@@ -820,7 +975,8 @@
axis2_status_t ( AXIS2_CALL *on_complete ) (const axutil_env_t *, <xsl:value-of select="$outputtype"/><xsl:text> _</xsl:text><xsl:value-of select="output/param/@name"/><xsl:for-each select="output/param[@location='soap_header']">,
<xsl:variable name="header_outputtype"><xsl:value-of select="@type"/></xsl:variable>
<xsl:value-of select="$header_outputtype"/><xsl:text> </xsl:text><xsl:value-of select="@name"/>
- </xsl:for-each>, void *data) ,
+ </xsl:for-each><xsl:if test="fault">,
+ axis2_stub_<xsl:value-of select="$servicename"/>_<xsl:value-of select="@name"/><xsl:text>_fault</xsl:text> fault</xsl:if>, void *data) ,
axis2_status_t ( AXIS2_CALL *on_error ) (const axutil_env_t *, int exception, void *data) )
{