Hi all,
I've recently upgraded from 1.2.4 to 1.2.6, and discovered that the XML
response now includes many more namespace definitions than previously.
Unfortunately this has broken one of our clients applications (that treated
the xml as text, and did searches for specfic elements and didn't handle
xmlns text).
So, my question, is there any way to modify the response/configure xfire so
that we define the default namespace, and therefore all contained elements
that are on that namespace use that instead of reprinting it? (everything
is in the same namespace to try to reduce the XML, as namespace's were not
important).
I think that the fix that caused me the problems was that which modified the
WrappedBinding class to call through to NamespaceHelper.getUniquePrefix
(revision 2156?).
To make things a bit clearer, here's the XML output from a simplified test
case (see the end) that prints out the response, using xfire 1.2.4, note the
default namespace definition on the response:
<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><soap:Body><getPersonResponse
xmlns="http://andy"><out><age>123</age><name>HelloWorld</name></out></getPersonResponse></soap:Body></soap:Envelope>
And here's the output from the same application, but using xfire 1.2.6, ,
note the multiple definitions of the default namespace definition on the
responses child elements.
<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><soap:Body><ns1:getPersonResponse
xmlns:ns1="http://andy"><ns1:out><age xmlns="http://andy">123</age><name
xmlns="http://andy">HelloWorld</name></ns1:out></ns1:getPersonResponse></soap:Body></soap:Envelope>
Many Thanks
Andy
The sample application:
package andy;
import java.io.ByteArrayOutputStream;
import javax.jws.WebService;
import org.codehaus.xfire.spring.AbstractXFireSpringTest;
import org.jdom.Document;
import org.jdom.output.XMLOutputter;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
public class NamespaceTest extends AbstractXFireSpringTest {
public void testNamespace() throws Exception {
Document response = invokeService("service", "/serviceCall.xml");
ByteArrayOutputStream baos = new ByteArrayOutputStream();
new XMLOutputter().output(response, baos);
String xml = new String(baos.toByteArray());
System.out.println("xml: " + xml);
}
protected ApplicationContext createContext() {
return new
ClassPathXmlApplicationContext("/applicationContext.xml");
}
public static class Person {
private String name;
private int age;
public String getName() { return this.name; }
public void setName(String name) { this.name = name; }
public int getAge() { return this.age; }
public void setAge(int age) { this.age = age; }
}
@WebService(targetNamespace = "http://andy", serviceName = "service")
public static class ServiceImpl {
//@WebResult(name = "out", targetNamespace = "http://andy")
public Person getPerson(String name) {
Person p = new Person();
p.setName(name);
p.setAge(123);
return p;
}
}
}
// The applicationContext.xml file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
"http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
<bean id="xfire" class="org.codehaus.xfire.DefaultXFire" />
<bean id="xfire.serviceFactory"
class="org.codehaus.xfire.annotations.AnnotationServiceFactory">
<constructor-arg><bean factory-bean="xfire"
factory-method="getTransportManager" /></constructor-arg>
</bean>
<bean id="service.handlerMapping"
class="org.codehaus.xfire.spring.ServiceBean">
<property name="xfire" ref="xfire" />
<property name="serviceFactory" ref="xfire.serviceFactory" />
<property name="serviceBean">
<bean class="andy.NamespaceTest$ServiceImpl" />
</property>
</bean>
</beans>
// the serviceCall.xml file
<?xml version="1.0" encoding="UTF-8"?>
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
<env:Body>
<getPerson xmlns="http://andy">
<name>HelloWorld</name>
</getPerson>
</env:Body>
</env:Envelope>
_________________________________________________________________
Win tickets to the sold out Live Earth concert! http://liveearth.uk.msn.com
---------------------------------------------------------------------
To unsubscribe from this list please visit:
http://xircles.codehaus.org/manage_email