Forum Discussion

ehames's avatar
14 years ago

Need to manually add xsi namespace to SOAP envelope

My project is using inheritance to define some types used in WS requests and that's causing some unexpected trouble. Here is a simplified version of my project:

The base class:

@XmlType(name = "BaseClass")
@XmlSeeAlso( {ExtendingClass1.class, ExtendingClass2.class} )
class BaseClass {....}


The extending class is like this:

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "extendingClass1", propOrder = { "foo" })
@XmlRootElement(name = "extendingClass1")
public class ExtendingClass1 extends BaseClass {....}


The request looks like this:

@XmlAccessorType(XmlAccessType.FIELD)
class Request {
@XmlElementRefs({ @XmlElementRef(type = ExtendingClass1.class), @XmlElementRef(type = ExtendingClass2.class) })
protected BaseClass myObject;
}


When SOAPUI creates the request for me, I need to manually add to the envelope the namespace:
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

And I need to change the requests a bit to add xsi:type to my objects. For example:
<myns:myObject xsi:type="myns:ExtendingClass1">

Even though I have google'd for a while and looked up in the forum, I haven't been able to find a proper solution for this. So here are my questions:

  • Is there a way I can tell SOAPUI to automatically add this namespace?

  • Do I need to change my web service code to force the addition of the namespace on the envelope?

  • Other devs in the project complain that they need to manually add the namespace and type to attributes, is there any way that SOAPUI can help with this?


I appreciate your help and support!
No RepliesBe the first to reply