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 na...@apache.org on 2007/01/31 07:20:05 UTC
svn commit: r501745 - in
/webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp:
BeanParamWriter.java ClientStubWriter.java literal/ClientStubWriter.java
Author: nadiramra
Date: Tue Jan 30 22:20:04 2007
New Revision: 501745
URL: http://svn.apache.org/viewvc?view=rev&rev=501745
Log:
Remove redundant code between literal and encoded and sync up so that the code
is easier to compare.
Modified:
webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/BeanParamWriter.java
webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/ClientStubWriter.java
webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/literal/ClientStubWriter.java
Modified: webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/BeanParamWriter.java
URL: http://svn.apache.org/viewvc/webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/BeanParamWriter.java?view=diff&rev=501745&r1=501744&r2=501745
==============================================================================
--- webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/BeanParamWriter.java (original)
+++ webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/BeanParamWriter.java Tue Jan 30 22:20:04 2007
@@ -315,6 +315,33 @@
}
+ private void writeSerializeExtensionCode() throws IOException, WrapperFault
+ {
+ // TODO: xsd:extension not fully or correctly supported.
+ if (extensionBaseAttrib != null)
+ {
+ String typeName = extensionBaseAttrib.getTypeName();
+
+ if (extensionBaseAttrib.isSimpleType())
+ {
+ writer.write("\tpSZ->serializeAsChardata((void*)");
+ if (!CUtils.isPointerType(typeName))
+ writer.write("&");
+ writer.write("(param->" + extensionBaseAttrib.getParamNameAsMember() + "), "
+ + CUtils.getXSDTypeForBasicType(typeName) + ");\n");
+ }
+ else
+ {
+ // TODO
+ }
+ }
+ else if (attribs.length == 0)
+ {
+ System.out.println("Possible error in class " + classname
+ + ": class with no attributes or elements...........");
+ }
+ }
+
private void writeSerializeGlobalMethod() throws IOException, WrapperFault
{
/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
@@ -332,61 +359,49 @@
writer.write( "int Axis_Serialize_" + classname
+ "( " + classname + "* param, IWrapperSoapSerializer* pSZ, bool bArray)\n");
writer.write( "{\n");
+
+ //=============================================================================
+ // No attributes or elements to serialize? Then serialize extension and return.
+ //=============================================================================
if (attribs.length == 0)
{
writer.write("\tpSZ->serialize(\">\", NULL);\n");
- if (extensionBaseAttrib != null)
- {
- String typeName = extensionBaseAttrib.getTypeName();
-
- if (extensionBaseAttrib.isSimpleType())
- {
- writer.write("\tpSZ->serializeAsChardata((void*)");
-
- if (!CUtils.isPointerType(typeName))
- writer.write("&");
-
- writer.write("(param->" + extensionBaseAttrib.getParamNameAsMember()
- + "), " + CUtils.getXSDTypeForBasicType(typeName) + ");\n");
- }
- else
- {
- // TODO
- }
- }
- else
- {
- System.out.println("Possible error in class " + classname
- + ": class with no attributes....................");
- }
+ writeSerializeExtensionCode();
writer.write("\treturn AXIS_SUCCESS;\n");
writer.write("}\n\n");
return;
}
- String arrayType;
-
-
- /*
- * A type does not know whether it is used as a nillable parameter So
- * this may not be the appropriate place to do this
- */
+ //=============================================================================
+ // NULL param passed in? Assume nillable although type does not know whether
+ // it is used as a nillable parameter so this may not be the appropriate place
+ // to put this, or we need to find a way to determine if nillable.
+ //=============================================================================
+
writer.write("\tif ( param == NULL )\n\t{\n");
writer.write("\t\tpSZ->serializeAsAttribute( \"xsi:nil\", 0, (void*)&(xsd_boolean_true), XSD_BOOLEAN);\n");
writer.write("\t\tpSZ->serialize( \">\", NULL);\n");
writer.write("\t\treturn AXIS_SUCCESS;\n");
writer.write("\t}\n\n");
- /*
- * This is the only real difference for the serializer between rpc/encoded and doc/literal objects
- */
+
+ //=============================================================================
+ // Serialize
+ // This is the only real difference for the serializer between rpc/encoded and
+ // doc/literal objects
+ //=============================================================================
+
if (wscontext.getWrapInfo().getWrapperStyle().equals("rpc"))
writeRPCArrayPortionOfSerializeGlobalMethod();
else
writeDOCArrayPortionOfSerializeGlobalMethod();
+ //=============================================================================
+ // Serialize attributes, if any
+ //=============================================================================
+
writer.write("\t/* If there are any attributes serialize them. If there aren't then close the tag */\n");
for (int i = 0; i < attributeParamCount; i++)
{
@@ -433,7 +448,11 @@
}
}
}
-
+
+ //=============================================================================
+ // Serialization relating to faults
+ //=============================================================================
+
if (type.isFault())
{
writer.write("\tif(Axis_URI_" + classname + ")\n\t{\n");
@@ -448,29 +467,21 @@
if(wscontext.getWrapInfo().getWrapperStyle().equals("document"))
writer.write("\tpSZ->serialize( \">\", 0);\n");
- // TODO: xsd:extension not fully or correctly supported.
- if (extensionBaseAttrib != null)
- {
- String typeName = extensionBaseAttrib.getTypeName();
-
- if (extensionBaseAttrib.isSimpleType())
- {
- writer.write("\tpSZ->serializeAsChardata((void*)");
- if (!CUtils.isPointerType(typeName))
- writer.write("&");
- writer.write("(param->" + extensionBaseAttrib.getParamNameAsMember() + "), "
- + CUtils.getXSDTypeForBasicType(typeName) + ");\n");
- }
- else
- {
- // TODO
- }
- }
-
+ //=============================================================================
+ // Serialize extension, if any
+ //=============================================================================
+
+ writeSerializeExtensionCode();
+
+ //=============================================================================
+ // Serialize elements, if any
+ //=============================================================================
+
writer.write("\n\t/* then serialize elements if any*/\n");
boolean firstIfWritten = false;
int anyCounter = 0; //counter for any types.
+ String arrayType;
for (int i = attributeParamCount; i < attribs.length; i++)
{
@@ -639,13 +650,16 @@
writer.write("\t}\n");
}
+ //=============================================================================
+ // End of attribute and element serialization
+ //=============================================================================
+
if (wscontext.getWrapInfo().getWrapperStyle().equals("rpc"))
{
writer.write("\n\tpSZ->serialize(\"</\", Axis_TypeName_" + classname
+ ", \">\", NULL);\n");
}
-
writer.write("\n\tif (!bArray && blnIsNewPrefix)\n");
writer.write("\t\tpSZ->removeNamespacePrefix(Axis_URI_" + classname + ");\n");
writer.write("\n");
@@ -715,6 +729,40 @@
writer.write( "\t}\n\n");
}
+ private void writeDeSerializeExtensionCode() throws IOException, WrapperFault
+ {
+ if (extensionBaseAttrib != null
+ && extensionBaseAttrib.getTypeName() != null)
+ {
+ if (extensionBaseAttrib.isSimpleType())
+ {
+ writer.write("\tvoid* pCharDataAs;\n");
+ String typeName = extensionBaseAttrib.getTypeName();
+ String xsdType = CUtils.getXSDTypeForBasicType(typeName);
+ writer.write("\tpIWSDZ->getChardataAs(&pCharDataAs, " + xsdType + ");\n");
+ writer.write("\tparam->" + extensionBaseAttrib.getParamNameAsMember() + " = ");
+
+ if (CUtils.isPointerType(typeName))
+ writer.write("(" + typeName + ") pCharDataAs;\n");
+ else
+ {
+ writer.write(" *(" + typeName + "*) pCharDataAs;\n");
+ writer.write("\tAxis::AxisDelete( pCharDataAs, " + xsdType + ");\n");
+ }
+ }
+ else
+ {
+ // TODO
+ }
+ }
+ else if (attribs.length == 0)
+ {
+ System.out.println("Possible error in class " + classname
+ + ": class with no attributes or elements............");
+
+ }
+ }
+
private void writeDeSerializeGlobalMethod() throws IOException, WrapperFault
{
/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
@@ -732,42 +780,23 @@
writer.write("int Axis_DeSerialize_" + classname + "(" + classname
+ "* param, IWrapperSoapDeSerializer* pIWSDZ)\n{\n");
+ //=============================================================================
+ // No attributes or elements to deserialize? Then deserialize extension and return.
+ //=============================================================================
+
if (attribs.length == 0)
{
- if (extensionBaseAttrib != null)
- {
- if (extensionBaseAttrib.isSimpleType())
- {
- writer.write("\tvoid* pCharDataAs;\n\n");
- String typeName = extensionBaseAttrib.getTypeName();
- String xsdType = CUtils.getXSDTypeForBasicType(typeName);
- writer.write("\tpIWSDZ->getChardataAs(&pCharDataAs, " + xsdType + ");\n");
- writer.write("\tparam->" + extensionBaseAttrib.getParamNameAsMember() + " = ");
-
- if (CUtils.isPointerType(typeName))
- writer.write("(" + typeName + ") pCharDataAs;\n");
- else
- {
- writer.write(" *(" + typeName + "*) pCharDataAs;\n");
- writer.write("\tAxis::AxisDelete( pCharDataAs, " + xsdType + ");\n");
- }
- }
- else
- {
- // TODO
- }
- }
- else
- {
- System.out.println("Possible error in class " + classname
- + ": class with no attributes....................");
- }
+ writeDeSerializeExtensionCode();
writer.write("\treturn AXIS_SUCCESS;\n");
writer.write("}\n\n");
return;
}
+ //=============================================================================
+ // Deserialize attributes and elements.
+ //=============================================================================
+
String arrayType = null;
boolean peekCalled = false;
boolean firstIfWritten = false;
@@ -1014,31 +1043,12 @@
if (attribs[i].getMinOccurs() == 0)
writer.write("\t}\n");
}
-
- if (extensionBaseAttrib != null
- && extensionBaseAttrib.getTypeName() != null)
- {
- if (extensionBaseAttrib.isSimpleType())
- {
- writer.write("\tvoid* pCharDataAs;\n");
- String typeName = extensionBaseAttrib.getTypeName();
- String xsdType = CUtils.getXSDTypeForBasicType(typeName);
- writer.write("\tpIWSDZ->getChardataAs(&pCharDataAs, " + xsdType + ");\n");
- writer.write("\tparam->" + extensionBaseAttrib.getParamNameAsMember() + " = ");
-
- if (CUtils.isPointerType(typeName))
- writer.write("(" + typeName + ") pCharDataAs;\n");
- else
- {
- writer.write(" *(" + typeName + "*) pCharDataAs;\n");
- writer.write("\tAxis::AxisDelete( pCharDataAs, " + xsdType + ");\n");
- }
- }
- else
- {
- // TODO
- }
- }
+
+ //=============================================================================
+ // Deserialize extension, if any, and return status
+ //=============================================================================
+
+ writeDeSerializeExtensionCode();
writer.write("\treturn pIWSDZ->getStatus();\n");
writer.write("}\n");
Modified: webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/ClientStubWriter.java
URL: http://svn.apache.org/viewvc/webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/ClientStubWriter.java?view=diff&rev=501745&r1=501744&r2=501745
==============================================================================
--- webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/ClientStubWriter.java (original)
+++ webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/ClientStubWriter.java Tue Jan 30 22:20:04 2007
@@ -125,9 +125,8 @@
}
/*
- * (non-Javadoc)
- *
* @see org.apache.axis.wsdl.wsdl2ws.cpp.HeaderFileWriter#writeMethods()
+ * Used by literal code too!
*/
protected void writeMethods() throws WrapperFault
{
Modified: webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/literal/ClientStubWriter.java
URL: http://svn.apache.org/viewvc/webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/literal/ClientStubWriter.java?view=diff&rev=501745&r1=501744&r2=501745
==============================================================================
--- webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/literal/ClientStubWriter.java (original)
+++ webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/literal/ClientStubWriter.java Tue Jan 30 22:20:04 2007
@@ -60,10 +60,10 @@
/**
* This method genarate methods that wraps the each method of the service
- * @param methodName
- * @param params
- * @param outparam
+ * @param MethodInfo
* @throws IOException
+ * @throws WrapperFault
+ *
*/
public void writeMethodInWrapper (MethodInfo minfo) throws WrapperFault, IOException
@@ -121,7 +121,7 @@
//=============================================================================
writer.write ("\n/*\n");
- writer.write (" * This method wrap the service method" + methodName + "\n");
+ writer.write (" * This method wraps the service method" + methodName + "\n");
writer.write (" */\n");
//method signature
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org