Hi There,
I have buit & run the example "JSR 181 Service" successfully.
>From this web service, I also tried to make web service client as described
in "Client and Server Stub Generation from WSDL" using XMLBeans binding.
So far, everything goes well. And I got the following classes:
1) CustomerSerivceClient.java
2) CustomerServiceImpl.java
3) CustomerServicePortType.java
and some XMLBean binding classes, like:
1) Customer.class
2) UserToken.class
3) UserTokenDocument.class
to be used in the client code to invoke the web service "CustomerService".
when I ran the following test code:
=====================================
CustomerServiceClient service = new CustomerServiceClient();
CustomerServicePortType custservice = service.getCustomerServiceHttpPort();
Customer cust = Customer.Factory.newInstance();
cust.setName("jsr181 example");
cust.setEmail("[EMAIL PROTECTED]");
cust.setPhone("905-1234567");
UserToken ut = UserToken.Factory.newInstance();
ut.setUsername("myusername");
ut.setPassword("mypassword");
UserTokenDocument utd = UserTokenDocument.Factory.newInstance();
utd.setUserToken(ut);
System.out.println(utd.toString());
custservice.addCustomer(cust,utd);
=====================================================
I got the following exception:
org.jdom.IllegalAddException:
The namespace xmlns="http://demo.xfire.codehaus.org" could not be added
as a namespace to "UserToken": The namespace prefix "" collides with the el
ement namespace prefix
at org.jdom.Element.addNamespaceDeclaration(Element.java:341)
at org.codehaus.xfire.util.stax.JDOMStreamWriter.writeDefaultNamespace
(JDOMStreamWriter.java:146)
at org.codehaus.xfire.util.STAXUtils.writeStartElement(STAXUtils.java:235)
at org.codehaus.xfire.util.STAXUtils.copy(STAXUtils.java:138)
at org.codehaus.xfire.xmlbeans.XmlBeansType.writeObject(XmlBeansType.java:207)
at org.codehaus.xfire.aegis.AegisBindingProvider.writeParameter
(AegisBindingProvider.java:206)
at org.codehaus.xfire.service.binding.AbstractBinding.writeParameter
(AbstractBinding.java:273)
at org.codehaus.xfire.service.binding.ServiceInvocationHandler.writeHeaders
(ServiceInvocationHandler.java:295)
org.codehaus.xfire.client.Invocation.invoke(Invocation.java:73)
... 6 more
I also printed the XML representation of "UserTokenDocument" as following:
<UserToken xmlns="http://demo.xfire.codehaus.org">
<password>mypassword</password>
<username>myusername</username>
</UserToken>
I think that this not correct, because it use the default namesapce prefix "".
When I tried to use the follow XML file:
<tns:UserToken xmlns:tns="http://demo.xfire.codehaus.org">
<tns:password>mypassword</tns:password>
<tns:username>myusername</tns:username>
</tns:UserToken>
and the following java code:
=======================================================
CustomerServiceClient service = new CustomerServiceClient();
CustomerServicePortType custservice = service.getCustomerServiceHttpPort();
Customer cust = Customer.Factory.newInstance();
cust.setName("jsr181 example");
cust.setEmail("[EMAIL PROTECTED]");
cust.setPhone("905-1234567");
UserTokenDocument utd = UserTokenDocument.Factory.
parse(new File("usertoken.xml"));
custservice.addCustomer(cust,utd);
======================================
It works.
So I think that there maybe a bug in XFire or XMLBeans binding, that the XML
namespace prefix is not correctly set.
Can someone give advice?
Thanks,
William (Yi) Zhu
---------------------------------------------------------------------
To unsubscribe from this list please visit:
http://xircles.codehaus.org/manage_email