DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT <http://nagoya.apache.org/bugzilla/show_bug.cgi?id=18205>. ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND INSERTED IN THE BUG DATABASE.
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=18205 WSDL type mapping broken for non-built-in MIME type attachments Summary: WSDL type mapping broken for non-built-in MIME type attachments Product: Axis Version: 1.1rc2 Platform: PC OS/Version: Windows NT/2K Status: NEW Severity: Normal Priority: Other Component: WSDL processing AssignedTo: [EMAIL PROTECTED] ReportedBy: [EMAIL PROTECTED] While the JAX-RPC standard does not absolutely require the handling of attachments whose MIME type is not one of the five listed in the table of chapter 7.5 of the spec, it says other MIME types may be supported using the generic javax.activation.DataHandler. I believe the intent of Axis is to support such generic MIME types using DataHandler, so that on Call.invoke(), an argument can be a DataHandler or DataHandlerHolder if the attachment type is some weirdo MIME type. Otherwise, Axis could only ever support the current hard-coded types. To wit, the default type mapping implementation in Axis contains: myRegister(Constants.MIME_DATA_HANDLER, javax.activation.DataHandler.class, new JAFDataHandlerSerializerFactory(), new JAFDataHandlerDeserializerFactory()); While it is possible to explicitly set an operation parameter type to use the MIME_DATA_HANDLER type mapping, this doesn't work when the attachment is defined in the WSDL file, where the Service object is prefilled from the WSDL file, and the Call object is then created via Service.CreateCall(). That is, you can't and/or shouldn't have to tweak the OperationDesc parameters once it is built from a WSDL file. In addition, the WSDLtoJava tools choke and abort on WSDL files with such non-built-in MIME type attachments. To fix the service.createCall() problem requires a one line fix. To fix WSDLtoJava requires a few more lines in two files. I realize it may be a bit late to fix these for 1.1, but I hope a maintenance release could use these. Here are the two proposed fixes: =================================================================== RCS file: /home/cvspublic/xml-axis/java/src/org/apache/axis/utils/JavaUtils.java ,v retrieving revision 1.97 diff -u -r1.97 JavaUtils.java --- JavaUtils.java 14 Mar 2003 15:36:06 -0000 1.97 +++ JavaUtils.java 20 Mar 2003 20:59:04 -0000 @@ -1156,7 +1156,7 @@ return "javax.mail.internet.MimeMultipart"; } else { - return null; + return "javax.activation.DataHandler"; } } // mimeToJava =================================================================== and =================================================================== RCS file: /home/cvspublic/xml-axis/java/src/org/apache/axis/wsdl/toJava/Utils.ja va,v retrieving revision 1.74 diff -u -r1.74 Utils.java --- Utils.java 14 Mar 2003 16:14:37 -0000 1.74 +++ Utils.java 20 Mar 2003 21:00:41 -0000 @@ -120,6 +120,8 @@ else if (mimeType.equals("text/xml") || mimeType.equals("application/xml")) { return "org.apache.axis.holders.SourceHolder" + mimeDimensions; + } else { + return "org.apache.axis.holders.DataHandlerHolder" + mimeDimens ions; } } @@ -587,7 +589,7 @@ return "(org.apache.axis.attachments.OctetStream" + mimeDimensi ons + ") " + var + ";"; } else { - return "(" + type.getName() + ") " + var + ";"; + return "(javax.activation.DataHandler" + mimeDimensions + ") " + var + ";"; } } else { @@ -799,7 +801,7 @@ return Constants.MIME_MULTIPART; } else { - return null; + return Constants.MIME_DATA_HANDLER; } } // getMIMEType =================================================================== As a test case, simply run: java -classpath <your classpath> org.apache.axis.wsdl.WSDL2Java -s MyService.wsdl with and without the fix. The WSDL file could be as follows: =================================================================== <?xml version="1.0" ?> <definitions name="urn:GetQuote" targetNamespace="urn:xmltoday-delayed-quotes" xmlns:tns="urn:xmltoday-delayed-quotes" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soape="http://schemas.xmlsoap.org/soap/encoding/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns="http://schemas.xmlsoap.org/wsdl/"> <!-- message declns --> <message name="GetQuoteRequest"> <part name="input" type="xsd:hexBinary"/> </message> <message name="GetQuoteResponse"> <part name="output" type = "xsd:hexBinary"/> </message> <!-- port type declns --> <portType name="GetQuote"> <operation name="getQuote" > <input message="tns:GetQuoteRequest"/> <output message="tns:GetQuoteResponse"/> </operation> </portType> <!-- binding declns --> <binding name="GetQuoteBinding" type="tns:GetQuote"> <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/> <operation name="getQuote"> <soap:operation soapAction="getQuote"/> <input> <mime:multipartRelated> <mime:part> <soap:body use="encoded" namespace="urn:xmltoday-delayed-quotes" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/> </mime:part> <mime:part> <mime:content part="input" type="audio/midi"/> </mime:part> </mime:multipartRelated> </input> <output> <mime:multipartRelated> <mime:part> <soap:body use="encoded" namespace="urn:xmltoday-delayed-quotes" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/> </mime:part> <mime:part> <mime:content part="output" type="video/mpeg"/> </mime:part> </mime:multipartRelated> </output> </operation> </binding> <!-- service decln --> <service name="GetQuoteService"> <port name="GetQuote" binding="tns:GetQuoteBinding"> <soap:address location="http://localhost:8080/axis/services/GetQuote"/> </port> </service> </definitions> =================================================================== Without the bug fix, you get a stack trace... java.lang.NullPointerException at org.apache.axis.wsdl.toJava.Utils.getNewQName(Utils.java:684) at org.apache.axis.wsdl.toJava.JavaStubWriter.writeOperationMap(JavaStub Writer.java:430) at org.apache.axis.wsdl.toJava.JavaStubWriter.writeFileBody(JavaStubWrit er.java:165) at org.apache.axis.wsdl.toJava.JavaWriter.generate(JavaWriter.java:148) at org.apache.axis.wsdl.toJava.JavaBindingWriter.generate(JavaBindingWri ter.java:141) at org.apache.axis.wsdl.toJava.JavaGeneratorFactory$Writers.generate(Jav aGeneratorFactory.java:284) at org.apache.axis.wsdl.gen.Parser.generate(Parser.java:328) at org.apache.axis.wsdl.gen.Parser.access$000(Parser.java:82) at org.apache.axis.wsdl.gen.Parser$WSDLRunnable.run(Parser.java:246) at java.lang.Thread.run(Thread.java:536) Even with this fix, I still noteiced some weirdness, such as the generated stub containing a no-arg constructor for DataHandler (which doesn't exist), but that's probably another tweak somewhere. I'm more concerned with fixing service.createCall(). Gary
