History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: XFIRE-500
Type: Bug Bug
Status: Closed Closed
Resolution: Won't Fix
Priority: Minor Minor
Assignee: Dan Diephouse
Reporter: Matt Solnit
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
XFire

Namespace prefix required on inbound complex type

Created: 28/Jun/06 04:29 PM   Updated: 16/Aug/06 05:06 PM
Component/s: None
Affects Version/s: 1.1
Fix Version/s: 1.2

Time Tracking:
Not Specified

File Attachments: 1. XML File Object.aegis.xml (1 kb)
2. Zip Archive xfire-500.zip (5 kb)

Environment: Mac OS X Intel 10.4.7, Apache Tomcat 5.5.17, Java 1.5.0_06


 Description  « Hide
I have a method that takes a complex type as a parameter. If I try to test it by creating a raw SOAP message and posting it (instead of using a generated Java proxy class), I have to repeat the namespace, and use a prefix, on the complex type. For example:

<?xml version='1.0' encoding='UTF-8'?>
<soap:Envelope xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'>
<soap:Body>
<createObject xmlns='http://www.soasta.com/services/repository'>
<rp:oObject xmlns:rp='http://www.soasta.com/services/repository' rp:name="sub" rp:path="/" rp:type="folder" >
<rp:Body>foo</rp:Body>
</rp:oObject>
</createObject>
</soap:Body>
</soap:Envelope>

Notice that the <oObject> element simply reproduces the namespace on the parent <createObject> element, and adds a prefix.

If I leave the namespace out on the <oObject> element, or if I try to repeat it as a default namespace instead of using the "rp" prefix, then the type is not marshaled correctly and I get a null body on the server side.

Lest you think that it is because "Body" is already a SOAP element, I tried with others too and same problem



 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
Matt Solnit - 28/Jun/06 04:35 PM
Attaching the Aegis mapping file for the complex type.

Dan Diephouse - 29/Jun/06 04:07 AM
I'm kinda surprised that this can happen. I'll have to do some digging. Any chance you have the stax-dev-1.1.x jar on your classpath?

Matt Solnit - 29/Jun/06 01:13 PM
Hi Dan. Thanks for your response. My current classpath is stax-api-1.0.1.jar and wstx-2.0.6.jar. I also tried with Woodstox 2.9.3 instead of 2.0.6, but the behavior was the same.

Would it help if I provide a complete sample?


Dan Diephouse - 15/Aug/06 01:48 PM
Hi Matt, Sorry for the long delay.... A complete sample would definitely help

Matt Solnit - 15/Aug/06 04:09 PM
A modified version of the XFire BookService example that demonstrates the problem. Includes an HTML UI for testing.

Dan Diephouse - 15/Aug/06 04:18 PM
Thanks, looking into this now.

Matt Solnit - 15/Aug/06 04:22 PM
I was writing some more information, but looks like you beat me to it . I'll post anyway:

The attached sample is basically a small mod of xfire/examples/book. The changes are:

  • BookService.java includes a new method that tests the contents of a Book passed as an input parameter.
  • TestBookService.html is an HTML UI for testing various SOAP inputs to the service.
  • Book.aegis.xml has been added.

The reason that I added the Aegis file is to control the namespace that Book appears in. If I exclude the mapping file, then the problem does not occur, but Book is not in the same namespace as the actual service.

To reproduce the problem, browse to TestBookService.html and try the following SOAP:

<?xml version='1.0' encoding='UTF-8'?>
<soap:Envelope xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'>
<soap:Body>
<putBook>
<book xmlns='http://demo.xfire.codehaus.org'><author>Dan</author><isbn>123</isbn><title>foo</title></book>
</putBook>
</soap:Body>
</soap:Envelope>

You should get an error that the author is missing.


Dan Diephouse - 15/Aug/06 05:31 PM
I'm looking at your example. Your namespaces don't match - in the aegis.xml file you say the namespace is "http://xfire.codehaus.org/BookService", but in your example message its "http://demo.xfire.codehaus.org". Also, your putBook element doesn't have a namespace and it should be "http://xfire.codehaus.org/BookService".

Matt Solnit - 15/Aug/06 05:44 PM
Arg, could I have confused myself while creating this sample? It's the classic problem of "can't share my corporate code, and of course the little sample works just fine". I'll try again . Thanks for bearing with me so far.

Matt Solnit - 15/Aug/06 06:04 PM
OK, I think I know what's going on. I appreciate your help and I apologize for leading you in the wrong direction before.

The problem, as far as I can tell, only shows up when using attributes. So if you put the following in the Aegis file:
<property name="author" style="attribute" />

and use the following SOAP message:

<?xml version='1.0' encoding='UTF-8'?>
<soap:Envelope xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'>
<soap:Body>
<putBook xmlns='http://xfire.codehaus.org/BookService'>
<book xmlns='http://xfire.codehaus.org/BookService' author='Dan'><isbn>123</isbn><title>foo</title></book>
</putBook>
</soap:Body>
</soap:Envelope>

then you get the error. However, if you prefix-qualify the namespace, as shown below:

<?xml version='1.0' encoding='UTF-8'?>
<soap:Envelope xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'>
<soap:Body>
<putBook>
<b:book xmlns:b='http://xfire.codehaus.org/BookService' b:author='bob'><b:isbn>123</b:isbn><b:title>foo</b:title></b:book>
</putBook>
</soap:Body>
</soap:Envelope>

then it works. I hope this helps.


Dan Diephouse - 16/Aug/06 04:25 PM
Hi Matt,
Your XML is wrong. The author in this example is not associated with any namespace:

<book xmlns='http://xfire.codehaus.org/BookService' author='Dan'>

The XML Namespace specification says:

A default namespace declaration applies to all unprefixed element names within its scope. Default namespace declarations do not apply directly to attribute names; the interpretation of unprefixed attributes is determined by the element on which they appear. ... The namespace name for an unprefixed attribute name always has no value.

So a correct version with book having an empty prefix would be:

<book xmlns='http://xfire.codehaus.org/BookService' xmlns:b="xmlns='http://xfire.codehaus.org/BookService'" b:author='Dan'>


Matt Solnit - 16/Aug/06 05:06 PM
Hi Dan. I read the spec and it looks like you're right. Thanks for checking this out.

The XML Schema Primer backs this up:
"In fact, attributes that are required to be qualified must be explicitly prefixed because the Namespaces in XML specification does not provide a mechanism for defaulting the namespaces of attributes."

However, the Xerces XSD validator will allow un-prefixed attributes. This is how I got confused. Maybe Xerces is wrong.