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 2004/10/27 06:26:00 UTC
cvs commit: ws-axis/java/src/org/apache/axis/wsdl/fromJava Emitter.java Types.java
dims 2004/10/26 21:25:59
Modified: java/src/org/apache/axis/wsdl/fromJava Emitter.java
Types.java
Log:
Patch from Jonathan Colwell - "parameter and result namespaces"
=============== Notes from Jonathan ===================
I found that the while the parameter and return value namespaces
specified by OperationDesc.getReturnQName() and ParamDesc.getQName()
would show up the in SOAP messages, the WSDL for my Doc/Lit/Wrapped
service said nothing about them. Since I'm working on an implementation
of JSR-181 (Web Service Metadata) and that spec dictates that WSDL be
able to display this namespace, I have put together the attached patch
modifying Emitter.java and Types.java in the
org.apache.axis.wsdl.fromJava package.
Within Types.java I have simply overloaded
writeWrappedParameter(Element, String, QName, Class) to take a QName for
the second parameter writeWrappedParameter(Element, QName, QName, Class)
thus preserving compatibility with exiting code.
There was a comment in Emitter.java indicating that the author had
considered using QName rather than just the LocalPart so perhaps there
is a legitimate reason not to use QNames here, but the fix appears to
satisfy what the 181 spec is looking to accomplish. I have not yet
checked whether other areas of the wsdl.fromJava code could make use of
a similar change and until it is decided that this change is worth
making, there is no sense messing with a bunch of other functions.
=============================================
Revision Changes Path
1.130 +19 -6 ws-axis/java/src/org/apache/axis/wsdl/fromJava/Emitter.java
Index: Emitter.java
===================================================================
RCS file: /home/cvs/ws-axis/java/src/org/apache/axis/wsdl/fromJava/Emitter.java,v
retrieving revision 1.129
retrieving revision 1.130
diff -u -r1.129 -r1.130
--- Emitter.java 9 Oct 2004 19:43:20 -0000 1.129
+++ Emitter.java 27 Oct 2004 04:25:59 -0000 1.130
@@ -1641,13 +1641,20 @@
? oper.getAllInParams()
: oper.getAllOutParams();
+ String defaultNamespace = oper.getParent().getDefaultNamespace();
if (!request) {
- String retName;
-
+ QName retName;
+
if (oper.getReturnQName() == null) {
- retName = oper.getName() + "Return";
+ retName = new QName(oper.getName() + "Return");
} else {
- retName = oper.getReturnQName().getLocalPart();
+ if (defaultNamespace
+ .equals(oper.getReturnQName().getNamespaceURI())) {
+ retName =
+ new QName(oper.getReturnQName().getLocalPart());
+ } else {
+ retName = oper.getReturnQName();
+ }
}
types.writeWrappedParameter(sequence, retName,
@@ -1661,12 +1668,18 @@
// avoid headers
if (!parameter.isInHeader() && !parameter.isOutHeader())
{
+ QName paramName = parameter.getQName();
+ if (oper.getReturnQName() != null && defaultNamespace
+ .equals(paramName.getNamespaceURI())) {
+ paramName = new QName(oper.getReturnQName()
+ .getLocalPart());
+ }
types.writeWrappedParameter(sequence,
- parameter.getName(), // QName??
+ paramName,
parameter.getTypeQName(),
parameter.getJavaType());
}
- }
+ }
}
// Finally write the part itself
1.100 +19 -0 ws-axis/java/src/org/apache/axis/wsdl/fromJava/Types.java
Index: Types.java
===================================================================
RCS file: /home/cvs/ws-axis/java/src/org/apache/axis/wsdl/fromJava/Types.java,v
retrieving revision 1.99
retrieving revision 1.100
diff -u -r1.99 -r1.100
--- Types.java 16 Jul 2004 15:11:37 -0000 1.99
+++ Types.java 27 Oct 2004 04:25:59 -0000 1.100
@@ -558,6 +558,25 @@
return null;
}
+
+
+ public void writeWrappedParameter(
+ Element sequence, QName name, QName type, Class javaType)
+ throws AxisFault {
+ String ns = name.getNamespaceURI();
+ String prefixedName;
+ if (ns != null && ns.length() > 0) {
+ writeTypeNamespace(ns);
+ String prefix = namespaces.getCreatePrefix(name.getNamespaceURI());
+ prefixedName = prefix + ":" + name.getLocalPart();
+ }
+ else {
+ prefixedName = name.getLocalPart();
+ }
+ writeWrappedParameter(sequence, prefixedName, type, javaType);
+ }
+
+
/**
* Write a parameter (a sub-element) into a sequence generated by
* writeWrapperElement() above.