users@jax-rpc.java.net

Re: DII with complex types?

From: Arun Gupta <arun.gupta_at_Sun.COM>
Date: Fri, 12 Apr 2002 11:56:30 -0700

Hi Michael,

com.sun APIs are all internal to the JAX-RPC implementation. Javadocs
are available for the standard classes defined by the specification.

Thanks,
-Arun

YAWN,MICHAEL (HP-Cupertino,ex1) wrote:

>Thanks! This is exactly what I needed.
>
>Are there javadocs available for the com.sun.xml.rpc.encoding
>classes? They aren't included in the docs for either the EA1
>or EA2 releases. I'd like to create some tables that
>summarize the API calls.
>
>Mike
>
>>-----Original Message-----
>>From: Arun Gupta [mailto:arun.gupta_at_SUN.COM]
>>Sent: Friday, April 12, 2002 10:43 AM
>>To: JAXRPC-INTEREST_at_JAVA.SUN.COM
>>Subject: Re: DII with complex types?
>>
>>
>> Hi Michael,
>>
>>Consider the following WSDL (for String[]):
>>
>><complexType name="ArrayOfstring">
>> <complexContent>
>> <restriction base="soap-enc:Array">
>> <attribute ref="soap-enc:arrayType"
>>wsdl:arrayType="string[]" />
>> </restriction>
>> </complexContent>
>></complexType>
>>
>>Your DII client code needs to register the serializer for String[] in
>>the type mapping registry. You do it using the following steps:
>>
>>1). Include the following import statements in your code:
>>import javax.xml.rpc.Service;
>>import javax.xml.rpc.namespace.QName;
>>import com.sun.xml.rpc.encoding.SimpleTypeSerializer;
>>import com.sun.xml.rpc.encoding.CombinedSerializer;
>>import com.sun.xml.rpc.encoding.simpletype.XSDStringEncoder;
>>import com.sun.xml.rpc.encoding.SimpleTypeArraySerializer;
>>import com.sun.xml.rpc.encoding.ReferenceableSerializerImpl;
>>import com.sun.xml.rpc.encoding.SingletonSerializerFactory;
>>import com.sun.xml.rpc.encoding.SingletonDeserializerFactory;
>>import javax.xml.rpc.encoding.SerializerFactory;
>>import javax.xml.rpc.encoding.DeserializerFactory;
>>
>>2). Your client class should implement the following interfaces:
>>
>>com.sun.xml.rpc.encoding.SerializerConstants
>>com.sun.xml.rpc.wsdl.document.schema.SchemaConstants
>>
>>3). You need to register the serializers for String[]:
>>
>>Service service = factory.createService(new QName("service-name"));
>>TypeMappingRegistry registry = service.getTypeMappingRegistry();
>>TypeMapping typeMapping =
>>registry.getTypeMapping(SOAPConstants.URI_ENCODING);
>>QName stringArrayTypeQname = new QName( "http://foo.bar/types" ,
>>"ArrayOfstring");
>>QName stringArrayElementQname = new QName("", "string");
>>CombinedSerializer stringSerializer = new
>>SimpleTypeSerializer(QNAME_TYPE_STRING, DONT_ENCODE_TYPE, NULLABLE,
>>SOAPConstants.URI_ENCODING, XSDStringEncoder.getInstance());
>>CombinedSerializer stringArraySerializer = new
>>SimpleTypeArraySerializer(QNAME_TYPE_INT, ENCODE_TYPE, NULLABLE,
>>SOAPConstants.URI_ENCODING, stringArrayElementQname, QNAME_TYPE_INT,
>>String.class, 1, null, (SimpleTypeSerializer)stringSerializer);
>>stringArraySerializer = new
>>ReferenceableSerializerImpl(SERIALIZE_AS_REF, stringArraySerializer);
>>SerializerFactory stringArraySerializerFactory = new
>>SingletonSerializerFactory(stringArraySerializer);
>>DeserializerFactory stringArrayDeserializerFactory = new
>>SingletonDeserializerFactory(stringArraySerializer);
>>typeMapping.register(String[].class, stringArrayTypeQname,
>>boxedByteArraySerializerFactory, boxedByteArrayDeserializerFactory);
>>
>>4). Finally invoke the method on the port:
>>
>>QName port = new QName(YOUR_PORT);
>>Call call = newCall(service, port);
>>call.setReturnType(stringArrayTypeQname);
>>call.setOperationName(new QName( "http://foo.bar/wsdl" ,
>>"getStringArray"));
>>String[] stringArray = (String[])call.invoke(new Object[0]);
>>
>>You can repeat the same steps for any other complex type
>>defined by your
>>WSDL.
>>
>>Thanks for your interest in JAX-RPC.
>>
>>Regards,
>>-Arun
>>
>>YAWN,MICHAEL (HP-Cupertino,ex1) wrote:
>>
>>>Hi,
>>>
>>>I've gotten an example of DII to work, following the tutorial almost
>>>exactly.
>>>Now, I want to call two methods that return array types. One is an
>>>array of Strings, the other an array of a complex data type
>>>
>>defined in
>>
>>>the WSDL.
>>>
>>>These data types are known in the WSDL -- is there some mechanism
>>>to make them visible to the DII Client so I can use them as return
>>>types?
>>>
>>>Thanks,
>>>Mike
>>>
>>--
>>=============================================
>>There is only one me, I must live myself!
>>There is only one today, I must live itself!
>>=============================================
>>http://members.tripod.com/~apgupta/index.html
>>=============================================
>>

--
=============================================
There is only one me, I must live myself!
There is only one today, I must live itself!
=============================================
http://members.tripod.com/~apgupta/index.html
=============================================