You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cxf.apache.org by "Daniel Kulp (JIRA)" <ji...@apache.org> on 2007/08/07 22:21:59 UTC

[jira] Issue Comment Edited: (CXF-897) Default JAXB Data Binding does not unmarshal parameters correctly for a POJO service

    [ https://issues.apache.org/jira/browse/CXF-897?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12518244 ] 

dkulp edited comment on CXF-897 at 8/7/07 1:20 PM:
---------------------------------------------------------


This  is a hugely complicated so bear with me while I try and explain what's going on....

The reason it works with Aegis on the server:  aegis seems to be ignoring the element name.   Thus, the fact that the element name is wrong on the wire (more in a sec) doesn't bother it.   JAXB, however, is less forgiving and if the element name is wrong, it doesn't read anything.

So, what is is wrong?   Well, it has to do with how the "simple" frontend stuff derives/creates part/element names when building up the internal service model.    If the "debug" information is compiled into the class files, it uses that information to provide a "friendlier" wsdl.     In your case, your "HelloWorldImpl" is debug compiled and the argument for the echo method is named "text" so the element that is expected is named "text".  That's great!     

However, on the client side, the proxy is being built from the interface class, not an interface.   One of the mysteries of java is that abstract methods (and thus interface methods) do NOT get their parameter names compiled into them even with debug info.   Thus, when the service model is built from an interface, we have to "default" to "arg0".     Thus, the client is sending "arg0", but the server is expecting "text".    That doesn't work very well.

There are a couple of workarounds:

1) Have the client use the WSDL generated from the servers ?wsdl call.   Would need to set the wsdl url, the service name, port name, etc... 

2) Compile the server code with all the debug stuff off.   If the impl class doesn't have the debug information in it, then it should use/expect the default of arg0.

3) Use the interface on the server side as well:
svrBean.setServiceClass(HelloWorld.class);
svrBean.setServiceBean(new HelloWorldImpl());

4) Rename the argument in the HelloWorldImpl.echo method from "text" to "arg0".

5) Annotate the stuff and use JAX-WS


FYI: this is one reason why JAX-WS MANDATES all params get the "arg0" treatment unless there is a WebParam annotation with a name attribute.   You could imagine applications working fine during development (with -g) that suddenly break when built for production (no -g, -o) and all the qnames and stuff start changing.









      was (Author: dkulp):
    
This  is a hugely complicated so bear with me while I try and explain what's going on....

The reason it works with Aegis on the server:  aegis seems to be ignoring the element name.   Thus, the fact that the element name is wrong on the wire (more in a sec) doesn't bother it.   JAXB, however, is less forgiving and if the element name is wrong, it doesn't read anything.

So, what is is wrong?   Well, it has to do with how the "simple" frontend stuff derives/creates part/element names when building up the internal service model.    If the "debug" information is compiled into the class files, it uses that information to provide a "friendlier" wsdl.     In your case, your "HelloWorldImpl" is debug compiled and the argument for the echo method is named "text" so the element that is expected is named "text".  That's great!     

However, on the client side, the proxy is being built from the interface class, not an interface.   One of the mysteries of java is that abstract methods (and thus interface methods) do NOT get their parameter names compiled into them even with debug info.   Thus, when the service model is built from an interface, we have to "default" to "arg0".     Thus, the client is sending "arg0", but the server is expecting "text".    That doesn't work very well.

There are a couple of workarounds:

1) Have the client use the WSDL generated from the servers ?wsdl call.   Would need to set the wsdl url, the service name, port name, etc... 

2) Compile the server code with all the debug stuff off.   If the impl class doesn't have the debug information in it, then it should use/expect the default of arg0.

3) Use the interface on the server side as well:
svrBean.setServiceClass(HelloWorld.class);
svrBean.setServiceBean(new HelloWorldImpl());

4) Annotate the stuff and use JAX-WS


FYI: this is one reason why JAX-WS MANDATES all params get the "arg0" treatment unless there is a WebParam annotation with a name attribute.   You could imagine applications working fine during development (with -g) that suddenly break when built for production (no -g, -o) and all the qnames and stuff start changing.








  
> Default JAXB Data Binding does not unmarshal parameters correctly for a POJO service
> ------------------------------------------------------------------------------------
>
>                 Key: CXF-897
>                 URL: https://issues.apache.org/jira/browse/CXF-897
>             Project: CXF
>          Issue Type: Bug
>          Components: Core
>    Affects Versions: 2.1
>            Reporter: William Tam
>         Attachments: HelloWorld.java, HelloWorldImpl.java, SimpleTest.java
>
>
> See the attached test case.  It works as is.  But the test case will fail if the following line is commented out the line from SimpleTest.java
> svrBean.getServiceFactory().setDataBinding(new AegisDatabinding());

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.