You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Anto Paul <an...@gmail.com> on 2010/02/02 08:06:39 UTC

Customizing method body of wsdl2java generated code

Hi,

    How to embed custom code into method body of implementation classes
generated by wsdl2java tool? I am writing a tool that calls wsdl2java to
generate service implementation classes from WSDL and the generated code
should contain code for calling existing service layer. CXF wsdl2java
generates method body that is no usable by me. Instead of modifying that
manually or using another tool to modify generated method body, I need to
replace this method body with what I supply to the tool. Is this supported
by wsdl2java? If not which class I should look to customize the generated
code? I need to do the same for client.

Thanks in advance

Anto

Re: Customizing method body of wsdl2java generated code

Posted by KnutIvar <kn...@gmail.com>.
I don't know what databinding you're using, but if you use XMLBeans, I think
there are methods to manipulate the XML using XmlCursor... see the xmlbeans
XmlCursor javadoc for more information... I have only tried it once in an
example.


Anto P wrote:
> 
> Hi,
> 
>     How to embed custom code into method body of implementation classes
> generated by wsdl2java tool? I am writing a tool that calls wsdl2java to
> generate service implementation classes from WSDL and the generated code
> should contain code for calling existing service layer. CXF wsdl2java
> generates method body that is no usable by me. Instead of modifying that
> manually or using another tool to modify generated method body, I need to
> replace this method body with what I supply to the tool. Is this supported
> by wsdl2java? If not which class I should look to customize the generated
> code? I need to do the same for client.
> 
> Thanks in advance
> 
> Anto
> 
> 


-----
http://www.knutivars.net www.knutivars.net 
"http://www.knutivars.net/cxf/index.html Document first Apache CXF and
XMLBeans with Spring. 
-- 
View this message in context: http://old.nabble.com/Customizing-method-body-of-wsdl2java-generated-code-tp27416243p27426652.html
Sent from the cxf-user mailing list archive at Nabble.com.


Re: Customizing method body of wsdl2java generated code

Posted by Daniel Kulp <dk...@apache.org>.

The impl is generated by a velocity template:
http://svn.apache.org/repos/asf/cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/template/impl.vm

Not sure if that helps you out at all.

Dan




On Tue February 2 2010 2:06:39 am Anto Paul wrote:
> Hi,
> 
>     How to embed custom code into method body of implementation classes
> generated by wsdl2java tool? I am writing a tool that calls wsdl2java to
> generate service implementation classes from WSDL and the generated code
> should contain code for calling existing service layer. CXF wsdl2java
> generates method body that is no usable by me. Instead of modifying that
> manually or using another tool to modify generated method body, I need to
> replace this method body with what I supply to the tool. Is this supported
> by wsdl2java? If not which class I should look to customize the generated
> code? I need to do the same for client.
> 
> Thanks in advance
> 
> Anto
> 

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

Re: Customizing method body of wsdl2java generated code

Posted by Anto Paul <an...@gmail.com>.
Thanks Dan for the velocity template.

I use a code generation tool that generates database persistence logic. If I
could include call to DAO layer in service impl it will be a cool tool to
generate code.

Anto

On Wed, Feb 3, 2010 at 2:31 AM, Christian Schneider <chris@die-schneider.net
> wrote:

> Hi Anto,
>
> normally you generate only the data classes and the interface of your
> service. You simply write the implementation yourself.
> ---
> public MyServiceImpl implements MyService {
> }
> ---
> Where the MyService interface is generated but the MyServiceImpl not.
> So my question to you is why do you want to generate the implementation at
> all?
>
> Greetings
>
> Christian
>
> Am 02.02.2010 11:01, schrieb Anto Paul:
>
>  I need to modify generated Impl class of SEI.
>> Is the impl class is generated using XJC. I thought only request/response
>> objects for data binding are generated by xjc.
>>
>> Anto
>>
>>
>> On Tue, Feb 2, 2010 at 12:49 PM, Christian Schneider<
>> chris@die-schneider.net>  wrote:
>>
>>
>>
>>> Hi Anto,
>>>
>>> I guess the best way to generate additional code is writing a xjc plugin.
>>> Have a look at example 6 in
>>> http://cxf.apache.org/docs/maven-cxf-codegen-plugin-wsdl-to-java.html on
>>> how to use such a plugin .
>>> In the CXF source you can find the source of some xjc plugins (in path
>>> common/xjc). You can use one of those plugins as a base to write your
>>> plugin.
>>> Perhaps you even find what you need in jaxb commons:
>>> https://jaxb2-commons.dev.java.net/
>>>
>>> In any case you should not change generated code manually as this means
>>> you
>>> can not simply regenerate it. Could you explain a little more what
>>> exactly
>>> you want to achieve?
>>>
>>> Greetings
>>>
>>> Christian
>>>
>>>
>>> Am 02.02.2010 08:06, schrieb Anto Paul:
>>>
>>>  Hi,
>>>
>>>
>>>>     How to embed custom code into method body of implementation classes
>>>> generated by wsdl2java tool? I am writing a tool that calls wsdl2java to
>>>> generate service implementation classes from WSDL and the generated code
>>>> should contain code for calling existing service layer. CXF wsdl2java
>>>> generates method body that is no usable by me. Instead of modifying that
>>>> manually or using another tool to modify generated method body, I need
>>>> to
>>>> replace this method body with what I supply to the tool. Is this
>>>> supported
>>>> by wsdl2java? If not which class I should look to customize the
>>>> generated
>>>> code? I need to do the same for client.
>>>>
>>>> Thanks in advance
>>>>
>>>> Anto
>>>>
>>>>
>>>>
>>>>
>>>>
>>>
>>>
>>>
>>
>>
>
>

