Hi,

Now I understand that editing the generated files from wsdl2java is not a
good practice with the exception of skeleton code. Because if you change
wsdl in future you got to generate java files (wrapper objects) again which
will not contain changes I did manually so I got to put that code manually
again and its not a good design practice.

So, now I have a design issue, I want to implement Strategy pattern in my
service piece .Here is the problem description,

1) My service is using ADB framework and I have a requirement for a client
to send POJO to service end. So, here I have an interface and implementation
class

Transporter (Interface) --> ABCTransporter (Implementation class) under
package name "service"
So, class names are com.service.Transporter and com.service.ABCTransporter

Basically these classes have getters and setters (i.e. POJO) and I want to
pass this object (ABCTransporter) from client (Java SOAP client) to server
(webservice).

Here is the WSDL code,


    <wsdl:types>
    <schema>     
     <element name="MessageRequest"> 
        <complexType> 
            <sequence> 
                  <element name="transporter" nillable="true"
type="tns:Transporter"/> 
           </sequence> 
        </complexType> 
     </element> 
      <complexType abstract="true" name="Transporter"/> 
        <complexType name="ABCTransporter"> 
        <complexContent> 
              <extension base="tns:Transporter"> 
                         <sequence> 
                                <element name="StartDate" nillable="true"
type="xsd:string"/> 
                                <element name="EndDate" nillable="true"
type="xsd:string"/> 
                          </sequence> 
              </extension> 
        </complexContent> 
     </complexType> 
     </schema>
    </wsdl:types>
    <wsdl:message name="addRequest">
                <wsdl:part name="part1" element="tns:MessageRequest"/>
   </wsdl:message>


2) Now WSDL2Java creates wrapper objects on these message transport objects
which will create under package called "webservice" i.e.
com.webservice.Transporter and com.webservice.ABCTransporter

3) Now at the service end when the request comes in, it will receive
com.webservice.ABCTransporter thats what client is sending

        com.webservice.Transporter transporter =
(com.webservice.Transporter) msgRequest.getTransporter();
         //The following condition determines if the request is from ABC or
BCD
         if (transporter instanceof com.webservice.ABCTransporter) {

The above line is the problem with if condition, how could I get rid off if
and else conditions, can I use Strategy pattern but again I have no control
over com.webservice.Transporter & com.webservice.ABCTransporter classes as
these are generated by wsdl2java tool on top of my domain classes
com.service.Transporter & com.service.ABCTransporter

Any ideas. Thanks.

- Anil


Anil VVNN wrote:
> 
> Philipp,
> 
> Are you referring to "<arg line="-p com.myprj.webservice"/>" in my ant
> script. if so, I removed this line but it is still overriding the files
> under com.myprj.webservice directory. 
> 
> Observed that it is not overriding code of Stub, Skeleton and
> MessageReceiverInOut but it is overriding wrapper objects of complex
> types. 
> 
> What I mean is, here is my wsdl file,
> 
> <element name="MessageRequest">
>       <complexType>
>           <sequence>
>               <element name="transporter" nillable="true" 
> type="tns:Transporter"/>
>          </sequence>
>       </complexType>
> </element>
>       <complexType abstract="true" name="Transporter"/>
>       <complexType name="ABCTransporter">
>       <complexContent>
>             <extension base="tns:Transporter">
>                 <sequence>
>               <element name="StartDate" nillable="true" type="xsd:string"/>
>                                 <element name="EndDate" nillable="true"
> type="xsd:string"/>
>                           </sequence>
>             </extension>
>                </complexContent>
>      </complexType>
> 
> Transporter is an Interface and ABCTransporter implementation class in my
> object model. But I want to modify corresponding wrapper objects
> (Transporter  and ABCTransporter ) created by wsdl2java, so I did but when
> I run wsdl2java again, it creates new wrapper objects of Transporter and
> ABCTransporter and I loose my changes.
> 
> Any ideas how would I do to not to override these wrapper objects. Thanks.
> 
>   
> 
> 
> 
> 
> Philipp Leitner-2 wrote:
>> 
>> you should pass a target package as argument to wsdl2java to prevent it 
>> from overriding existing source files.
>> 
>> /philipp
>> 
>> Anil VVNN schrieb:
>>> Hi,
>>> 
>>> Any option to not to override files if they are already present. As I
>>> have
>>> modified few classes (wrapper objects of complex types) and skeleton
>>> code.
>>> 
>>> Here is my call in ant scripts,
>>> 
>>>       <java classname="org.apache.axis2.wsdl.WSDL2Java" fork="true"
>>> classpathref="axis.classpath">
>>>         <arg line="-uri ./ws/${src.xml.dir}/${wsdl.file}"/>
>>>         <arg line="-ss"/>
>>>         <arg line="-sd"/>
>>>         <arg line="-ssi"/>
>>>         <arg line="-d adb"/>
>>>         <arg line="-g"/>
>>>         <arg line="-p com.myprj.webservice"/>
>>>         <arg line="-o ${basedir}/ws/src/java"/>
>>>         <arg line="-S ."/>
>>>       </java>
>>> 
>>> Thanks.
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> For additional commands, e-mail: [EMAIL PROTECTED]
>> 
>> 
>> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/-Axis2--wsdl2java-overriding-my-files-tf3553485.html#a9958925
Sent from the Axis - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to