scheu 2002/10/10 10:22:55
Modified: java/src/org/apache/axis/i18n resource.properties
java/src/org/apache/axis/providers/java JavaProvider.java
java/src/org/apache/axis/wsdl Java2WSDL.java
java/src/org/apache/axis/wsdl/fromJava Emitter.java
java/tools/org/apache/axis/tools/ant/wsdl
Java2WsdlAntTask.java
Log:
Following changes are made:
- Added the -use option to Java2WSDL. Valid arguments are literal and encoded.
The default is literal if the style is not rpc.
- The emitter had a setMode() method to set the style. This is changed to
setStyle.
- Change Java2WSDL to properly use the use and style information. Also changed
the emitter to use the Use/Style enums instead of static constant integers.
- JavaProvider now invokes the java2wsdl emitter with the style/use information
from the serviceDesc. Thus all the wires are now hooked up.
Revision Changes Path
1.14 +2 -0 xml-axis/java/src/org/apache/axis/i18n/resource.properties
Index: resource.properties
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/i18n/resource.properties,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- resource.properties 10 Oct 2002 15:12:15 -0000 1.13
+++ resource.properties 10 Oct 2002 17:22:54 -0000 1.14
@@ -1037,3 +1037,5 @@
expectedHeaderParam=Found instance data for {0} in the soap:body instead of the
soap:header.
noReturnParam=Didn''t find specified return QName {0}!
noMsg=No symbol table entry found for message {0}
+j2woptUse00=The use of items in the binding, either LITERAL or ENCODED
+j2woptBadUse00=The value of the use option must be LITERAL or ENCODED
1.87 +3 -11
xml-axis/java/src/org/apache/axis/providers/java/JavaProvider.java
Index: JavaProvider.java
===================================================================
RCS file:
/home/cvs/xml-axis/java/src/org/apache/axis/providers/java/JavaProvider.java,v
retrieving revision 1.86
retrieving revision 1.87
diff -u -r1.86 -r1.87
--- JavaProvider.java 9 Oct 2002 19:06:31 -0000 1.86
+++ JavaProvider.java 10 Oct 2002 17:22:54 -0000 1.87
@@ -373,17 +373,9 @@
String alias = (String)service.getOption("alias");
if(alias != null) emitter.setServiceElementName(alias);
- Style style = serviceDesc.getStyle();
-
- // The emitter should be fixed to support all
- // the Style/Use flavors.
- if (style == Style.RPC) {
- emitter.setMode(Emitter.MODE_RPC);
- } else if (style == Style.DOCUMENT) {
- emitter.setMode(Emitter.MODE_DOCUMENT);
- } else if (style == Style.WRAPPED) {
- emitter.setMode(Emitter.MODE_DOC_WRAPPED);
- }
+ // Set style/use
+ emitter.setStyle(serviceDesc.getStyle());
+ emitter.setUse(serviceDesc.getUse());
emitter.setClsSmart(serviceDesc.getImplClass(), locationUrl);
1.30 +19 -8 xml-axis/java/src/org/apache/axis/wsdl/Java2WSDL.java
Index: Java2WSDL.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/wsdl/Java2WSDL.java,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -r1.29 -r1.30
--- Java2WSDL.java 30 Sep 2002 03:36:06 -0000 1.29
+++ Java2WSDL.java 10 Oct 2002 17:22:54 -0000 1.30
@@ -99,6 +99,7 @@
protected static final int TYPEMAPPING_OPT = 'T';
protected static final int SOAPACTION_OPT = 'A';
protected static final int STYLE_OPT = 'y';
+ protected static final int USE_OPT = 'u';
/**
* Define the understood options. Each CLOptionDescriptor contains:
@@ -197,7 +198,11 @@
new CLOptionDescriptor("style",
CLOptionDescriptor.ARGUMENT_REQUIRED,
STYLE_OPT,
- Messages.getMessage("j2woptStyle00"))
+ Messages.getMessage("j2woptStyle00")),
+ new CLOptionDescriptor("use",
+ CLOptionDescriptor.ARGUMENT_REQUIRED,
+ USE_OPT,
+ Messages.getMessage("j2woptUse00"))
};
@@ -375,14 +380,20 @@
case STYLE_OPT:
value = option.getArgument();
- if (value.equalsIgnoreCase("DOCUMENT")) {
- emitter.setMode(Emitter.MODE_DOCUMENT);
- } else if (value.equalsIgnoreCase("RPC")) {
- emitter.setMode(Emitter.MODE_RPC);
- } else if (value.equalsIgnoreCase("WRAPPED")) {
- emitter.setMode(Emitter.MODE_DOC_WRAPPED);
+ if (value.equalsIgnoreCase("DOCUMENT") ||
+ value.equalsIgnoreCase("RPC") ||
+ value.equalsIgnoreCase("WRAPPED")) {
+ emitter.setStyle(value);
+ } else {
+ System.out.println(Messages.getMessage("j2woptBadStyle00"));
}
+ break;
+ case USE_OPT:
+ value = option.getArgument();
+ if (value.equalsIgnoreCase("LITERAL") ||
+ value.equalsIgnoreCase("ENCODED")) {
+ emitter.setUse(value);
} else {
- System.out.println(Messages.getMessage("j2woptBadStyle00"));
+ System.out.println(Messages.getMessage("j2woptBadUse00"));
}
break;
1.70 +76 -60 xml-axis/java/src/org/apache/axis/wsdl/fromJava/Emitter.java
Index: Emitter.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/wsdl/fromJava/Emitter.java,v
retrieving revision 1.69
retrieving revision 1.70
diff -u -r1.69 -r1.70
--- Emitter.java 10 Oct 2002 15:12:15 -0000 1.69
+++ Emitter.java 10 Oct 2002 17:22:54 -0000 1.70
@@ -69,6 +69,8 @@
import org.apache.axis.description.FaultDesc;
import org.apache.axis.encoding.DefaultTypeMappingImpl;
import org.apache.axis.encoding.TypeMapping;
+import org.apache.axis.enum.Style;
+import org.apache.axis.enum.Use;
import org.apache.axis.utils.ClassUtils;
import org.apache.axis.utils.XMLUtils;
import org.apache.axis.utils.JavaUtils;
@@ -130,10 +132,7 @@
public static final int MODE_IMPLEMENTATION = 2;
// Style Modes
- public static final int MODE_RPC = 0;
- public static final int MODE_DOCUMENT = 1;
- public static final int MODE_DOC_WRAPPED = 2;
-
+
private Class cls;
private Class implCls; // Optional implementation class
private Vector allowedMethods = null; // Names of methods to consider
@@ -149,7 +148,8 @@
private String serviceElementName;
private String targetService = null;
private String description;
- private int mode = MODE_RPC;
+ private Style style = Style.RPC;
+ private Use use = null; // Default depends on style setting
private TypeMapping tm = null; // Registered type mapping
private TypeMapping defaultTM = null; // Default TM
private Namespaces namespaces;
@@ -396,6 +396,15 @@
*/
private void init(int mode) {
+ // Default use depending on setting of style
+ if (use == null) {
+ if (style == Style.RPC) {
+ use = Use.ENCODED;
+ } else {
+ use = Use.LITERAL;
+ }
+ }
+
// Get a default TM if not specified.
if (defaultTM == null) {
defaultTM = DefaultTypeMappingImpl.getSingleton();
@@ -622,8 +631,8 @@
binding.setQName(bindingQName);
SOAPBinding soapBinding = new SOAPBindingImpl();
- String modeStr = (mode == MODE_RPC) ? "rpc" : "document";
- soapBinding.setStyle(modeStr);
+ String styleStr = (style == Style.RPC) ? "rpc" : "document";
+ soapBinding.setStyle(styleStr);
soapBinding.setTransportURI(Constants.URI_SOAP11_HTTP);
binding.addExtensibilityElement(soapBinding);
@@ -834,7 +843,7 @@
}
if (names.size() > 0) {
- if (mode == MODE_DOC_WRAPPED) {
+ if (style == Style.WRAPPED) {
names.clear();
}
oper.setParameterOrdering(names);
@@ -919,8 +928,8 @@
private ExtensibilityElement writeSOAPBody(QName operQName) {
SOAPBody soapBody = new SOAPBodyImpl();
- // for now, if its document, it is literal use.
- if (mode == MODE_RPC) {
+ // for now, if its document, it is literal use.
+ if (use == Use.ENCODED) {
soapBody.setUse("encoded");
soapBody.setEncodingStyles(encodingList);
} else {
@@ -939,7 +948,7 @@
private SOAPFault writeSOAPFault(QName operQName, String faultName) {
SOAPFault soapFault = new SOAPFaultImpl();
- if (mode == MODE_RPC) {
+ if (use == Use.ENCODED) {
soapFault.setUse("encoded");
soapFault.setEncodingStyles(encodingList);
} else {
@@ -1115,47 +1124,7 @@
javaType = JavaUtils.getHolderValueType(javaType);
}
- switch(mode) {
- case MODE_RPC: {
- // Add the type representing the param
- // For convenience, add an element for the param
- // Write <part name=param_name type=param_type>
- QName typeQName =
- types.writeTypeForPart(javaType,
- param.getTypeQName());
- types.writeElementForPart(javaType, param.getTypeQName());
- if (typeQName != null) {
- part.setName(param.getName());
- part.setTypeName(typeQName);
- msg.addPart(part);
- }
- break;
- }
- case MODE_DOCUMENT: {
- // Write the type representing the param.
- // Write the element representing the param
- // If an element was written
- // Write <part name=param_name element=param_element>
- // Else its a simple type,
- // Write <part name=param_name type=param_type>
- QName typeQName =
- types.writeTypeForPart(javaType,
- param.getTypeQName());
- QName elemQName =
- types.writeElementForPart(javaType,
- param.getTypeQName());
- if (elemQName != null) {
- part.setName(param.getName());
- part.setElementName(elemQName);
- msg.addPart(part);
- } else if (typeQName != null) {
- part.setName(param.getName());
- part.setTypeName(typeQName);
- msg.addPart(part);
- }
- break;
- }
- case MODE_DOC_WRAPPED: {
+ if (style == Style.WRAPPED) {
// Write type representing the param
QName typeQName =
types.writeTypeForPart(javaType,
@@ -1190,10 +1159,41 @@
msg.addPart(part);
}
}
- break;
- }
- default:
- // ?? Throw an exception here?
+ } else if (use == Use.ENCODED) {
+ // Add the type representing the param
+ // For convenience, add an element for the param
+ // Write <part name=param_name type=param_type>
+ QName typeQName =
+ types.writeTypeForPart(javaType,
+ param.getTypeQName());
+ types.writeElementForPart(javaType, param.getTypeQName());
+ if (typeQName != null) {
+ part.setName(param.getName());
+ part.setTypeName(typeQName);
+ msg.addPart(part);
+ }
+ } else if (use == Use.LITERAL) {
+ // Write the type representing the param.
+ // Write the element representing the param
+ // If an element was written
+ // Write <part name=param_name element=param_element>
+ // Else its a simple type,
+ // Write <part name=param_name type=param_type>
+ QName typeQName =
+ types.writeTypeForPart(javaType,
+ param.getTypeQName());
+ QName elemQName =
+ types.writeElementForPart(javaType,
+ param.getTypeQName());
+ if (elemQName != null) {
+ part.setName(param.getName());
+ part.setElementName(elemQName);
+ msg.addPart(part);
+ } else if (typeQName != null) {
+ part.setName(param.getName());
+ part.setTypeName(typeQName);
+ msg.addPart(part);
+ }
}
return param.getName();
}
@@ -1698,12 +1698,28 @@
this.defaultTM = defaultTM;
}
- public int getMode() {
- return mode;
+ public Style getStyle() {
+ return style;
+ }
+
+ public void setStyle(String value) {
+ style = Style.getStyle(value);
+ }
+
+ public void setStyle(Style value) {
+ style = value;
+ }
+
+ public Use getUse() {
+ return use;
+ }
+
+ public void setUse(String value) {
+ use = Use.getUse(value);
}
- public void setMode(int mode) {
- this.mode = mode;
+ public void setUse(Use value) {
+ use = value;
}
public ServiceDesc getServiceDesc() {
1.5 +8 -7
xml-axis/java/tools/org/apache/axis/tools/ant/wsdl/Java2WsdlAntTask.java
Index: Java2WsdlAntTask.java
===================================================================
RCS file:
/home/cvs/xml-axis/java/tools/org/apache/axis/tools/ant/wsdl/Java2WsdlAntTask.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- Java2WsdlAntTask.java 26 Sep 2002 20:59:58 -0000 1.4
+++ Java2WsdlAntTask.java 10 Oct 2002 17:22:55 -0000 1.5
@@ -91,6 +91,7 @@
private String stopClasses = null;
private String tm = "1.1";
private String style = null;
+ private String use = null;
// The method executing the task
public void execute() throws BuildException {
@@ -111,6 +112,7 @@
log("\tstopClasses:" + stopClasses, Project.MSG_VERBOSE);
log("\ttypeMappingVersion:" + tm, Project.MSG_VERBOSE);
log("\tstyle:" + style, Project.MSG_VERBOSE);
+ log("\tuse:" + use, Project.MSG_VERBOSE);
log("\toutputImpl:" + outputImpl, Project.MSG_VERBOSE);
log("\tnamespaceImpl:" + namespaceImpl, Project.MSG_VERBOSE);
log("\tlocationImport:" + locationImport, Project.MSG_VERBOSE);
@@ -148,14 +150,13 @@
emitter.setDefaultTypeMapping(DefaultSOAP12TypeMappingImpl.create());
}
if (style != null) {
- if (style.equalsIgnoreCase("DOCUMENT")) {
- emitter.setMode(Emitter.MODE_DOCUMENT);
- } else if (style.equalsIgnoreCase("RPC")) {
- emitter.setMode(Emitter.MODE_RPC);
- } else if (style.equalsIgnoreCase("WRAPPED")) {
- emitter.setMode(Emitter.MODE_DOC_WRAPPED);
- }
+ emitter.setStyle(style);
}
+
+ if (use != null) {
+ emitter.setUse(use);
+ }
+
if (input != null) {
emitter.setInputWSDL(input);
}