Hello,
I have set up xfire 1.1RC1 in a webapp using spring like this:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
"http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
<bean
class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
<property name="urlMap">
<map>
<entry key="/TestService">
<ref bean="test" />
</entry>
</map>
</property>
</bean>
<!-- Declare a parent bean with all properties common to both
services -->
<bean id="test"
class="org.codehaus.xfire.spring.remoting.XFireExporter">
<property name="serviceFactory"
ref="xfire.xmlbeansServiceFactory" />
<property name="xfire" ref="xfire" />
<property name="style" value="rpc" />
<property name="serviceBean" ref="testBean" />
<property name="serviceInterface"
value="dk.bec.test.TestXFireService" />
<property name="namespace" value="PITrans30Ver6" />
</bean>
<bean id="testBean" class="dk.bec.test.TestXFireServiceImpl" />
</beans>
With the corresponding Service code:
public class TestXFireServiceImpl implements TestXFireService {
public AnmodOmDataDocument test(AnmodOmDataDocument document) {
System.out.println(document.xmlText());
return document;
}
}
And this client:
public class TextXFireClient {
public static void main(String[] args) {
System.setProperty(
"javax.xml.stream.XMLInputFactory",
"com.ctc.wstx.stax.WstxInputFactory");
System.setProperty(
"javax.xml.stream.XMLOutputFactory",
"com.ctc.wstx.stax.WstxOutputFactory");
System.setProperty(
"javax.xml.stream.XMLEventFactory",
"com.ctc.wstx.stax.WstxEventFactory");
try {
XmlBeansServiceFactory factory = new
XmlBeansServiceFactory();
factory.setStyle("rpc");
Service service =
factory.create(
TestXFireService.class,
"TestService",
"PITrans30Ver6",
null);
service.setProperty(XmlBeansType.XMLBEANS_NAMESPACE_HACK, "true");
System.out.println(service);
TestXFireService testService =
(TestXFireService) new
XFireProxyFactory().create(
service,
"http://localhost:9080/XfireTest/TestService");
AnmodOmDataDocument doc =
((AnmodOmDataDocument)
AnmodOmDataDocument
.Factory
.parse(
TextXFireClient.class.getResourceAsStream(
"PITrans30Ver6.xml")));
AnmodOmDataDocument doc2 =
testService.test(doc);
System.out.println(doc);
System.out.println(doc2);
} catch (Exception e) {
e.printStackTrace();
}
}
}
Everything works fine except that when i recieve an XmlBeans object and
print it, the xml is surrounded by <xml-fragment> tags... It looks like
xfire messes up the namespace attributes of my xml:
This is the XML i send
<p:AnmodOmData xmlns:p="PITrans30Ver6"
xmlns:xsi="http:/www.w3.org/2001/XMLSchema-instance">
<Header>
<VersionsNr>6</VersionsNr>
<LeveranceID/>
<TransaktionstypeNr>30</TransaktionstypeNr>
<LeveranceTidspunkt>2001-12-31T12:00:00</LeveranceTidspunkt>
<CprNr>1710743017</CprNr>
</Header>
<Anmoder>
<AnmoderID>1</AnmoderID>
<AnmoderKontakt>[EMAIL PROTECTED]</AnmoderKontakt>
<Valutakode>dkk</Valutakode>
</Anmoder>
</p:AnmodOmData>
This is the xml i recieve on the server.
<xml-fragment xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:p="PITrans30Ver6"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<p:AnmodOmData xmlns:xsi="http:/www.w3.org/2001/XMLSchema-instance">
<Header xmlns="PITrans30Ver6">
<VersionsNr>6</VersionsNr>
<LeveranceID/>
<TransaktionstypeNr>30</TransaktionstypeNr>
<LeveranceTidspunkt>2001-12-31T12:00:00</LeveranceTidspunkt>
<CprNr>1710743017</CprNr>
</Header>
<Anmoder xmlns="PITrans30Ver6">
<AnmoderID>1</AnmoderID>
<AnmoderKontakt>[EMAIL PROTECTED]</AnmoderKontakt>
<Valutakode>dkk</Valutakode>
</Anmoder>
</p:AnmodOmData>
</xml-fragment>
I am totally clueless as to why this happends and i hope somebody can
help me.
Sincerely
Morten Wilken