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 ds...@apache.org on 2006/10/17 19:38:34 UTC
svn commit: r464972 - in /webservices/axis2/branches/java/1_1/modules:
codegen/src/org/apache/axis2/wsdl/codegen/emitter/
jibx/src/org/apache/axis2/jibx/ jibx/src/org/apache/axis2/jibx/template/
Author: dsosnoski
Date: Tue Oct 17 10:38:33 2006
New Revision: 464972
URL: http://svn.apache.org/viewvc?view=rev&rev=464972
Log:
Fix Fault handling for JiBX data binding
Modified:
webservices/axis2/branches/java/1_1/modules/codegen/src/org/apache/axis2/wsdl/codegen/emitter/AxisServiceBasedMultiLanguageEmitter.java
webservices/axis2/branches/java/1_1/modules/jibx/src/org/apache/axis2/jibx/CodeGenerationUtility.java
webservices/axis2/branches/java/1_1/modules/jibx/src/org/apache/axis2/jibx/template/JibXDatabindingTemplate.xsl
Modified: webservices/axis2/branches/java/1_1/modules/codegen/src/org/apache/axis2/wsdl/codegen/emitter/AxisServiceBasedMultiLanguageEmitter.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/1_1/modules/codegen/src/org/apache/axis2/wsdl/codegen/emitter/AxisServiceBasedMultiLanguageEmitter.java?view=diff&rev=464972&r1=464971&r2=464972
==============================================================================
--- webservices/axis2/branches/java/1_1/modules/codegen/src/org/apache/axis2/wsdl/codegen/emitter/AxisServiceBasedMultiLanguageEmitter.java (original)
+++ webservices/axis2/branches/java/1_1/modules/codegen/src/org/apache/axis2/wsdl/codegen/emitter/AxisServiceBasedMultiLanguageEmitter.java Tue Oct 17 10:38:33 2006
@@ -1143,7 +1143,14 @@
// finish with any extra information from service and operations
Parameter details = axisService.getParameter(Constants.DATABINDING_SERVICE_DETAILS);
if (details != null) {
- rootElement.appendChild(doc.importNode((Element)details.getValue(), true));
+ Object value = details.getValue();
+ if (value instanceof Element) {
+ rootElement.appendChild(doc.importNode((Element)value, true));
+ } else if (value instanceof List) {
+ for (Iterator iter = ((List)value).iterator(); iter.hasNext();) {
+ rootElement.appendChild(doc.importNode((Element)iter.next(), true));
+ }
+ }
}
for (Iterator operationsIterator = axisService.getOperations(); operationsIterator.hasNext();) {
AxisOperation axisOperation = (AxisOperation) operationsIterator.next();
Modified: webservices/axis2/branches/java/1_1/modules/jibx/src/org/apache/axis2/jibx/CodeGenerationUtility.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/1_1/modules/jibx/src/org/apache/axis2/jibx/CodeGenerationUtility.java?view=diff&rev=464972&r1=464971&r2=464972
==============================================================================
--- webservices/axis2/branches/java/1_1/modules/jibx/src/org/apache/axis2/jibx/CodeGenerationUtility.java (original)
+++ webservices/axis2/branches/java/1_1/modules/jibx/src/org/apache/axis2/jibx/CodeGenerationUtility.java Tue Oct 17 10:38:33 2006
@@ -209,6 +209,9 @@
int opindex = 0;
Map typeMappedClassMap = new HashMap();
String mappedclass = null;
+ Set objins = new HashSet();
+ Set objouts = new HashSet();
+ Set objfaults = new HashSet();
while (operations.hasNext()) {
// get the basic operation information
@@ -253,15 +256,24 @@
// concrete mappings, just save the mapped class name(s)
if (inmsg != null) {
mappedclass = mapMessage(inmsg, elementMap);
+ objins.add(mappedclass);
}
if (outmsg != null) {
mappedclass = mapMessage(outmsg, elementMap);
+ objouts.add(mappedclass);
}
}
+
+ // always handle faults as wrapped
+ for (Iterator iter = op.getFaultMessages().iterator(); iter.hasNext();) {
+ mappedclass = mapMessage((AxisMessage)iter.next(), elementMap);
+ objfaults.add(mappedclass);
+ }
}
// add type usage information as service parameter
+ List details = new ArrayList();
Element bindinit = doc.createElement("initialize-binding");
if (!typeMappedClassMap.isEmpty()) {
for (Iterator iter = typeMappedClassMap.keySet().iterator(); iter.hasNext();) {
@@ -279,7 +291,28 @@
}
}
bindinit.setAttribute("bound-class", mappedclass);
- codeGenConfig.getAxisService().addParameter(new Parameter(Constants.DATABINDING_SERVICE_DETAILS, bindinit));
+ details.add(bindinit);
+
+ // add details for all objects used as inputs/outputs/faults
+ for (Iterator iter = objins.iterator(); iter.hasNext();) {
+ String classname = (String)iter.next();
+ Element detail = doc.createElement("object-input");
+ detail.setAttribute("type", classname);
+ details.add(detail);
+ }
+ for (Iterator iter = objouts.iterator(); iter.hasNext();) {
+ String classname = (String)iter.next();
+ Element detail = doc.createElement("object-output");
+ detail.setAttribute("type", classname);
+ details.add(detail);
+ }
+ for (Iterator iter = objfaults.iterator(); iter.hasNext();) {
+ String classname = (String)iter.next();
+ Element detail = doc.createElement("object-fault");
+ detail.setAttribute("type", classname);
+ details.add(detail);
+ }
+ codeGenConfig.getAxisService().addParameter(new Parameter(Constants.DATABINDING_SERVICE_DETAILS, details));
} catch (FileNotFoundException e) {
throw new RuntimeException(e);
Modified: webservices/axis2/branches/java/1_1/modules/jibx/src/org/apache/axis2/jibx/template/JibXDatabindingTemplate.xsl
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/1_1/modules/jibx/src/org/apache/axis2/jibx/template/JibXDatabindingTemplate.xsl?view=diff&rev=464972&r1=464971&r2=464972
==============================================================================
--- webservices/axis2/branches/java/1_1/modules/jibx/src/org/apache/axis2/jibx/template/JibXDatabindingTemplate.xsl (original)
+++ webservices/axis2/branches/java/1_1/modules/jibx/src/org/apache/axis2/jibx/template/JibXDatabindingTemplate.xsl Tue Oct 17 10:38:33 2006
@@ -21,39 +21,6 @@
</xsl:for-each>
};
</xsl:if>
-
- <xsl:variable name="firstType"><xsl:value-of select="param[1]/@type"/></xsl:variable>
-
- <xsl:for-each select="param[not(@type = preceding-sibling::param/@type)]">
- <xsl:if test="@type!=''">
-
- private org.apache.axiom.om.OMElement toOM(<xsl:value-of select="@type"/> param, org.apache.axiom.soap.SOAPFactory factory, boolean optimizeContent) {
- if (param instanceof org.jibx.runtime.IMarshallable){
- if (bindingFactory == null) {
- throw new RuntimeException("Could not find JiBX binding information for <xsl:value-of select="$firstType"/>, JiBX binding unusable");
- }
- org.jibx.runtime.IMarshallable marshallable =
- (org.jibx.runtime.IMarshallable)param;
- int index = marshallable.JiBX_getIndex();
- org.apache.axis2.jibx.JiBXDataSource source =
- new org.apache.axis2.jibx.JiBXDataSource(marshallable, bindingFactory);
- org.apache.axiom.om.OMNamespace namespace = factory.createOMNamespace(bindingFactory.getElementNamespaces()[index], null);
- return factory.createOMElement(source, bindingFactory.getElementNames()[index], namespace);
- } else {
- throw new RuntimeException("No JiBX <mapping> defined for class <xsl:value-of select="@type"/>");
- }
- }
-
- private org.apache.axiom.soap.SOAPEnvelope toEnvelope(org.apache.axiom.soap.SOAPFactory factory, <xsl:value-of select="@type"/> param, boolean optimizeContent) {
- org.apache.axiom.soap.SOAPEnvelope envelope = factory.getDefaultEnvelope();
- if (param != null){
- envelope.getBody().addChild(toOM(param, factory, optimizeContent));
- }
- return envelope;
- }
-
- </xsl:if>
- </xsl:for-each>
/**
* get the default envelope
@@ -67,13 +34,7 @@
java.lang.Class type,
java.util.Map extraNamespaces) {
try {
- if (bindingFactory == null) {
- throw new RuntimeException("Could not find JiBX binding information for com.sosnoski.seismic.jibxsoap.Query, JiBX binding unusable");
- }
- org.jibx.runtime.impl.UnmarshallingContext ctx =
- (org.jibx.runtime.impl.UnmarshallingContext)bindingFactory.createUnmarshallingContext();
- org.jibx.runtime.IXMLReader reader = new org.jibx.runtime.impl.StAXReaderWrapper(param.getXMLStreamReaderWithoutCaching(), "SOAP-message", true);
- ctx.setDocument(reader);
+ org.jibx.runtime.impl.UnmarshallingContext ctx = getNewUnmarshalContext(param);
return ctx.unmarshalElement(type);
} catch (Exception e) {
throw new RuntimeException(e);
@@ -92,6 +53,65 @@
</xsl:when>
</xsl:choose>
</xsl:if>
+
+ <xsl:choose>
+ <xsl:when test="$context='message-receiver'">
+ <xsl:apply-templates select="object-output"/>
+ <xsl:apply-templates select="object-fault"/>
+ </xsl:when>
+ <xsl:when test="$context='interface-implementation'">
+ <xsl:apply-templates select="object-input"/>
+ </xsl:when>
+ </xsl:choose>
+
+ </xsl:template>
+
+
+ <!--
+ toOM AND toEnvelope METHOD GENERATION
+ -->
+ <xsl:template match="object-input|object-output">
+
+ private org.apache.axiom.om.OMElement toOM(<xsl:value-of select="@type"/> param, org.apache.axiom.soap.SOAPFactory factory, boolean optimizeContent) {
+ <xsl:call-template name="toOM-method-body"/>
+ }
+ <xsl:call-template name="toEnvelope-method"/>
+ </xsl:template>
+
+ <xsl:template match="object-fault">
+
+ private org.apache.axiom.om.OMElement toOM(<xsl:value-of select="@type"/> param, boolean optimizeContent) {
+ org.apache.axiom.om.OMFactory factory = org.apache.axiom.om.OMAbstractFactory.getOMFactory();
+ <xsl:call-template name="toOM-method-body"/>
+ }
+ </xsl:template>
+
+ <xsl:template name="toOM-method-body">
+ if (param instanceof org.jibx.runtime.IMarshallable){
+ if (bindingFactory == null) {
+ throw new RuntimeException(bindingErrorMessage);
+ }
+ org.jibx.runtime.IMarshallable marshallable =
+ (org.jibx.runtime.IMarshallable)param;
+ int index = marshallable.JiBX_getIndex();
+ org.apache.axis2.jibx.JiBXDataSource source =
+ new org.apache.axis2.jibx.JiBXDataSource(marshallable, bindingFactory);
+ org.apache.axiom.om.OMNamespace namespace = factory.createOMNamespace(bindingFactory.getElementNamespaces()[index], null);
+ return factory.createOMElement(source, bindingFactory.getElementNames()[index], namespace);
+ } else {
+ throw new RuntimeException("No JiBX <mapping> defined for class <xsl:value-of select="@type"/>");
+ }
+ </xsl:template>
+
+ <xsl:template name="toEnvelope-method">
+
+ private org.apache.axiom.soap.SOAPEnvelope toEnvelope(org.apache.axiom.soap.SOAPFactory factory, <xsl:value-of select="@type"/> param, boolean optimizeContent) {
+ org.apache.axiom.soap.SOAPEnvelope envelope = factory.getDefaultEnvelope();
+ if (param != null){
+ envelope.getBody().addChild(toOM(param, factory, optimizeContent));
+ }
+ return envelope;
+ }
</xsl:template>
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org