users@jax-rpc.java.net

Deserializing extended types in default namespace

From: Jerry Pisk <jerry.pisk_at_gmail.com>
Date: Wed, 7 Dec 2005 14:01:13 -0800

Hi,

I'm having a problem accessing a jax-rpc based web service using a
.Net client. It comes down to what's in the subject and is not really
related to the client used, it's just that .Net framework uses the
default namespace while jax-rpc client prefixes all its namespaces.
Everything works fine when I do not derive types using xsd:extension
so I am going to focus on only the relevant pieces.

Service WSDL snippet:

<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions
    name="service"
    targetNamespace="http://example.org/service/v1/wsdl"
    xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
    xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:tns="http://example.org/service/v1/wsdl"
    xmlns:t="http://example.org/service/v1/types"
>
    <wsdl:types>
        <xsd:schema
            elementFormDefault="qualified"
            attributeFormDefault="unqualified"
            targetNamespace="http://example.org/service/v1/types"
            xmlns:xsd="http://www.w3.org/2001/XMLSchema"
            xmlns:tns="http://example.org/service/v1/types"
>
            <xsd:complexType name="Shape" abstract="true" />
            <xsd:complexType name="Point">
                <xsd:complexContent mixed="false">
                    <xsd:extension base="tns:Shape">
                        <xsd:sequence>
                            <xsd:element
                                name="id"
                                type="xsd:string"
                                minOccurs="0"
                                maxOccurs="1"
                            />
                        </xsd:sequence>
                    </xsd:extension>
                </xsd:complexContent>
            </xsd:complexType>
            <!-- Other types defined here -->
        </xsd:schema>
    </wsdl:types>
    <!-- Messages, ports, bindings and service definitions -->
</wsdl:definitions>

The only difference in the SOAP message that comes in is that .Net
puts the request message into a default namespace
(xmlns="http://example.org/service/v1/types") while jax-rpc client
uses prefixed namespace
(xmlns:ns0="http://example.org/service/v1/types") on the message
element and the xsi:type is set to "Point" or "ns0:Point"
respectively. When the namespace is prefixed everything works as
expected, when it's not I get the following exception:

unexpected element type: expected=, actual=Point
        at org.example.service.Shape__service__InterfaceSOAPSerializer.doDeserialize(Shape__service__InterfaceSOAPSerializer.java:57)
        at com.sun.xml.rpc.encoding.InterfaceSerializerBase.deserialize(InterfaceSerializerBase.java:118)
        at org.example.service.RequestMessage__map__LiteralSerializer.doDeserialize(RequestMessage__map__LiteralSerializer.java:77)
        at com.sun.xml.rpc.encoding.literal.LiteralObjectSerializerBase.internalDeserialize(LiteralObjectSerializerBase.java:216)
        at com.sun.xml.rpc.encoding.literal.LiteralObjectSerializerBase.deserialize(LiteralObjectSerializerBase.java:124)
        at org.example.service.IService_Tie.deserialize_Method(IService_Tie.java:314)
        at org.example.service.IService_Tie.readFirstBodyElement(IService_Tie.java:282)
        at com.sun.xml.rpc.server.StreamingHandler.handle(StreamingHandler.java:245)
        at com.sun.xml.rpc.server.http.JAXRPCServletDelegate.doPost(JAXRPCServletDelegate.java:448)
        at com.sun.xml.rpc.server.http.JAXRPCServlet.doPost(JAXRPCServlet.java:102)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
        at org.apache.catalina.valves.FastCommonAccessLogValve.invoke(FastCommonAccessLogValve.java:481)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:825)
        at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:731)
        at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:526)
        at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
        at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
        at java.lang.Thread.run(Thread.java:595)

This exception comes from
com.sun.xml.rpc.encoding.literal.LiteralObjectSerializerBase.internalDeserialize()
but so far I wasn't able to trace why it's expecting a blank name when
the types are in the default namespace. Any ideas?

I have also tried to write a message handler to prefix the default
namespace but that didn't work even when it did make the message to
look identical to the one sent by a jax-rpc client with all the
namespaces prefixed and it managed to break the response (invalid
content type kind of an exception on the client) even though the
handler only overwrote handleRequest from
javax.xml.rpc.handler.GenericHandler.

Any help would be appreciated, I can provide more information if I
missed something important.

Jerry Pisk