users@jax-rpc.java.net

Using Arrays in DII calls

From: YAWN,MICHAEL (HP-Cupertino,ex1) <"YAWN,MICHAEL>
Date: Thu, 11 Apr 2002 08:11:11 -0700

Followup to yesterday's question:

Trying to access a service whose methods return Arrays. One is an array of
strings, the other an array of structure types.

What is the correct specification of the return type of a method that
returns an array of strings? Of a method that returns an array of structs?

First attempt:
  String NS_SOAP_ENC =
        "http://schemas.xmlsoap.org/soap/encoding";
  QName QNAME_TYPE_ARRAY =
         new QName(NS_SOAP_ENC, "ArrayOfstring"
  call.setReturnType(QNAME_TYPE_ARRAY, String[].class);

This fails at runtime with the error
Couldn't match: class [Ljava.lang.String;,
{http://schemas.xmlsoap.org/soap/encoding/}ArrayOfstring
Exception in thread "main" serialization error: no serializer is registered
for
(class [Ljava.lang.String;,
{http://schemas.xmlsoap.org/soap/encoding/}ArrayOfstring)

An equivalent error is seen if String[] is replaced by Object[].

Next attempt:
I at least make some progress if I replace 'ArrayOfstring' with the more
generic 'Array'.
I don't get the 'couldn't match' error, but instead get
Exception in thread "main" HTTP transport error:
java.lang.IllegalArgumentException: Illegal MimeHeader name or value

Any explanation of the above error and how to correct it would be helpful.

But getting back to the first case. When running via stubs, xrpcc generates
a bunch
of serializer and deserializer classes that know how to map, for example, an
XML
ArrayOfstring to a Java String[]. In the DII case, these classes aren't
generated,
but they are obviously still needed. How do I generate them on-the-fly?

My WSDL document defines the various types I need serializers and
deserializers
for (e.g., ArrayOfstring). But I don't see any way to query the
TypeMappingRegistry
to see whether any conversions are defined for that type. I can query the
TypeMappingRegistry for namespaces supported (I see SOAP-ENC and a blank
namespace, but not the target namespace from my WSDL). For a namespace,
I cannot see a way to get a list of the defined conversions. I can see
whether
specific conversions are registered -- so I tested various combinations of
String[], Object[], Array, and ArrayOfstring, and only the Object[] to Array

mapping was found. This at least matches the behavior seen in the program.

I'm not sure how to solve my problem:
- Do I need to write my own Serializers and Deserializers for conversions of
  the array types? This seems odd given that JAX-RPC already knows how
  to create exactly the ones I need.
- Should I just go with mapping everything to an Object[] and casting? If
so,
  how do I resolve the 'Illegal MimeHeader name or value' error that I get
when
  treating my return array as an Object[]?

Mike