users@jax-rpc.java.net

Re: Using Arrays in DII calls

From: Arun Gupta <arun.gupta_at_Sun.COM>
Date: Fri, 12 Apr 2002 10:45:25 -0700

Hi Michael,

Please refer to my posting at
http://swjscmail1.java.sun.com/cgi-bin/wa?A2=ind0204&L=jaxrpc-interest&F=&S=&P=8733
on using a String[] in DII client.

Thanks for your interest in JAX-RPC.

Thanks,
-Arun

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

>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
>

--
=============================================
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
=============================================