Re: Customizing method body of wsdl2java generated code

Posted by Christian Schneider <ch...@die-schneider.net>.
Hi Anto,

normally you generate only the data classes and the interface of your 
service. You simply write the implementation yourself.
---
public MyServiceImpl implements MyService {
}
---
Where the MyService interface is generated but the MyServiceImpl not.
So my question to you is why do you want to generate the implementation 
at all?

Greetings

Christian

Am 02.02.2010 11:01, schrieb Anto Paul:
> I need to modify generated Impl class of SEI.
> Is the impl class is generated using XJC. I thought only request/response
> objects for data binding are generated by xjc.
>
> Anto
>
>
> On Tue, Feb 2, 2010 at 12:49 PM, Christian Schneider<
> chris@die-schneider.net>  wrote:
>
>    
>> Hi Anto,
>>
>> I guess the best way to generate additional code is writing a xjc plugin.
>> Have a look at example 6 in
>> http://cxf.apache.org/docs/maven-cxf-codegen-plugin-wsdl-to-java.html on
>> how to use such a plugin .
>> In the CXF source you can find the source of some xjc plugins (in path
>> common/xjc). You can use one of those plugins as a base to write your
>> plugin.
>> Perhaps you even find what you need in jaxb commons:
>> https://jaxb2-commons.dev.java.net/
>>
>> In any case you should not change generated code manually as this means you
>> can not simply regenerate it. Could you explain a little more what exactly
>> you want to achieve?
>>
>> Greetings
>>
>> Christian
>>
>>
>> Am 02.02.2010 08:06, schrieb Anto Paul:
>>
>>   Hi,
>>      
>>>      How to embed custom code into method body of implementation classes
>>> generated by wsdl2java tool? I am writing a tool that calls wsdl2java to
>>> generate service implementation classes from WSDL and the generated code
>>> should contain code for calling existing service layer. CXF wsdl2java
>>> generates method body that is no usable by me. Instead of modifying that
>>> manually or using another tool to modify generated method body, I need to
>>> replace this method body with what I supply to the tool. Is this supported
>>> by wsdl2java? If not which class I should look to customize the generated
>>> code? I need to do the same for client.
>>>
>>> Thanks in advance
>>>
>>> Anto
>>>
>>>
>>>
>>>        
>>
>>      
>    


Re: Customizing method body of wsdl2java generated code

Posted by Anto Paul <an...@gmail.com>.
I need to modify generated Impl class of SEI.
Is the impl class is generated using XJC. I thought only request/response
objects for data binding are generated by xjc.

Anto


On Tue, Feb 2, 2010 at 12:49 PM, Christian Schneider <
chris@die-schneider.net> wrote:

> Hi Anto,
>
> I guess the best way to generate additional code is writing a xjc plugin.
> Have a look at example 6 in
> http://cxf.apache.org/docs/maven-cxf-codegen-plugin-wsdl-to-java.html on
> how to use such a plugin .
> In the CXF source you can find the source of some xjc plugins (in path
> common/xjc). You can use one of those plugins as a base to write your
> plugin.
> Perhaps you even find what you need in jaxb commons:
> https://jaxb2-commons.dev.java.net/
>
> In any case you should not change generated code manually as this means you
> can not simply regenerate it. Could you explain a little more what exactly
> you want to achieve?
>
> Greetings
>
> Christian
>
>
> Am 02.02.2010 08:06, schrieb Anto Paul:
>
>  Hi,
>>
>>     How to embed custom code into method body of implementation classes
>> generated by wsdl2java tool? I am writing a tool that calls wsdl2java to
>> generate service implementation classes from WSDL and the generated code
>> should contain code for calling existing service layer. CXF wsdl2java
>> generates method body that is no usable by me. Instead of modifying that
>> manually or using another tool to modify generated method body, I need to
>> replace this method body with what I supply to the tool. Is this supported
>> by wsdl2java? If not which class I should look to customize the generated
>> code? I need to do the same for client.
>>
>> Thanks in advance
>>
>> Anto
>>
>>
>>
>
>

Re: Customizing method body of wsdl2java generated code

Posted by Christian Schneider <ch...@die-schneider.net>.
Hi Anto,

I guess the best way to generate additional code is writing a xjc 
plugin. Have a look at example 6 in 
http://cxf.apache.org/docs/maven-cxf-codegen-plugin-wsdl-to-java.html on 
how to use such a plugin .
In the CXF source you can find the source of some xjc plugins (in path 
common/xjc). You can use one of those plugins as a base to write your 
plugin.
Perhaps you even find what you need in jaxb commons: 
https://jaxb2-commons.dev.java.net/

In any case you should not change generated code manually as this means 
you can not simply regenerate it. Could you explain a little more what 
exactly you want to achieve?

Greetings

Christian


Am 02.02.2010 08:06, schrieb Anto Paul:
> Hi,
>
>      How to embed custom code into method body of implementation classes
> generated by wsdl2java tool? I am writing a tool that calls wsdl2java to
> generate service implementation classes from WSDL and the generated code
> should contain code for calling existing service layer. CXF wsdl2java
> generates method body that is no usable by me. Instead of modifying that
> manually or using another tool to modify generated method body, I need to
> replace this method body with what I supply to the tool. Is this supported
> by wsdl2java? If not which class I should look to customize the generated
> code? I need to do the same for client.
>
> Thanks in advance
>
> Anto
>
>