users@glassfish.java.net

JAX-WS: targetNamespace oddities

From: <glassfish_at_javadesktop.org>
Date: Wed, 25 Jul 2007 08:37:21 PDT

I have been writing some JAX-WS services on glassfish. There are similar services
in an already-existing .NET implementation that we need to behave like.

The client of both instances of these services in written in Objective-C, using some API
that, more or less, allows the Objective-C programmer to manually construct the SOAP
envelope.

Getting this Objective-C client to work with the JAX-WS services while not breaking its
ability to work with the .NET services took some detailed experimentation. The difficulties
turned out to be with the use of namespaces for the service operations and their arguments.

My service was annotated thusly:
@WebService(targetNamespace=""http://soap.somewhere.net/something/"")

Three example SOAP requests, each with a different combination of applying (or not
applying) namespace prefixes to the method names or method arguments, follow:

This call works against glassfish, but fails on .NET
----------------------------------------------------
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema"
                                xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                                xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
                                soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
                                xmlns:ihatesoap="http://soap.somewhere.net/something/">
        <soap:Body>
                <ihatesoap:someMethodName>
                        <argumentName1 xsi:type="xsd:string">some string</argumentName1>
                        <argumentName2 xsi:type="xsd:string">some other string</argumentName2>
                </ihatesoap:someMethodName>
        </soap:Body>
</soap:Envelope>




Either of these two calls work against a .NET service, but neither work against glassfish
-----------------------------------------------------------------------------------------
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema"
                                xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                                xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
                                soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
                                xmlns="http://soap.somewhere.net/something/">
        <soap:Body>
                <someMethodName>
                        <argumentName1 xsi:type="xsd:string">some string</ihatesoap:argumentName1>
                        <argumentName2 xsi:type="xsd:string">some other string</ihatesoap:argumentName2>
                </someMethodName>
        </soap:Body>
</soap:Envelope>




<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema"
                                xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                                xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
                                soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
                                xmlns:ihatesoap="http://soap.somewhere.net/something/">
        <soap:Body>
                <ihatesoap:someMethodName>
                        <ihatesoap:argumentName1 xsi:type="xsd:string">some string</ihatesoap:argumentName1>
                        <ihatesoap:argumentName2 xsi:type="xsd:string">some other string</ihatesoap:argumentName2>
                </ihatesoap:someMethodName>
        </soap:Body>
</soap:Envelope>


After this experimentation, I discovered that if I use the targetNamespace attribute
in the @WebParam() annotation of every argument of every operation, then I could
get cases 2 & 3 to work with glassfish.

That said, my question is twofold:
     1) Is there some way to annotate my JAX-WS service such that I really only need
          to mention the namespace once (at the class level) and it's inherited throughout
          so that I don't need to laboriously annotate each method argument this way.

     2) Is there some other way the Objective-C client could try constructing the SOAP
          request so that my single @WebService() annotation would be all that I need,
[Message sent by forum member 'pohl' (pohl)]

http://forums.java.net/jive/thread.jspa?messageID=228187