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 di...@apache.org on 2008/03/30 21:11:27 UTC
svn commit: r642802 - in
/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl:
codegen/emitter/ template/c/
Author: dimuthu
Date: Sun Mar 30 12:11:19 2008
New Revision: 642802
URL: http://svn.apache.org/viewvc?rev=642802&view=rev
Log:
Adding custom soap headers (both in and out) support for axis2/c codegen
Modified:
webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/emitter/AxisServiceBasedMultiLanguageEmitter.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/codegen/src/org/apache/axis2/wsdl/codegen/emitter/AxisServiceBasedMultiLanguageEmitter.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/emitter/AxisServiceBasedMultiLanguageEmitter.java?rev=642802&r1=642801&r2=642802&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/emitter/AxisServiceBasedMultiLanguageEmitter.java (original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/emitter/AxisServiceBasedMultiLanguageEmitter.java Sun Mar 30 12:11:19 2008
@@ -247,7 +247,7 @@
this.mapper = mapper;
}
- private Object getBindingPropertyFromOperation(String name, QName qName) {
+ protected Object getBindingPropertyFromOperation(String name, QName qName) {
// Get the correct AxisBindingOperation coresponding to the AxisOperation
AxisBindingOperation axisBindingOperation = null;
@@ -272,7 +272,7 @@
return property;
}
- private Policy getBindingPolicyFromMessage(AxisBindingOperation axisBindingOperation,
+ protected Policy getBindingPolicyFromMessage(AxisBindingOperation axisBindingOperation,
String key) {
AxisBindingMessage axisBindingMessage = null;
@@ -290,7 +290,7 @@
return null;
}
- private Object getBindingPropertyFromMessage(String name, QName qName, String key) {
+ protected Object getBindingPropertyFromMessage(String name, QName qName, String key) {
Object property = null;
// Get the correct AxisBindingOperation coresponding to the AxisOperation
@@ -324,7 +324,7 @@
return property;
}
- private Object getBindingPropertyFromMessageFault(String name, QName qName, String key) {
+ protected Object getBindingPropertyFromMessageFault(String name, QName qName, String key) {
Object property = null;
// Get the correct AxisBindingOperation coresponding to the AxisOperation
@@ -907,7 +907,7 @@
* @param faultMessagesToMep
*/
- private void addFaultMessages(List operationFaultMessages, Set faultMessagesToMep) {
+ protected void addFaultMessages(List operationFaultMessages, Set faultMessagesToMep) {
AxisMessage faultMessage;
for (Iterator iter = operationFaultMessages.iterator(); iter.hasNext();) {
@@ -3272,7 +3272,6 @@
parameterElementList.add(param);
}
}
-
return parameterElementList;
}
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=642802&r1=642801&r2=642802&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 Sun Mar 30 12:11:19 2008
@@ -26,7 +26,12 @@
import org.apache.axis2.util.JavaUtils;
import org.apache.axis2.util.PolicyUtil;
import org.apache.axis2.util.Utils;
+import org.apache.axis2.wsdl.HTTPHeaderMessage;
import org.apache.axis2.wsdl.WSDLConstants;
+import org.apache.axis2.wsdl.WSDLUtil;
+import org.apache.axis2.wsdl.WSDLConstants;
+import org.apache.axis2.description.WSDL2Constants;
+import org.apache.axis2.wsdl.SOAPHeaderMessage;
import org.apache.axis2.wsdl.codegen.CodeGenConfiguration;
import org.apache.axis2.wsdl.codegen.CodeGenerationException;
import org.apache.axis2.wsdl.codegen.writer.CBuildScriptWriter;
@@ -726,6 +731,179 @@
return outputDir;
}
+ /**
+ * @param doc
+ * @param parameters
+ * @param location
+ */
+ protected List getParameterElementList(Document doc, List parameters, String location) {
+ List parameterElementList = new ArrayList();
+
+ if ((parameters != null) && !parameters.isEmpty()) {
+ int count = parameters.size();
+
+ for (int i = 0; i < count; i++) {
+ Element param = doc.createElement("param");
+ SOAPHeaderMessage header = (SOAPHeaderMessage) parameters.get(i);
+ QName name = header.getElement();
+
+ addAttribute(doc, "name", this.mapper.getParameterName(name), param);
+
+ String typeMapping = this.mapper.getTypeMappingName(name);
+ String typeMappingStr = (typeMapping == null)
+ ? ""
+ : typeMapping;
+
+ addAttribute(doc, "type", typeMappingStr, param);
+ addAttribute(doc, "location", location, param);
+ if (header.isMustUnderstand()) {
+ addAttribute(doc, "mustUnderstand", "true", param);
+ }
+
+ if (name != null) {
+ Element qNameElement = doc.createElement("qname");
+ addAttribute(doc, "nsuri", name.getNamespaceURI(), qNameElement);
+ addAttribute(doc, "localname", name.getLocalPart(), qNameElement);
+ param.appendChild(qNameElement);
+ }
+ parameterElementList.add(param);
+
+ // the new trick to identify adb types
+ boolean isOurs = true;
+
+ if (typeMappingStr.length() != 0 && !typeMappingStr.equals("void") &&
+ !typeMappingStr.equals(C_DEFAULT_TYPE)) {
+ addAttribute(doc, "ours", "yes", param);
+ isOurs = true;
+ } else {
+ isOurs = false;
+ }
+
+ if (isOurs) {
+ typeMappingStr = C_OUR_TYPE_PREFIX + typeMappingStr + C_OUR_TYPE_SUFFIX;
+ }
+
+ addAttribute(doc, "axis2-type", typeMappingStr, param);
+
+ }
+ }
+ return parameterElementList;
+ }
+
+ /**
+ * Finds the output element.
+ *
+ * @param doc
+ * @param bindingOperation
+ * @param headerParameterQNameList
+ */
+ protected Element getOutputElement(Document doc,
+ AxisBindingOperation bindingOperation,
+ List headerParameterQNameList) {
+ AxisOperation operation = bindingOperation.getAxisOperation();
+ Element outputElt = doc.createElement("output");
+ String mep = operation.getMessageExchangePattern();
+
+
+ if (WSDLUtil.isOutputPresentForMEP(mep)) {
+
+ Element param = getOutputParamElement(doc, operation);
+
+ if (param != null) {
+ outputElt.appendChild(param);
+ }
+
+ List outputElementList = getParameterElementList(doc, headerParameterQNameList,
+ WSDLConstants.SOAP_HEADER);
+ outputElementList.addAll(getParameterElementListForHttpHeader(doc,
+ (ArrayList) getBindingPropertyFromMessage(
+ WSDL2Constants.ATTR_WHTTP_HEADER,
+ operation.getName(),
+ WSDLConstants.WSDL_MESSAGE_DIRECTION_OUT),
+ WSDLConstants.HTTP_HEADER));
+
+ for (int i = 0; i < outputElementList.size(); i++) {
+ outputElt.appendChild((Element) outputElementList.get(i));
+ }
+
+ /*
+ * Setting the effective policy for the output message.
+ */
+ Policy policy = getBindingPolicyFromMessage(bindingOperation,
+ WSDLConstants.WSDL_MESSAGE_DIRECTION_OUT);
+
+ if (policy != null) {
+ try {
+ addAttribute(doc, "policy",
+ PolicyUtil.getSafeString(PolicyUtil.policyComponentToString(policy)),
+ outputElt);
+ } catch (Exception ex) {
+ throw new RuntimeException("can't serialize the policy ..");
+ }
+ }
+ }
+ return outputElt;
+ }
+
+ /**
+ * Get the input element
+ *
+ * @param doc
+ * @param bindingOperation
+ * @param headerParameterQNameList
+ * @return DOM element
+ */
+ protected Element getInputElement(Document doc,
+ AxisBindingOperation bindingOperation,
+ List headerParameterQNameList) {
+ AxisOperation operation = bindingOperation.getAxisOperation();
+ Element inputElt = doc.createElement("input");
+ String mep = operation.getMessageExchangePattern();
+
+ if (WSDLUtil.isInputPresentForMEP(mep)) {
+
+ Element[] param = getInputParamElement(doc, operation);
+ for (int i = 0; i < param.length; i++) {
+ inputElt.appendChild(param[i]);
+ }
+
+ List parameterElementList = getParameterElementList(doc, headerParameterQNameList,
+ WSDLConstants.SOAP_HEADER);
+ parameterElementList.addAll(getParameterElementListForHttpHeader(doc,
+ (ArrayList) getBindingPropertyFromMessage(
+ WSDL2Constants.ATTR_WHTTP_HEADER,
+ operation.getName(),
+ WSDLConstants.WSDL_MESSAGE_DIRECTION_IN),
+ WSDLConstants.HTTP_HEADER));
+ parameterElementList.addAll(getParameterElementListForSOAPModules(doc,
+ (ArrayList) getBindingPropertyFromMessage(
+ WSDL2Constants.ATTR_WSOAP_MODULE,
+ operation.getName(),
+ WSDLConstants.WSDL_MESSAGE_DIRECTION_IN)));
+
+ for (int i = 0; i < parameterElementList.size(); i++) {
+ inputElt.appendChild((Element) parameterElementList.get(i));
+ }
+
+ /*
+ * Setting the effective policy of input message
+ */
+ Policy policy = getBindingPolicyFromMessage(bindingOperation,
+ WSDLConstants.WSDL_MESSAGE_DIRECTION_IN);
+
+ if (policy != null) {
+ try {
+ addAttribute(doc, "policy",
+ PolicyUtil.getSafeString(PolicyUtil.policyComponentToString(policy)),
+ inputElt);
+ } catch (Exception ex) {
+ throw new RuntimeException("can't serialize the policy ..");
+ }
+ }
+
+ }
+ return inputElt;
+ }
}
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=642802&r1=642801&r2=642802&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 Sun Mar 30 12:11:19 2008
@@ -27,6 +27,7 @@
<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>
<xsl:variable name="svcname"><xsl:value-of select="@svcname"/></xsl:variable>
+ <xsl:variable name="servicename"><xsl:value-of select="@svcname"/></xsl:variable>
<xsl:variable name="soapVersion"><xsl:value-of select="@soap-version"/></xsl:variable>
/**
@@ -123,6 +124,157 @@
}
+
+ /**
+ * function to free any soap input headers
+ */
+ <xsl:for-each select="method">
+ <xsl:if test="input/param[@location='soap_header']">
+ void
+ axis2_stub_op_<xsl:value-of select="$servicename"/>_<xsl:value-of select="@name"/>_free_input_headers(const axutil_env_t *env, <xsl:for-each select="input/param[@location='soap_header']"><xsl:if test="position()!=1">,</xsl:if>
+ <xsl:variable name="inputtype"><xsl:if test="@ours">adb_</xsl:if><xsl:value-of select="@type"/><xsl:if test="@ours">_t*</xsl:if></xsl:variable>
+ <xsl:value-of select="$inputtype"/><xsl:text> _</xsl:text><xsl:value-of select="@name"/>
+ </xsl:for-each>)
+ {
+ <xsl:for-each select="input/param[@location='soap_header']">
+ <xsl:variable name="header_var"><xsl:text>_</xsl:text><xsl:value-of select="@name"/></xsl:variable>
+ <xsl:choose>
+ <xsl:when test="@ours">
+ if(<xsl:value-of select="$header_var"/>)
+ {
+ adb_<xsl:value-of select="@type"/>_free(<xsl:value-of select="$header_var"/>, env);
+ }
+ </xsl:when>
+ <xsl:otherwise>
+ /* we don't have anything to free on <xsl:value-of select="$header_var"/> */
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:for-each>
+ }
+ </xsl:if>
+ </xsl:for-each>
+
+
+
+ /**
+ * function to free any soap output headers
+ */
+ <xsl:for-each select="method">
+ <xsl:if test="output/param[@location='soap_header']">
+ void
+ axis2_stub_op_<xsl:value-of select="$servicename"/>_<xsl:value-of select="@name"/>_free_output_headers(const axutil_env_t *env, <xsl:for-each select="output/param[@location='soap_header']"><xsl:if test="position()!=1">,</xsl:if>
+ <xsl:variable name="outputtype"><xsl:if test="@ours">adb_</xsl:if><xsl:value-of select="@type"/><xsl:if test="@ours">_t*</xsl:if></xsl:variable>
+ <xsl:value-of select="$outputtype"/><xsl:text> _</xsl:text><xsl:value-of select="@name"/>
+ </xsl:for-each>)
+ {
+ <xsl:for-each select="output/param[@location='soap_header']">
+ <xsl:variable name="header_var"><xsl:text>_</xsl:text><xsl:value-of select="@name"/></xsl:variable>
+ <xsl:choose>
+ <xsl:when test="@ours">
+ if(<xsl:value-of select="$header_var"/>)
+ {
+ adb_<xsl:value-of select="@type"/>_free(<xsl:value-of select="$header_var"/>, env);
+ }
+ </xsl:when>
+ <xsl:otherwise>
+ /* we don't have anything to free on <xsl:value-of select="$header_var"/> */
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:for-each>
+ }
+ </xsl:if>
+ </xsl:for-each>
+
+ <xsl:for-each select="method/output/param[@location='soap_header']">
+ <xsl:if test="position()=1">
+ /*
+ * Create the response soap envelope when output headers are to be set..
+ */
+ axiom_soap_envelope_t* AXIS2_CALL
+ <xsl:value-of select="$method-prefix"/>_create_response_envelope(const axutil_env_t *env,
+ axis2_msg_ctx_t *in_msg_ctx,
+ axis2_msg_ctx_t *msg_ctx,
+ axiom_node_t *body_content_node)
+ {
+ const axis2_char_t *soap_ns = AXIOM_SOAP12_SOAP_ENVELOPE_NAMESPACE_URI;
+ int soap_version = AXIOM_SOAP12;
+ axiom_namespace_t *env_ns = NULL;
+ axiom_soap_envelope_t *default_envelope = NULL;
+ axiom_soap_header_t *out_header = NULL;
+ axiom_soap_body_t *out_body = NULL;
+ axiom_node_t *out_node = NULL;
+
+ if (in_msg_ctx && axis2_msg_ctx_get_is_soap_11(in_msg_ctx, env))
+ {
+ soap_ns = AXIOM_SOAP11_SOAP_ENVELOPE_NAMESPACE_URI; /* default is 1.2 */
+ soap_version = AXIOM_SOAP11;
+ }
+
+ /* create the soap envelope here */
+ env_ns = axiom_namespace_create(env, soap_ns, "soapenv");
+ if (!env_ns)
+ {
+ return NULL;
+ }
+
+ default_envelope = axiom_soap_envelope_create(env, env_ns);
+
+ if (!default_envelope)
+ {
+ axiom_namespce_free(env_ns, env);
+ return NULL;
+ }
+
+ out_header = axiom_soap_header_create_with_parent(env, default_envelope);
+ if (!out_header)
+ {
+ axiom_soap_envelope_free(default_envelope, env);
+ axiom_namespce_free(env_ns, env);
+ return NULL;
+ }
+
+ out_body = axiom_soap_body_create_with_parent(env, default_envelope);
+ if (!out_body)
+ {
+ axiom_soap_body_free(out_body, env);
+ axiom_soap_envelope_free(default_envelope, env);
+ axiom_namespce_free(env_ns, env);
+ return NULL;
+ }
+
+ out_node = axiom_soap_body_get_base_node(out_body, env);
+ if (!out_node)
+ {
+ axiom_soap_body_free(out_body, env);
+ axiom_soap_envelope_free(default_envelope, env);
+ axiom_namespce_free(env_ns, env);
+ return NULL;
+ }
+
+ if (body_content_node)
+ {
+ axiom_node_add_child(out_node, env, body_content_node);
+ }
+
+ if(axis2_msg_ctx_set_soap_envelope(msg_ctx, env, default_envelope) == AXIS2_FAILURE)
+ {
+ axiom_soap_body_free(out_body, env);
+ axiom_soap_envelope_free(default_envelope, env);
+ axiom_namespce_free(env_ns, env);
+ if (body_content_node)
+ {
+ axiom_node_free(body_content_node, env);
+ }
+ return NULL;
+ }
+ return default_envelope;
+ }
+ </xsl:if>
+ </xsl:for-each>
+
+
+
+
/*
* This method invokes the right service method
*/
@@ -140,8 +292,17 @@
axis2_op_t *operation = NULL;
axutil_qname_t *op_qname = NULL;
axis2_char_t *op_name = NULL;
+ axis2_msg_ctx_t *in_msg_ctx = NULL;
+
+ axiom_soap_envelope_t *req_soap_env = NULL;
+ axiom_soap_header_t *req_soap_header = NULL;
+ axiom_soap_envelope_t *res_soap_env = NULL;
+ axiom_soap_header_t *res_soap_header = NULL;
axiom_node_t *ret_node = NULL;
+ axiom_node_t *input_header = NULL;
+ axiom_node_t *output_header = NULL;
+ axiom_node_t *header_base_node = NULL;
<xsl:for-each select="method">
<xsl:text>
@@ -156,11 +317,17 @@
</xsl:variable>
<xsl:value-of select="$outputtype"/> ret_val<xsl:value-of select="$position"/><xsl:if test="output/param/@ours"> = NULL</xsl:if>;
<xsl:if test="input/param/@type!=''">
- <xsl:variable name="inputtype">
- <xsl:if test="input/param/@ours">adb_</xsl:if><xsl:value-of select="input/param/@type"/><xsl:if test="input/param/@ours">_t*</xsl:if>
- </xsl:variable>
+ <xsl:variable name="inputtype"><xsl:if test="input/param/@ours">adb_</xsl:if><xsl:value-of select="input/param/@type"/><xsl:if test="input/param/@ours">_t*</xsl:if></xsl:variable>
<xsl:value-of select="$inputtype"/> input_val<xsl:value-of select="$position"/><xsl:if test="input/param/@ours"> = NULL</xsl:if>;
</xsl:if>
+ <xsl:for-each select="input/param[@location='soap_header']">
+ <xsl:variable name="inputtype"><xsl:if test="@ours">adb_</xsl:if><xsl:value-of select="@type"/><xsl:if test="@ours">_t*</xsl:if></xsl:variable>
+ <xsl:value-of select="$inputtype"/><xsl:text> _</xsl:text><xsl:value-of select="@name"/><xsl:value-of select="$position"/> = NULL;
+ </xsl:for-each>
+ <xsl:for-each select="output/param[@location='soap_header']">
+ <xsl:variable name="outputtype"><xsl:if test="@ours">adb_</xsl:if><xsl:value-of select="@type"/><xsl:if test="@ours">_t*</xsl:if></xsl:variable>
+ <xsl:value-of select="$outputtype"/><xsl:text> _</xsl:text><xsl:value-of select="@name"/><xsl:value-of select="$position"/> = NULL;
+ </xsl:for-each>
</xsl:for-each>
operation_ctx = axis2_msg_ctx_get_op_ctx(msg_ctx, env);
@@ -170,6 +337,31 @@
if (op_name)
{
+ <xsl:for-each select="method/input/param[@location='soap_header']">
+ <xsl:if test="position()=1">
+ if(operation_ctx)
+ {
+ in_msg_ctx = axis2_op_ctx_get_msg_ctx(operation_ctx, env, AXIS2_WSDL_MESSAGE_LABEL_IN);
+ }
+ if(in_msg_ctx)
+ {
+ req_soap_env = axis2_msg_ctx_get_soap_envelope(in_msg_ctx, env);
+ }
+ if(!req_soap_env)
+ {
+ AXIS2_LOG_ERROR( env->log, AXIS2_LOG_SI, "request evelope is NULL");
+ return NULL;
+ }
+ req_soap_header = axiom_soap_envelope_get_header(req_soap_env, env);
+
+ if(req_soap_header)
+ {
+ header_base_node = axiom_soap_header_get_base_node(req_soap_header, env);
+ }
+ </xsl:if>
+ </xsl:for-each>
+
+
<xsl:for-each select="method">
<xsl:variable name="position"><xsl:value-of select="position()"/></xsl:variable>
<xsl:variable name="name"><xsl:value-of select="@name"/></xsl:variable>
@@ -177,6 +369,7 @@
<xsl:variable name="method-ns"><xsl:value-of select="@namespace"/> </xsl:variable>
<xsl:variable name="outputCapsType"><xsl:value-of select="output/param/@caps-type"/> </xsl:variable>
<xsl:variable name="outputtype"><xsl:value-of select="output/param/@type"/></xsl:variable>
+ <xsl:variable name="inputtype"><xsl:value-of select="input/param/@type"/></xsl:variable>
if ( axutil_strcmp(op_name, "<xsl:value-of select="@localpart"/>") == 0 )
{
@@ -197,14 +390,95 @@
<xsl:otherwise>content_node;</xsl:otherwise>
</xsl:choose>
</xsl:if>
+
+ <xsl:for-each select="input/param[@location='soap_header']">
+ <xsl:choose>
+ <xsl:when test="position()=1">
+ input_header = axiom_node_get_first_child(header_base_node, env);
+
+ while(input_header && axiom_node_get_node_type(input_header, env) != AXIOM_ELEMENT)
+ {
+ input_header = axiom_node_get_next_sibling(input_header, env);
+ }
+ </xsl:when>
+ <xsl:otherwise>
+ input_header = axiom_node_get_next_sibling(input_header, env);
+
+ while(input_header && axiom_node_get_node_type(input_header, env) != AXIOM_ELEMENT)
+ {
+ input_header = axiom_node_get_next_sibling(input_header, env);
+ }
+ </xsl:otherwise>
+ </xsl:choose>
+
+ <!-- here the position mean the number of the method -->
+ <xsl:variable name="header_var"><xsl:text>_</xsl:text><xsl:value-of select="@name"/><xsl:value-of select="$position"/></xsl:variable>
+
+ if( NULL == input_header)
+ {
+ AXIS2_LOG_ERROR( env->log, AXIS2_LOG_SI, "Response header <xsl:value-of select="@name"/> is NULL");
+ <xsl:if test="@ours">
+ /* you can't have a response header NULL, just free things and exit */
+ axis2_stub_op_<xsl:value-of select="$servicename"/>_<xsl:value-of select="$method-name"/>_free_input_headers(env, <xsl:for-each select="../../input/param[@location='soap_header']"><xsl:if test="position()!=1">,</xsl:if>
+ <xsl:text>_</xsl:text><xsl:value-of select="@name"/><xsl:value-of select="$position"/>
+ </xsl:for-each>);
+ adb_<xsl:value-of select="$inputtype"/>_free(input_val<xsl:value-of select="$position"/>, env);
+ </xsl:if>
+ return NULL;
+ }
+
+ <xsl:choose>
+ <xsl:when test="@ours">
+ <xsl:value-of select="$header_var"/> = adb_<xsl:value-of select="@type"/>_create(env);
+
+ if(adb_<xsl:value-of select="@type"/>_deserialize(<xsl:value-of select="$header_var"/>, env, &input_header, NULL, AXIS2_FALSE ) == AXIS2_FAILURE)
+ {
+ if(<xsl:value-of select="$header_var"/> != NULL)
+ {
+ adb_<xsl:value-of select="@type"/>_free(<xsl:value-of select="$header_var"/>, env);
+ }
+ AXIS2_LOG_ERROR( env->log, AXIS2_LOG_SI, "NULL returnted from the <xsl:value-of select="@type"/>_deserialize: "
+ "This should be due to an invalid input header");
+ axis2_stub_op_<xsl:value-of select="$servicename"/>_<xsl:value-of select="$method-name"/>_free_input_headers(env, <xsl:for-each select="../../input/param[@location='soap_header']"><xsl:if test="position()!=1">,</xsl:if>
+ <xsl:text>_</xsl:text><xsl:value-of select="@name"/><xsl:value-of select="$position"/>
+ </xsl:for-each>);
+ adb_<xsl:value-of select="$inputtype"/>_free(input_val<xsl:value-of select="$position"/>, env);
+ return NULL;
+ }
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="header_var"/> = input_header;
+ </xsl:otherwise>
+ </xsl:choose>
+
+ </xsl:for-each>
+
+
ret_val<xsl:value-of select="$position"/> = <xsl:value-of select="$svcop-prefix"/>_<xsl:value-of select="$method-name"/>(env <xsl:if test="input/param/@type!=''">,</xsl:if>
- <xsl:if test="input/param/@type!=''">input_val<xsl:value-of select="$position"/></xsl:if> );
+ <xsl:if test="input/param/@type!=''">input_val<xsl:value-of select="$position"/></xsl:if><xsl:for-each select="input/param[@location='soap_header']">,
+ <xsl:text>_</xsl:text><xsl:value-of select="@name"/><xsl:value-of select="$position"/>
+ </xsl:for-each><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: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">
+ adb_<xsl:value-of select="input/param/@type"/>_free(input_val<xsl:value-of select="$position"/>, env);
+ </xsl:if>
+ <xsl:if test="input/param/@location='soap_header'">
+ axis2_stub_op_<xsl:value-of select="$servicename"/>_<xsl:value-of select="$method-name"/>_free_input_headers(env, <xsl:for-each select="input/param[@location='soap_header']"><xsl:if test="position()!=1">,</xsl:if>
+ <xsl:text>_</xsl:text><xsl:value-of select="@name"/><xsl:value-of select="$position"/>
+ </xsl:for-each>);
+ </xsl:if>
+ <xsl:if test="output/param/@location='soap_header'">
+ axis2_stub_op_<xsl:value-of select="$servicename"/>_<xsl:value-of select="$method-name"/>_free_output_headers(env, <xsl:for-each select="output/param[@location='soap_header']"><xsl:if test="position()!=1">,</xsl:if>
+ <xsl:text> _</xsl:text><xsl:value-of select="@name"/><xsl:value-of select="$position"/>
+ </xsl:for-each>);
+ </xsl:if>
return NULL;
}
ret_node = <xsl:choose>
@@ -217,6 +491,74 @@
</xsl:when>
<xsl:otherwise>ret_val<xsl:value-of select="$position"/>;</xsl:otherwise>
</xsl:choose>
+ <xsl:if test="output/param[@location='soap_header']">
+ res_soap_env = axis2_msg_ctx_get_response_soap_envelope(msg_ctx, env);
+ if(!res_soap_env)
+ {
+ res_soap_env = <xsl:value-of select="$method-prefix"/>_create_response_envelope(env, in_msg_ctx, msg_ctx, ret_node);
+ }
+ if(!res_soap_env)
+ {
+ AXIS2_LOG_ERROR( env->log, AXIS2_LOG_SI, "response evelope is NULL");
+ <xsl:if test="input/param/@location='soap_header'">
+ axis2_stub_op_<xsl:value-of select="$servicename"/>_<xsl:value-of select="$method-name"/>_free_input_headers(env, <xsl:for-each select="input/param[@location='soap_header']"><xsl:if test="position()!=1">,</xsl:if>
+ <xsl:text> _</xsl:text><xsl:value-of select="@name"/><xsl:value-of select="$position"/>
+ </xsl:for-each>);
+ </xsl:if>
+ <xsl:if test="output/param/@location='soap_header'">
+ axis2_stub_op_<xsl:value-of select="$servicename"/>_<xsl:value-of select="$method-name"/>_free_output_headers(env, <xsl:for-each select="output/param[@location='soap_header']"><xsl:if test="position()!=1">,</xsl:if>
+ <xsl:text> _</xsl:text><xsl:value-of select="@name"/><xsl:value-of select="$position"/>
+ </xsl:for-each>);
+ </xsl:if>
+ return NULL;
+ }
+ res_soap_header = axiom_soap_envelope_get_header(res_soap_env, env);
+
+ if(res_soap_header)
+ {
+ header_base_node = axiom_soap_header_get_base_node(res_soap_header, env);
+ }
+
+ if(!header_base_node)
+ {
+ <xsl:if test="input/param/@location='soap_header'">
+ axis2_stub_op_<xsl:value-of select="$servicename"/>_<xsl:value-of select="$method-name"/>_free_input_headers(env, <xsl:for-each select="input/param[@location='soap_header']"><xsl:if test="position()!=1">,</xsl:if>
+ <xsl:text> _</xsl:text><xsl:value-of select="@name"/><xsl:value-of select="$position"/>
+ </xsl:for-each>);
+ </xsl:if>
+ <xsl:if test="output/param/@location='soap_header'">
+ axis2_stub_op_<xsl:value-of select="$servicename"/>_<xsl:value-of select="$method-name"/>_free_output_headers(env, <xsl:for-each select="output/param[@location='soap_header']"><xsl:if test="position()!=1">,</xsl:if>
+ <xsl:text> _</xsl:text><xsl:value-of select="@name"/><xsl:value-of select="$position"/>
+ </xsl:for-each>);
+ </xsl:if>
+ AXIS2_LOG_ERROR( env->log, AXIS2_LOG_SI, "Required response header is NULL");
+ return NULL;
+ }
+ </xsl:if>
+ <!-- adding output headers -->
+ <xsl:for-each select="output/param[@location='soap_header']">
+ <xsl:choose>
+ <xsl:when test="@ours">
+ output_header = adb_<xsl:value-of select="@type"/>_serialize(_<xsl:value-of select="@name"/><xsl:value-of select="$position"/>, env, NULL, NULL, AXIS2_TRUE, NULL, NULL);
+ </xsl:when>
+ <xsl:otherwise>
+ output_header = _<xsl:value-of select="@name"/>;
+ </xsl:otherwise>
+ </xsl:choose>
+ axiom_node_add_child(header_base_node, env, output_header);
+ </xsl:for-each>
+
+ <xsl:if test="input/param/@location='soap_header'">
+ axis2_stub_op_<xsl:value-of select="$servicename"/>_<xsl:value-of select="$method-name"/>_free_input_headers(env, <xsl:for-each select="input/param[@location='soap_header']"><xsl:if test="position()!=1">,</xsl:if>
+ <xsl:text> _</xsl:text><xsl:value-of select="@name"/><xsl:value-of select="$position"/>
+ </xsl:for-each>);
+ </xsl:if>
+ <xsl:if test="output/param/@location='soap_header'">
+ axis2_stub_op_<xsl:value-of select="$servicename"/>_<xsl:value-of select="$method-name"/>_free_output_headers(env, <xsl:for-each select="output/param[@location='soap_header']"><xsl:if test="position()!=1">,</xsl:if>
+ <xsl:text> _</xsl:text><xsl:value-of select="@name"/><xsl:value-of select="$position"/>
+ </xsl:for-each>);
+ </xsl:if>
+
return ret_node;
</xsl:when>
<xsl:otherwise>
@@ -224,7 +566,15 @@
{
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/@type!=''">
+ adb_<xsl:value-of select="input/param/@type"/>_free(input_val<xsl:value-of select="$position"/>, env);
+ </xsl:if>
+ <xsl:if test="input/param/@location='soap_header'">
+ axis2_stub_op_<xsl:value-of select="$servicename"/>_<xsl:value-of select="$method-name"/>_free_input_headers(env, <xsl:for-each select="input/param[@location='soap_header']"><xsl:if test="position()!=1">,</xsl:if>
+ <xsl:text> _</xsl:text><xsl:value-of select="@name"/><xsl:value-of select="position()"/>
+ </xsl:for-each>);
return NULL;
+ </xsl:if>
</xsl:otherwise>
</xsl:choose>
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=642802&r1=642801&r2=642802&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 Sun Mar 30 12:11:19 2008
@@ -43,14 +43,14 @@
<xsl:for-each select="method">
- <xsl:if test="output/param[@ours and @type!='']">
- <xsl:variable name="outputtype">adb_<xsl:value-of select="output/param/@type"></xsl:value-of></xsl:variable>
- #include "<xsl:value-of select="$outputtype"/>.h"
- </xsl:if>
<xsl:for-each select="input/param[@type!='' and @ours]">
<xsl:variable name="inputtype">adb_<xsl:value-of select="@type"></xsl:value-of></xsl:variable>
#include "<xsl:value-of select="$inputtype"/>.h"
</xsl:for-each>
+ <xsl:for-each select="output/param[@type!='' and @ours]">
+ <xsl:variable name="outputtype">adb_<xsl:value-of select="@type"></xsl:value-of></xsl:variable>
+ #include "<xsl:value-of select="$outputtype"/>.h"
+ </xsl:for-each>
</xsl:for-each>
#ifdef __cplusplus
@@ -73,8 +73,14 @@
* auto generated function declaration
* for "<xsl:value-of select="@qname"/>" operation.
<!-- select only the body parameters -->
- <xsl:for-each select="input/param[@type!='']">* @param <xsl:value-of select="@name"></xsl:value-of></xsl:for-each>
+ *<xsl:for-each select="input/param[@type!='']"><xsl:text>
+ </xsl:text>* @param <xsl:value-of select="@name"/></xsl:for-each>
+ *<xsl:for-each select="output/param[@location='soap_header']"><xsl:text>
+ </xsl:text>* @param dp_<xsl:value-of select="@name"/> - output header</xsl:for-each>
+ * @return <xsl:value-of select="$outputtype"/>
+ <xsl:for-each select="input/param[@type!='']">* @param <xsl:value-of select="@name"></xsl:value-of></xsl:for-each><xsl:text>
*/
+ </xsl:text>
<xsl:choose>
<xsl:when test="$outputtype=''">axis2_status_t </xsl:when>
<xsl:when test="$outputtype!=''"><xsl:value-of select="$outputtype"/></xsl:when>
@@ -84,7 +90,10 @@
<xsl:variable name="inputtype">
<xsl:if test="@ours">adb_</xsl:if><xsl:value-of select="@type"/><xsl:if test="@ours">_t*</xsl:if>
</xsl:variable>
- <xsl:if test="position()>1">,</xsl:if><xsl:value-of select="$inputtype"/><xsl:text> </xsl:text><xsl:value-of select="@name"/>
+ <xsl:value-of select="$inputtype"/><xsl:text> </xsl:text><xsl:value-of select="@name"/>
+ </xsl:for-each><xsl:for-each select="output/param[@location='soap_header']">,
+ <xsl:variable name="outputtype"><xsl:if test="@ours">adb_</xsl:if><xsl:value-of select="@type"/><xsl:if test="@ours">_t**</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>
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=642802&r1=642801&r2=642802&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 Sun Mar 30 12:11:19 2008
@@ -50,8 +50,14 @@
* auto generated function definition signature
* for "<xsl:value-of select="@qname"/>" operation.
<!-- select only the body parameters -->
- <xsl:for-each select="input/param[@type!='']">* @param <xsl:value-of select="@name"></xsl:value-of></xsl:for-each>
+ *<xsl:for-each select="input/param[@type!='']"><xsl:text>
+ </xsl:text>* @param <xsl:value-of select="@name"/></xsl:for-each>
+ *<xsl:for-each select="output/param[@location='soap_header']"><xsl:text>
+ </xsl:text>* @param dp_<xsl:value-of select="@name"/> - output header</xsl:for-each>
+ * @return <xsl:value-of select="$outputtype"/>
+ <xsl:for-each select="input/param[@type!='']">* @param <xsl:value-of select="@name"></xsl:value-of></xsl:for-each><xsl:text>
*/
+ </xsl:text>
<xsl:choose>
<xsl:when test="$outputtype=''">axis2_status_t </xsl:when>
<xsl:when test="$outputtype!=''"><xsl:value-of select="$outputtype"/></xsl:when>
@@ -61,8 +67,11 @@
<xsl:variable name="inputtype">
<xsl:if test="@ours">adb_</xsl:if><xsl:value-of select="@type"/><xsl:if test="@ours">_t*</xsl:if>
</xsl:variable>
- <xsl:if test="position()>1">,</xsl:if><xsl:value-of select="$inputtype"/><xsl:text> </xsl:text><xsl:value-of select="@name"/>
- </xsl:for-each> )
+ <xsl:value-of select="$inputtype"/><xsl:text> </xsl:text><xsl:value-of select="@name"/>
+ </xsl:for-each><xsl:for-each select="output/param[@location='soap_header']">,
+ <xsl:variable name="outputtype"><xsl:if test="@ours">adb_</xsl:if><xsl:value-of select="@type"/><xsl:if test="@ours">_t**</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> )
{
/* TODO fill this with the necessary business logic */
<xsl:if test="$outputtype!=''">return NULL;</xsl:if>
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=642802&r1=642801&r2=642802&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 Sun Mar 30 12:11:19 2008
@@ -46,14 +46,14 @@
#include <axis2_stub.h>
<xsl:for-each select="method">
- <xsl:if test="output/param[@ours and @type!='']">
- <xsl:variable name="outputtype">adb_<xsl:value-of select="output/param/@type"></xsl:value-of></xsl:variable>
- #include "<xsl:value-of select="$outputtype"/>.h"
- </xsl:if>
<xsl:for-each select="input/param[@type!='' and @ours ]">
<xsl:variable name="inputtype">adb_<xsl:value-of select="@type"></xsl:value-of></xsl:variable>
#include "<xsl:value-of select="$inputtype"/>.h"
</xsl:for-each>
+ <xsl:for-each select="output/param[@type!='' and @ours ]">
+ <xsl:variable name="outputtype">adb_<xsl:value-of select="@type"></xsl:value-of></xsl:variable>
+ #include "<xsl:value-of select="$outputtype"/>.h"
+ </xsl:for-each>
</xsl:for-each>
#ifdef __cplusplus
@@ -104,15 +104,14 @@
* for "<xsl:value-of select="@qname"/>" operation.
* @param stub The stub (axis2_stub_t)
* @param env environment ( mandatory)
- <!-- select only the body parameters -->
- <xsl:for-each select="input/param[@type!='']">* @param _<xsl:value-of select="@name"></xsl:value-of></xsl:for-each>
- * return
- <xsl:choose>
- <xsl:when test="$outputtype=''">axis2_status_t</xsl:when>
- <xsl:when test="$outputtype!=''"><xsl:value-of select="$outputtype"/></xsl:when>
- </xsl:choose>
+ *<xsl:for-each select="input/param[@type!='']"><xsl:text>
+ </xsl:text>* @param _<xsl:value-of select="@name"/></xsl:for-each>
+ *<xsl:for-each select="output/param[@location='soap_header']"><xsl:text>
+ </xsl:text>* @param dp_<xsl:value-of select="@name"/> - output header</xsl:for-each>
+ * @return <xsl:value-of select="$outputtype"/>
*/
+
<xsl:choose>
<xsl:when test="$outputtype=''">axis2_status_t</xsl:when>
<xsl:when test="$outputtype!=''"><xsl:value-of select="$outputtype"/></xsl:when>
@@ -121,6 +120,9 @@
axis2_stub_op_<xsl:value-of select="$servicename"/>_<xsl:value-of select="@name"/>( axis2_stub_t *stub, const axutil_env_t *env<xsl:for-each select="input/param[@type!='']">,
<xsl:variable name="inputtype"><xsl:if test="@ours">adb_</xsl:if><xsl:value-of select="@type"/><xsl:if test="@ours">_t*</xsl:if></xsl:variable>
<xsl:value-of select="$inputtype"/><xsl:text> _</xsl:text><xsl:value-of select="@name"/>
+ </xsl:for-each><xsl:for-each select="output/param[@location='soap_header']">,
+ <xsl:variable name="outputtype"><xsl:if test="@ours">adb_</xsl:if><xsl:value-of select="@type"/><xsl:if test="@ours">_t**</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:if>
</xsl:for-each>
@@ -162,12 +164,43 @@
<xsl:value-of select="$inputtype"/><xsl:text> _</xsl:text><xsl:value-of select="@name"/>
</xsl:for-each>,
void *user_data,
- 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"/>, void *data) ,
+ 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:if test="@ours">adb_</xsl:if><xsl:value-of select="@type"/><xsl:if test="@ours">_t*</xsl:if></xsl:variable>
+ <xsl:value-of select="$header_outputtype"/><xsl:text> _</xsl:text><xsl:value-of select="@name"/>
+ </xsl:for-each>, 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'"-->
</xsl:for-each>
</xsl:if> <!--close for test="$isAsync='1'-->
+
+ /**
+ * function to free any soap input headers
+ * @param env environment ( mandatory)
+ */
+ <xsl:for-each select="method">
+ <xsl:if test="input/param[@location='soap_header']">
+ void
+ axis2_stub_op_<xsl:value-of select="$servicename"/>_<xsl:value-of select="@name"/>_free_input_headers(const axutil_env_t *env, <xsl:for-each select="input/param[@location='soap_header']"><xsl:if test="position()!=1">,</xsl:if>
+ <xsl:variable name="inputtype"><xsl:if test="@ours">adb_</xsl:if><xsl:value-of select="@type"/><xsl:if test="@ours">_t*</xsl:if></xsl:variable>
+ <xsl:value-of select="$inputtype"/><xsl:text> _</xsl:text><xsl:value-of select="@name"/>
+ </xsl:for-each>);
+ </xsl:if>
+ </xsl:for-each>
+
+ /**
+ * function to free any soap output headers
+ * @param env environment ( mandatory)
+ */
+ <xsl:for-each select="method">
+ <xsl:if test="output/param[@location='soap_header']">
+ void
+ axis2_stub_op_<xsl:value-of select="$servicename"/>_<xsl:value-of select="@name"/>_free_output_headers(const axutil_env_t *env, <xsl:for-each select="output/param[@location='soap_header']"><xsl:if test="position()!=1">,</xsl:if>
+ <xsl:variable name="outputtype"><xsl:if test="@ours">adb_</xsl:if><xsl:value-of select="@type"/><xsl:if test="@ours">_t*</xsl:if></xsl:variable>
+ <xsl:value-of select="$outputtype"/><xsl:text> _</xsl:text><xsl:value-of select="@name"/>
+ </xsl:for-each>);
+ </xsl:if>
+ </xsl:for-each>
#ifdef __cplusplus
}
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=642802&r1=642801&r2=642802&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 Sun Mar 30 12:11:19 2008
@@ -186,7 +186,9 @@
* for "<xsl:value-of select="@qname"/>" operation.
*<xsl:for-each select="input/param[@type!='']"><xsl:text>
</xsl:text>* @param _<xsl:value-of select="@name"/></xsl:for-each>
- * @return
+ *<xsl:for-each select="output/param[@location='soap_header']"><xsl:text>
+ </xsl:text>* @param dp_<xsl:value-of select="@name"/> - output header</xsl:for-each>
+ * @return <xsl:value-of select="$outputtype"/>
*/
<xsl:choose>
<xsl:when test="$outputtype=''">void</xsl:when> <!--this case is unexpected-->
@@ -196,6 +198,9 @@
axis2_stub_op_<xsl:value-of select="$servicename"/>_<xsl:value-of select="@name"/>( axis2_stub_t *stub, const axutil_env_t *env<xsl:for-each select="input/param[@type!='']">,
<xsl:variable name="inputtype"><xsl:if test="@ours">adb_</xsl:if><xsl:value-of select="@type"/><xsl:if test="@ours">_t*</xsl:if></xsl:variable>
<xsl:value-of select="$inputtype"/><xsl:text> _</xsl:text><xsl:value-of select="@name"/>
+ </xsl:for-each><xsl:for-each select="output/param[@location='soap_header']">,
+ <xsl:variable name="outputtype"><xsl:if test="@ours">adb_</xsl:if><xsl:value-of select="@type"/><xsl:if test="@ours">_t**</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>)
{
axis2_svc_client_t *svc_client = NULL;
@@ -213,9 +218,23 @@
<!-- this means data binding is enable -->
<xsl:value-of select="$outputtype"/> ret_val = NULL;
</xsl:if>
+ <xsl:if test="input/param[@location='soap_header']">
+ axiom_node_t *input_header = NULL;
+ </xsl:if>
+ <xsl:if test="output/param[@location='soap_header']">
+ axis2_op_client_t *op_client = NULL;
+ const axis2_msg_ctx_t *msg_ctx = NULL;
+ axiom_soap_envelope_t *res_soap_env = NULL;
+ axiom_soap_header_t *res_soap_header = NULL;
+ axiom_node_t *header_base_node = NULL;
+ axiom_node_t *output_header = NULL;
+ </xsl:if>
+ <xsl:for-each select="output/param[@location='soap_header']">
+ <xsl:variable name="outputtype"><xsl:if test="@ours">adb_</xsl:if><xsl:value-of select="@type"/><xsl:if test="@ours">_t*</xsl:if></xsl:variable>
+ <xsl:value-of select="$outputtype"/><xsl:text> _</xsl:text><xsl:value-of select="@name"/> = NULL;
+ </xsl:for-each>
-
- <!-- for service client currently suppported only 1 input param -->
+ <!-- for service client the 1st input param is the payload -->
<xsl:variable name="firstParam" select="input/param[1]"/>
<xsl:if test="$firstParam/@type!=''">
<xsl:choose>
@@ -227,15 +246,29 @@
</xsl:otherwise>
</xsl:choose>
</xsl:if>
+ svc_client = axis2_stub_get_svc_client(stub, env );
+ <!-- handling header params -->
+
+ <!-- adding input headers -->
+ <xsl:for-each select="input/param[@location='soap_header']">
+ <xsl:choose>
+ <xsl:when test="@ours">
+ input_header = adb_<xsl:value-of select="@type"/>_serialize(_<xsl:value-of select="@name"/>, env, NULL, NULL, AXIS2_TRUE, NULL, NULL);
+ </xsl:when>
+ <xsl:otherwise>
+ input_header = _<xsl:value-of select="@name"/>;
+ </xsl:otherwise>
+ </xsl:choose>
+ axis2_svc_client_add_header(svc_client, env, input_header);
+ </xsl:for-each>
options = axis2_stub_get_options( stub, env);
- if ( NULL == options )
+ if (NULL == options)
{
AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_NULL_PARAM, AXIS2_FAILURE);
AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "options is null in stub");
return NULL;
}
- svc_client = axis2_stub_get_svc_client(stub, env );
soap_action = axis2_options_get_action( options, env );
if (NULL == soap_action)
{
@@ -263,6 +296,116 @@
axis2_options_set_action( options, env, NULL);
}
+ <!-- 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);
+ if(!op_client)
+ {
+ AXIS2_LOG_ERROR( env->log, AXIS2_LOG_SI, "op client is NULL");
+ return NULL;
+ }
+ msg_ctx = axis2_op_client_get_msg_ctx(op_client, env, AXIS2_WSDL_MESSAGE_LABEL_OUT);
+ if(!msg_ctx)
+ {
+ AXIS2_LOG_ERROR( env->log, AXIS2_LOG_SI, "response msg ctx is NULL");
+ return NULL;
+ }
+ res_soap_env = axis2_msg_ctx_get_response_soap_envelope(msg_ctx, env);
+ if(!res_soap_env)
+ {
+ AXIS2_LOG_ERROR( env->log, AXIS2_LOG_SI, "response evelope is NULL");
+ return NULL;
+ }
+ res_soap_header = axiom_soap_envelope_get_header(res_soap_env, env);
+
+ if(res_soap_header)
+ {
+ header_base_node = axiom_soap_header_get_base_node(res_soap_header, env);
+ }
+
+ if(!header_base_node)
+ {
+ AXIS2_LOG_ERROR( env->log, AXIS2_LOG_SI, "Required response header is NULL");
+ }
+
+ <xsl:for-each select="output/param[@location='soap_header']">
+ <xsl:choose>
+ <xsl:when test="position()=1">
+ output_header = axiom_node_get_first_child(header_base_node, env);
+
+ while(output_header && axiom_node_get_node_type(output_header, env) != AXIOM_ELEMENT)
+ {
+ output_header = axiom_node_get_next_sibling(output_header, env);
+ }
+ </xsl:when>
+ <xsl:otherwise>
+ output_header = axiom_node_get_next_sibling(output_header, env);
+
+ while(output_header && axiom_node_get_node_type(output_header, env) != AXIOM_ELEMENT)
+ {
+ output_header = axiom_node_get_next_sibling(output_header, env);
+ }
+ </xsl:otherwise>
+ </xsl:choose>
+
+ <xsl:variable name="header_var"><xsl:text>_</xsl:text><xsl:value-of select="@name"/></xsl:variable>
+
+ if( NULL == output_header)
+ {
+ AXIS2_LOG_ERROR( env->log, AXIS2_LOG_SI, "Response header <xsl:value-of select="@name"/> is NULL");
+ /* you can't have a response header NULL, just free things and exit */
+ axis2_stub_op_<xsl:value-of select="$servicename"/>_<xsl:value-of select="$method-name"/>_free_output_headers(env, <xsl:for-each select="../../output/param[@location='soap_header']"><xsl:if test="position()!=1">,</xsl:if>
+ <xsl:text> _</xsl:text><xsl:value-of select="@name"/>
+ </xsl:for-each>);
+ <xsl:choose>
+ <xsl:when test="$outputtype=''">
+ return;
+ </xsl:when>
+ <xsl:otherwise>
+ return NULL;
+ </xsl:otherwise>
+ </xsl:choose>
+ }
+ /* you can have these parameters NULL, to avoid deserializing them */
+ if(dp_<xsl:value-of select="@name"/>)
+ {
+ <xsl:choose>
+ <xsl:when test="@ours">
+ <xsl:value-of select="$header_var"/> = adb_<xsl:value-of select="@type"/>_create(env);
+
+ if(adb_<xsl:value-of select="@type"/>_deserialize(<xsl:value-of select="$header_var"/>, env, &output_header, NULL, AXIS2_FALSE ) == AXIS2_FAILURE)
+ {
+ <!-- this too will be freed from the _free_output_headers
+ if(<xsl:value-of select="$header_var"/> != NULL)
+ {
+ adb_<xsl:value-of select="@type"/>_free(<xsl:value-of select="$header_var"/>, env);
+ }-->
+ AXIS2_LOG_ERROR( env->log, AXIS2_LOG_SI, "NULL returnted from the <xsl:value-of select="@type"/>_deserialize: "
+ "This should be due to an invalid output header");
+ axis2_stub_op_<xsl:value-of select="$servicename"/>_<xsl:value-of select="$method-name"/>_free_output_headers(env, <xsl:for-each select="../../output/param[@location='soap_header']"><xsl:if test="position()!=1">,</xsl:if>
+ <xsl:text> _</xsl:text><xsl:value-of select="@name"/>
+ </xsl:for-each>);
+ <xsl:choose>
+ <xsl:when test="$outputtype=''">
+ return;
+ </xsl:when>
+ <xsl:otherwise>
+ return NULL;
+ </xsl:otherwise>
+ </xsl:choose>
+ }
+ </xsl:when>
+ <xsl:otherwise>
+ _<xsl:value-of select="@name"/> = input_header;
+ </xsl:otherwise>
+ </xsl:choose>
+ *dp_<xsl:value-of select="@name"/> = _<xsl:value-of select="@name"/>;
+ }
+
+ <!-- just handle next type-->
+ </xsl:for-each>
+ </xsl:if>
+
<xsl:choose>
<xsl:when test="$outputtype=''">
return;
@@ -297,8 +440,6 @@
</xsl:for-each>
-
-
<xsl:for-each select="method">
<xsl:variable name="outputours"><xsl:value-of select="output/param/@ours"></xsl:value-of></xsl:variable>
<xsl:variable name="outputtype">
@@ -330,7 +471,10 @@
struct axis2_stub_<xsl:value-of select="$servicename"/>_<xsl:value-of select="@name"/>_callback_data
{
void *data;
- 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"/>, void *data);
+ 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:if test="@ours">adb_</xsl:if><xsl:value-of select="@type"/><xsl:if test="@ours">_t*</xsl:if></xsl:variable>
+ <xsl:value-of select="$header_outputtype"/><xsl:text> </xsl:text><xsl:value-of select="@name"/>
+ </xsl:for-each>, void *data);
axis2_status_t ( AXIS2_CALL *on_error ) (const axutil_env_t *, int exception, void *data);
};
@@ -358,10 +502,13 @@
axis2_status_t AXIS2_CALL axis2_stub_on_complete_<xsl:value-of select="$servicename"/>_<xsl:value-of select="@name"/>(axis2_callback_t *callback, const axutil_env_t *env)
{
- 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"/>, void *data);
+ 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:if test="@ours">adb_</xsl:if><xsl:value-of select="@type"/><xsl:if test="@ours">_t*</xsl:if></xsl:variable>
+ <xsl:value-of select="$header_outputtype"/><xsl:text> </xsl:text><xsl:value-of select="@name"/>
+ </xsl:for-each>, 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_status_t status = AXIS2_SUCCESS;
<xsl:if test="output/param/@ours">
<!-- this means data binding is enable -->
@@ -371,6 +518,16 @@
axiom_node_t *ret_node = NULL;
axiom_soap_envelope_t *soap_envelope = NULL;
+ <xsl:if test="output/param[@location='soap_header']">
+ axiom_soap_header_t *res_soap_header = NULL;
+ axiom_node_t *header_base_node = NULL;
+ axiom_node_t *output_header = NULL;
+ </xsl:if>
+ <xsl:for-each select="output/param[@location='soap_header']">
+ <xsl:variable name="outputtype"><xsl:if test="@ours">adb_</xsl:if><xsl:value-of select="@type"/><xsl:if test="@ours">_t*</xsl:if></xsl:variable>
+ <xsl:value-of select="$outputtype"/><xsl:text> _</xsl:text><xsl:value-of select="@name"/> = NULL;
+ </xsl:for-each>
+
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);
@@ -386,6 +543,92 @@
ret_node = axiom_node_get_first_child(body_node, env);
}
}
+ <!-- extract out the headers at this point -->
+ <xsl:if test="output/param[@location='soap_header']">
+ res_soap_header = axiom_soap_envelope_get_header(soap_envelope, env);
+
+ if(res_soap_header)
+ {
+ header_base_node = axiom_soap_header_get_base_node(res_soap_header, env);
+ }
+
+ if(!header_base_node)
+ {
+ AXIS2_LOG_ERROR( env->log, AXIS2_LOG_SI, "Required response header is NULL");
+ }
+ if(header_base_node)
+ {
+ <xsl:for-each select="output/param[@location='soap_header']">
+ if(status == AXIS2_SUCCESS)
+ {
+ <xsl:choose>
+ <xsl:when test="position()=1">
+ output_header = axiom_node_get_first_child(header_base_node, env);
+
+ while(output_header && axiom_node_get_node_type(output_header, env) != AXIOM_ELEMENT)
+ {
+ output_header = axiom_node_get_next_sibling(output_header, env);
+ }
+ </xsl:when>
+ <xsl:otherwise>
+ output_header = axiom_node_get_next_sibling(output_header, env);
+
+ while(output_header && axiom_node_get_node_type(output_header, env) != AXIOM_ELEMENT)
+ {
+ output_header = axiom_node_get_next_sibling(output_header, env);
+ }
+ </xsl:otherwise>
+ </xsl:choose>
+
+ <xsl:variable name="header_var"><xsl:text>_</xsl:text><xsl:value-of select="@name"/></xsl:variable>
+
+ if( NULL == output_header)
+ {
+ AXIS2_LOG_ERROR( env->log, AXIS2_LOG_SI, "Response header <xsl:value-of select="@name"/> is NULL");
+ /* you can't have a response header NULL, just free things and exit */
+ axis2_stub_op_<xsl:value-of select="$servicename"/>_<xsl:value-of select="$method-name"/>_free_output_headers(env, <xsl:for-each select="../../output/param[@location='soap_header']"><xsl:if test="position()!=1">,</xsl:if>
+ <xsl:text> _</xsl:text><xsl:value-of select="@name"/>
+ </xsl:for-each>);
+ status = AXIS2_FAILURE;
+ }
+ else
+ {
+ <xsl:choose>
+ <xsl:when test="@ours">
+ <xsl:value-of select="$header_var"/> = adb_<xsl:value-of select="@type"/>_create(env);
+
+ if(adb_<xsl:value-of select="@type"/>_deserialize(<xsl:value-of select="$header_var"/>, env, &output_header, NULL, AXIS2_FALSE ) == AXIS2_FAILURE)
+ {
+ <!-- this too will be freed from the _free_output_headers function
+ if(<xsl:value-of select="$header_var"/> != NULL)
+ {
+ adb_<xsl:value-of select="@type"/>_free(<xsl:value-of select="$header_var"/>, env);
+ }-->
+ AXIS2_LOG_ERROR( env->log, AXIS2_LOG_SI, "NULL returnted from the <xsl:value-of select="@type"/>_deserialize: "
+ "This should be due to an invalid output header");
+ axis2_stub_op_<xsl:value-of select="$servicename"/>_<xsl:value-of select="$method-name"/>_free_output_headers(env, <xsl:for-each select="../../output/param[@location='soap_header']"><xsl:if test="position()!=1">,</xsl:if>
+ <xsl:text> _</xsl:text><xsl:value-of select="@name"/>
+ </xsl:for-each>);
+ status = AXIS2_FAILURE;
+ }
+ </xsl:when>
+ <xsl:otherwise>
+ _<xsl:value-of select="@name"/> = output_header;
+ </xsl:otherwise>
+ </xsl:choose>
+ }
+ }
+ </xsl:for-each> <!-- for each output header param -->
+
+ <!-- free them if anything goes wrong -->
+ <xsl:for-each select="output/param[@location='soap_header']">
+ if(status == AXIS2_FAILURE)
+ {
+ <xsl:text>_</xsl:text><xsl:value-of select="@name"/> = NULL;
+ }
+ </xsl:for-each>
+ }
+ </xsl:if>
}
user_data = callback_data->data;
@@ -409,10 +652,14 @@
{
ret_val = NULL;
}
- status = on_complete(env, ret_val, user_data);
+ 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:when>
<xsl:otherwise>
- status = on_complete(env, ret_node, user_data);
+ status = on_complete(env, ret_node<xsl:for-each select="output/param[@location='soap_header']">,
+ <xsl:text>_</xsl:text><xsl:value-of select="@name"/>
+ </xsl:for-each>, user_data);
</xsl:otherwise>
</xsl:choose>
@@ -437,7 +684,10 @@
<xsl:value-of select="$inputtype"/><xsl:text> _</xsl:text><xsl:value-of select="@name"/>
</xsl:for-each>,
void *user_data,
- 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"/>, void *data) ,
+ 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:if test="@ours">adb_</xsl:if><xsl:value-of select="@type"/><xsl:if test="@ours">_t*</xsl:if></xsl:variable>
+ <xsl:value-of select="$header_outputtype"/><xsl:text> </xsl:text><xsl:value-of select="@name"/>
+ </xsl:for-each>, void *data) ,
axis2_status_t ( AXIS2_CALL *on_error ) (const axutil_env_t *, int exception, void *data) )
{
@@ -557,6 +807,9 @@
const axis2_char_t *soap_action = NULL;
axutil_qname_t *op_qname = NULL;
axiom_node_t *payload = NULL;
+ <xsl:if test="input/param[@location='soap_header']">
+ axiom_node_t *input_header = NULL;
+ </xsl:if>
<!-- for service client currently suppported only 1 input param -->
<xsl:variable name="firstParam" select="input/param[1]"/>
@@ -571,6 +824,20 @@
</xsl:choose>
</xsl:if>
+ <!-- adding input headers -->
+ <xsl:for-each select="input/param[@location='soap_header']">
+ <xsl:choose>
+ <xsl:when test="@ours">
+ input_header = adb_<xsl:value-of select="@type"/>_serialize(_<xsl:value-of select="@name"/>, env, NULL, NULL, AXIS2_TRUE, NULL, NULL);
+ </xsl:when>
+ <xsl:otherwise>
+ input_header = _<xsl:value-of select="@name"/>;
+ </xsl:otherwise>
+ </xsl:choose>
+ axis2_svc_client_add_header(svc_client, env, input_header);
+ </xsl:for-each>
+
+
options = axis2_stub_get_options( stub, env);
if ( NULL == options )
{
@@ -603,5 +870,66 @@
}
</xsl:if> <!-- close for test="$mep='http://www.w3.org/2004/08/wsdl/in-only' -->
</xsl:for-each> <!-- close of for-each select = "method" -->
+
+
+ /**
+ * function to free any soap input headers
+ */
+ <xsl:for-each select="method">
+ <xsl:if test="input/param[@location='soap_header']">
+ void
+ axis2_stub_op_<xsl:value-of select="$servicename"/>_<xsl:value-of select="@name"/>_free_input_headers(const axutil_env_t *env, <xsl:for-each select="input/param[@location='soap_header']"><xsl:if test="position()!=1">,</xsl:if>
+ <xsl:variable name="inputtype"><xsl:if test="@ours">adb_</xsl:if><xsl:value-of select="@type"/><xsl:if test="@ours">_t*</xsl:if></xsl:variable>
+ <xsl:value-of select="$inputtype"/><xsl:text> _</xsl:text><xsl:value-of select="@name"/>
+ </xsl:for-each>)
+ {
+ <xsl:for-each select="input/param[@location='soap_header']">
+ <xsl:variable name="header_var"><xsl:text>_</xsl:text><xsl:value-of select="@name"/></xsl:variable>
+ <xsl:choose>
+ <xsl:when test="@ours">
+ if(<xsl:value-of select="$header_var"/>)
+ {
+ adb_<xsl:value-of select="@type"/>_free(<xsl:value-of select="$header_var"/>, env);
+ }
+ </xsl:when>
+ <xsl:otherwise>
+ /* we don't have anything to free on <xsl:value-of select="$header_var"/> */
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:for-each>
+ }
+ </xsl:if>
+ </xsl:for-each>
+
+
+ /**
+ * function to free any soap output headers
+ */
+ <xsl:for-each select="method">
+ <xsl:if test="output/param[@location='soap_header']">
+ void
+ axis2_stub_op_<xsl:value-of select="$servicename"/>_<xsl:value-of select="@name"/>_free_output_headers(const axutil_env_t *env, <xsl:for-each select="output/param[@location='soap_header']"><xsl:if test="position()!=1">,</xsl:if>
+ <xsl:variable name="outputtype"><xsl:if test="@ours">adb_</xsl:if><xsl:value-of select="@type"/><xsl:if test="@ours">_t*</xsl:if></xsl:variable>
+ <xsl:value-of select="$outputtype"/><xsl:text> _</xsl:text><xsl:value-of select="@name"/>
+ </xsl:for-each>)
+ {
+ <xsl:for-each select="output/param[@location='soap_header']">
+ <xsl:variable name="header_var"><xsl:text>_</xsl:text><xsl:value-of select="@name"/></xsl:variable>
+ <xsl:choose>
+ <xsl:when test="@ours">
+ if(<xsl:value-of select="$header_var"/>)
+ {
+ adb_<xsl:value-of select="@type"/>_free(<xsl:value-of select="$header_var"/>, env);
+ }
+ </xsl:when>
+ <xsl:otherwise>
+ /* we don't have anything to free on <xsl:value-of select="$header_var"/> */
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:for-each>
+ }
+ </xsl:if>
+ </xsl:for-each>
+
</xsl:template>
</xsl:stylesheet>
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org