You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Valerio Schiavoni <va...@gmail.com> on 2009/05/15 00:19:17 UTC

using jaxb external file when creating stubs

Hello,
I have a wsdl file, which defines a service whose name is:
 <wsdl:service name="HelloWorldServer_Service">

for internal reason, I want the resulting class to be named exactly as
the service. By default, jaxb trims away the '_' and it generates a
class called HelloWorldServer_Service.

So, i created a jaxb mapping.xml file, trying to force jaxb to keep
that '_' characters.

<jaxws:bindings wsdlLocation="./proactive.wsdl"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
    xmlns:jaxws="http://java.sun.com/xml/ns/jaxws"
xmlns:jaxb="http://java.sun.com/xml/ns/jaxb">
    <jaxb:globalBindings underscoreHandling="asCharInWord"/>
</jaxws:bindings>

and it used by cxf-codegen-plugin as usual by defining:
	<bindingFiles>
		<bindingFile>
${basedir}/src/main/resources/wsdl/mapping.xml
		 </bindingFile>
        </bindingFiles>

Nevertheless, the resulting class still doesn't contain '_' in the
name. I'm not sure to understand the reasons..

I am using cxf 2.2.1

Thanks
valerio
-- 
http://www.linkedin.com/in/vschiavoni
http://jroller.com/vschiavoni

Re: using jaxb external file when creating stubs

Posted by Valerio Schiavoni <va...@gmail.com>.
Hello Daniel,
thanks for the suggestion.

I noticed something strange. Despite the xpath expression you
suggested (exactly the same in the snippet you posted) was correct,
when used, i get the following error:

Could not find any node with the XPath expression:
///wsdl:definitions/wsdl:service[@name='HelloWorldServer_Service']

Please note the 3 trailing slashes at the beginning of the xpath,
which have been added 'automatically', not in the jaxb mapping.

If instead, I use the following xpath:
wsdl:definitions/wsdl:service[@name='HelloWorldServer_Service']

(so, without any slash character '/' at the beginning of the
expression), everything works as expected, and the jaxb mapping
produces the intended result.

I'm not sure that this behaviour is intended..

best regards,
valerio

On Fri, May 15, 2009 at 5:33 PM, Daniel Kulp <dk...@apache.org> wrote:
>
> The JAXB customizations only apply to the stuff that JAXB handles, which is
> the schemas.   It wouldn't apply to the JAX-WS generated stuff.
>
> For your case, you would need something like:
>
> <jaxws:bindings wsdlLocation="./proactive.wsdl"
>     xmlns:xs="http://www.w3.org/2001/XMLSchema"
>     xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
>     xmlns:jaxws="http://java.sun.com/xml/ns/jaxws"
>     xmlns:jaxb="http://java.sun.com/xml/ns/jaxb">
>
>     <jaxws:bindings
>      node="/wsdl:definitions/wsdl:service[@name='HelloWorldServer_Service']">
>          <jaxws:class name="HelloWorldServer_Service"/>
>     </jaxws:bindings>
> </jaxws:bindings>
>
>
> Dan
>
>
> On Thu May 14 2009 6:19:17 pm Valerio Schiavoni wrote:
>> Hello,
>> I have a wsdl file, which defines a service whose name is:
>>  <wsdl:service name="HelloWorldServer_Service">
>>
>> for internal reason, I want the resulting class to be named exactly as
>> the service. By default, jaxb trims away the '_' and it generates a
>> class called HelloWorldServer_Service.
>>
>> So, i created a jaxb mapping.xml file, trying to force jaxb to keep
>> that '_' characters.
>>
>> <jaxws:bindings wsdlLocation="./proactive.wsdl"
>>     xmlns:xs="http://www.w3.org/2001/XMLSchema"
>> xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
>>     xmlns:jaxws="http://java.sun.com/xml/ns/jaxws"
>> xmlns:jaxb="http://java.sun.com/xml/ns/jaxb">
>>     <jaxb:globalBindings underscoreHandling="asCharInWord"/>
>> </jaxws:bindings>
>>
>> and it used by cxf-codegen-plugin as usual by defining:
>>       <bindingFiles>
>>               <bindingFile>
>> ${basedir}/src/main/resources/wsdl/mapping.xml
>>                </bindingFile>
>>         </bindingFiles>
>>
>> Nevertheless, the resulting class still doesn't contain '_' in the
>> name. I'm not sure to understand the reasons..
>>
>> I am using cxf 2.2.1
>>
>> Thanks
>> valerio
>
> --
> Daniel Kulp
> dkulp@apache.org
> http://www.dankulp.com/blog
>



-- 
http://www.linkedin.com/in/vschiavoni
http://jroller.com/vschiavoni

Re: using jaxb external file when creating stubs

Posted by Daniel Kulp <dk...@apache.org>.
The JAXB customizations only apply to the stuff that JAXB handles, which is 
the schemas.   It wouldn't apply to the JAX-WS generated stuff.

For your case, you would need something like:

<jaxws:bindings wsdlLocation="./proactive.wsdl"
     xmlns:xs="http://www.w3.org/2001/XMLSchema"
     xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
     xmlns:jaxws="http://java.sun.com/xml/ns/jaxws"
     xmlns:jaxb="http://java.sun.com/xml/ns/jaxb">

     <jaxws:bindings
      node="/wsdl:definitions/wsdl:service[@name='HelloWorldServer_Service']">
          <jaxws:class name="HelloWorldServer_Service"/>
     </jaxws:bindings>
</jaxws:bindings>


Dan


On Thu May 14 2009 6:19:17 pm Valerio Schiavoni wrote:
> Hello,
> I have a wsdl file, which defines a service whose name is:
>  <wsdl:service name="HelloWorldServer_Service">
>
> for internal reason, I want the resulting class to be named exactly as
> the service. By default, jaxb trims away the '_' and it generates a
> class called HelloWorldServer_Service.
>
> So, i created a jaxb mapping.xml file, trying to force jaxb to keep
> that '_' characters.
>
> <jaxws:bindings wsdlLocation="./proactive.wsdl"
>     xmlns:xs="http://www.w3.org/2001/XMLSchema"
> xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
>     xmlns:jaxws="http://java.sun.com/xml/ns/jaxws"
> xmlns:jaxb="http://java.sun.com/xml/ns/jaxb">
>     <jaxb:globalBindings underscoreHandling="asCharInWord"/>
> </jaxws:bindings>
>
> and it used by cxf-codegen-plugin as usual by defining:
> 	<bindingFiles>
> 		<bindingFile>
> ${basedir}/src/main/resources/wsdl/mapping.xml
> 		 </bindingFile>
>         </bindingFiles>
>
> Nevertheless, the resulting class still doesn't contain '_' in the
> name. I'm not sure to understand the reasons..
>
> I am using cxf 2.2.1
>
> Thanks
> valerio

-- 
Daniel Kulp
dkulp@apache.org
http://www.dankulp.com/blog