You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by robert rowntree <ro...@mindspring.com> on 2002/05/22 00:19:46 UTC
encoding for Array of Datahandler objects
one of the IBM WSTK samples ( attachments ) using RPC has an existing SOAP
"parts" list of :
1.string
2.string []
3.dataHandler for a java class
4.dataHandler for a jpg file
5.dataHandler for an Html file
The practical effect of the sample is to transfer files in above parts 3, 4,
and 5 from the client to the server over HTTP/SOAP.
I want to change this so that an Array of DataHandlers for MIME type text is
passed over the wire.
So my new Parts would be:
1.string
2.string []
3.dataHandler [] for MIME type "text" this is where all my attached files
goes.
and my new WSDL for the interface would look something like
<message name="RPCRequest">
<part name="listTitle" type="xsd:string" />
<part name="fileList" type="types:ArrayOfString" />
<part name="fileArray" type="types:ArrayOfDataHandler" /> // would have
many files here
</message>
- <complexType name="ArrayOfDataHandler">
- <complexContent>
- <restriction base="soapenc:Array">
<attribute ref="soapenc:arrayType" wsdl:arrayType="xsd:DataHandler[]" />
</restriction>
</complexContent>
</complexType>
* * * endof myPropsed WSDL
Can you help me alter the following from the original sample so that an
Array of DataHandlers is encoded correctly as the 3rd part of the RPC:
A. WSDL for the interface ( see below from original )
B. WSDD for the serializer ( for files to be serialized using a
DataHandler )
C. Java file for the Server-side service
*** Original Code from the IBM sample ***
A. * * WSDL for the interface * *
- <xsd:schema xmlns="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.attachment.com/types">
- <complexType name="ArrayOfString">
- <complexContent>
- <restriction base="soapenc:Array">
<attribute ref="soapenc:arrayType" wsdl:arrayType="xsd:string[]" />
</restriction>
</complexContent>
</complexType>
- <complexType name="ArrayOfBinary">
- <complexContent>
- <restriction base="soapenc:Array">
<attribute ref="soapenc:arrayType" wsdl:arrayType="xsd:byte[]" />
</restriction>
</complexContent>
</complexType>
- <complexType name="contentType">
- <simpleContent>
- <extension base="xsd:string">
<attribute name="part" type="xsd:string" />
<attribute name="type" type="xsd:string" />
</extension>
</simpleContent>
</complexType>
- <element name="attachments">
- <complexType>
- <sequence>
<element name="content" type="types:contentType" />
</sequence>
</complexType>
</element>
</xsd:schema>
<message name="RPCRequest">
<part name="listTitle" type="xsd:string" />
<part name="fileList" type="types:ArrayOfString" />
<part name="classFile" type="types:ArrayOfBinary" /> this should change,
but how
<part name="imageFile" type="types:ArrayOfBinary" /> this should change
<part name="htmlFile" type="xsd:string" />
</message>
B. *** WSDD for the serializer
<typeMapping
deserializer="org.apache.axis.encoding.ser.JAFDataHandlerDeserializerFactory
"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
languageSpecificType="java:javax.activation.DataHandler"
qname="ns1:DataHandler"
serializer="org.apache.axis.encoding.ser.JAFDataHandlerSerializerFactory"/>
C. *** Java file for the Server-side service
public class AttachmentService
{
public String THETargetMethod( String listTitle, String[] fileList,
DataHandler classFile, DataHandler imageFile, DataHandler htmlFile)
DataHandler[] dhs= {classFile, imageFile, htmlFile};
String ret=listAttachments( listTitle, fileList, dhs );
...
for(int i=0; i< parts.length; ++i)
{
DataHandler datahandler= null;
Part part= null;
if( parts[i] instanceof Part){
part= (Part) parts[i];
datahandler= AttachmentUtils.getActiviationDataHandler(part);
...
String listAttachments( String listTitle,
String[] fileList,
Object[] parts
)
...
for(int i=0; i< parts.length; ++i)
{
DataHandler datahandler= null;
Part part= null;
if( parts[i] instanceof Part){
part= (Part) parts[i];
datahandler= AttachmentUtils.getActiviationDataHandler(part);
}