You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Alex Shneyderman <a....@gmail.com> on 2011/11/09 16:10:25 UTC

Binding of imported types probelm

Hi, all!

I have a problem with wsdl2java not generating types for a particular
XSD to the correct package.

I have a WSDL that imports one XSD which in turn imports another XSD.
I would like the types from the second XSD go into a pre-determined
package. They however go into the default. Any hints on how to achieve
this customization?

Here is the setup I have. Directory layout goes like this:

src/main/
   jaxb/
       mobile-partner-schema-binding.xjb
       troubleticket-schema-binding.xjb
   xsd/
       assurance/
           partner/
              troubleticket.xsd
       mobile/
           partner/
              Mobile_v2.wsdl
              Mobile_v2.xsd

Mobile_v2.wsdl:
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions name="Mobile"
    targetNamespace="urn:mobile.ws.test"
    xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
    xmlns:tns="urn:mobile.ws.test"
    xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema">

    <wsdl:types>
        <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
            <xsd:import namespace="urn:mobile.ws.test"
schemaLocation="Mobile_v2.xsd" />
        </xsd:schema>
    </wsdl:types>

...
</wsdl:definitions>

Mobile_v2.xsd:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
           xmlns="urn:mobile.ws.test"
           xmlns:tns="urn:mobile.ws.test"
           xmlns:tt="urn:troubleticket.ws.test"
           targetNamespace="urn:mobile.ws.test"
           elementFormDefault="qualified">

    <xs:import namespace="urn:troubleticket.ws.test"
               schemaLocation="../../assurance/partner/troubleticket.xsd" />
...

</xs:schema>

troubleticket.xsd:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
           xmlns="urn:troubleticket.ws.test"
           targetNamespace="urn:troubleticket.ws.test"
           elementFormDefault="qualified">

    <xs:complexType name="TroubleTicket">
        <xs:annotation>
            <xs:documentation>Trouble ticket.</xs:documentation>
        </xs:annotation>
...
    </xs:complexType>

...

</xs:schema>


troubleticket-schema-binding.xjb:
<jxb:bindings version="1.0"
	xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
	xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
	xmlns:xs="http://www.w3.org/2001/XMLSchema">

	<jxb:bindings schemaLocation="../xsd/assurance/partner/troubleticket.xsd"
node="/xs:schema">
		<jxb:schemaBindings>
			<jxb:package name="troubleticket.app.ws.partner.types"/>
		</jxb:schemaBindings>
	</jxb:bindings>

</jxb:bindings>

the pom config for the plugin is like so:

                              <wsdlOption>
                                    <wsdl>

${basedir}/src/main/xsd/mobile/partner/Mobile_v2.wsdl
                                    </wsdl>
                                    <extraargs>
                                        <extraarg>-validate</extraarg>
                                        <extraarg>-b</extraarg>
                                        <extraarg>

${basedir}/src/main/jaxb/mobile-partner-schema-binding.xjb
                                        </extraarg>
                                        <extraarg>-b</extraarg>
                                        <extraarg>

${basedir}/src/main/jaxws/troubleticket-definitions-binding.xjb
                                        </extraarg>
                                        <extraarg>-verbose</extraarg>
                                    </extraargs>
                                </wsdlOption>

Somehow, TroubleTicket type gets generated to the default package
test.ws.troubleticket instead of my expected package that I am trying
to bind to troubleticket.app.ws.partner.types

Any ideas on how I can force the CXF's hand on this and have the types
to generate into the package I want?

Thanks,
Alex.

Re: Binding of imported types probelm

Posted by Alex Shneyderman <a....@gmail.com>.
Yes I did schemaLocation fiddling and that did not work for me. The
only way I could force wsdl2java generate what I needed is to provide
-p, specifiying namespace to java package correspondence. That worked!

It solved my problem but sure looks like a bug just do not know where.

I will try to reproduce the problem on a smaller scale. Although, what
I had i my mail is the version stripped down to the bare minimum. I
will try to produce a zip file, so you could just unzip and try it
out.

Thanks for your help,
Alex.

On Tue, Nov 15, 2011 at 10:31 PM, Daniel Kulp <dk...@apache.org> wrote:
>
>
> Your setup looks correct to me.   Is there any chance you can create a small
> testcase that shows the issue that we can look at?   It's usually an issue
> trying to find a schema with the right name.
>
> You could try changing:
>  schemaLocation="../xsd/assurance/partner/troubleticket.xsd"
>
> to just:
>  schemaLocation="troubleticket.xsd"
>
> but I'm not really sure if that will help.
>
>
>
> Dan
>
>
> On Wednesday, November 09, 2011 4:10:25 PM Alex Shneyderman wrote:
>> Hi, all!
>>
>> I have a problem with wsdl2java not generating types for a particular
>> XSD to the correct package.
>>
>> I have a WSDL that imports one XSD which in turn imports another XSD.
>> I would like the types from the second XSD go into a pre-determined
>> package. They however go into the default. Any hints on how to achieve
>> this customization?
>>
>> Here is the setup I have. Directory layout goes like this:
>>
>> src/main/
>>    jaxb/
>>        mobile-partner-schema-binding.xjb
>>        troubleticket-schema-binding.xjb
>>    xsd/
>>        assurance/
>>            partner/
>>               troubleticket.xsd
>>        mobile/
>>            partner/
>>               Mobile_v2.wsdl
>>               Mobile_v2.xsd
>>
>> Mobile_v2.wsdl:
>> <?xml version="1.0" encoding="UTF-8"?>
>> <wsdl:definitions name="Mobile"
>>     targetNamespace="urn:mobile.ws.test"
>>     xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
>>     xmlns:tns="urn:mobile.ws.test"
>>     xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
>>     xmlns:xsd="http://www.w3.org/2001/XMLSchema">
>>
>>     <wsdl:types>
>>         <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
>>             <xsd:import namespace="urn:mobile.ws.test"
>> schemaLocation="Mobile_v2.xsd" />
>>         </xsd:schema>
>>     </wsdl:types>
>>
>> ...
>> </wsdl:definitions>
>>
>> Mobile_v2.xsd:
>> <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
>> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
>>            xmlns="urn:mobile.ws.test"
>>            xmlns:tns="urn:mobile.ws.test"
>>            xmlns:tt="urn:troubleticket.ws.test"
>>            targetNamespace="urn:mobile.ws.test"
>>            elementFormDefault="qualified">
>>
>>     <xs:import namespace="urn:troubleticket.ws.test"
>>                schemaLocation="../../assurance/partner/troubleticket.xsd" />
>> ...
>>
>> </xs:schema>
>>
>> troubleticket.xsd:
>> <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
>> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
>>            xmlns="urn:troubleticket.ws.test"
>>            targetNamespace="urn:troubleticket.ws.test"
>>            elementFormDefault="qualified">
>>
>>     <xs:complexType name="TroubleTicket">
>>         <xs:annotation>
>>             <xs:documentation>Trouble ticket.</xs:documentation>
>>         </xs:annotation>
>> ...
>>     </xs:complexType>
>>
>> ...
>>
>> </xs:schema>
>>
>>
>> troubleticket-schema-binding.xjb:
>> <jxb:bindings version="1.0"
>>       xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
>>       xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
>>       xmlns:xs="http://www.w3.org/2001/XMLSchema">
>>
>>       <jxb:bindings schemaLocation="../xsd/assurance/partner/troubleticket.xsd"
>> node="/xs:schema">
>>               <jxb:schemaBindings>
>>                       <jxb:package name="troubleticket.app.ws.partner.types"/>
>>               </jxb:schemaBindings>
>>       </jxb:bindings>
>>
>> </jxb:bindings>
>>
>> the pom config for the plugin is like so:
>>
>>                               <wsdlOption>
>>                                     <wsdl>
>>
>> ${basedir}/src/main/xsd/mobile/partner/Mobile_v2.wsdl
>>                                     </wsdl>
>>                                     <extraargs>
>>                                         <extraarg>-validate</extraarg>
>>                                         <extraarg>-b</extraarg>
>>                                         <extraarg>
>>
>> ${basedir}/src/main/jaxb/mobile-partner-schema-binding.xjb
>>                                         </extraarg>
>>                                         <extraarg>-b</extraarg>
>>                                         <extraarg>
>>
>> ${basedir}/src/main/jaxws/troubleticket-definitions-binding.xjb
>>                                         </extraarg>
>>                                         <extraarg>-verbose</extraarg>
>>                                     </extraargs>
>>                                 </wsdlOption>
>>
>> Somehow, TroubleTicket type gets generated to the default package
>> test.ws.troubleticket instead of my expected package that I am trying
>> to bind to troubleticket.app.ws.partner.types
>>
>> Any ideas on how I can force the CXF's hand on this and have the types
>> to generate into the package I want?
>>
>> Thanks,
>> Alex.
> --
> Daniel Kulp
> dkulp@apache.org
> http://dankulp.com/blog
> Talend - http://www.talend.com
>

Re: Binding of imported types probelm

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

Your setup looks correct to me.   Is there any chance you can create a small 
testcase that shows the issue that we can look at?   It's usually an issue 
trying to find a schema with the right name.

You could try changing:
 schemaLocation="../xsd/assurance/partner/troubleticket.xsd"

to just:
 schemaLocation="troubleticket.xsd"

but I'm not really sure if that will help.



Dan


On Wednesday, November 09, 2011 4:10:25 PM Alex Shneyderman wrote:
> Hi, all!
> 
> I have a problem with wsdl2java not generating types for a particular
> XSD to the correct package.
> 
> I have a WSDL that imports one XSD which in turn imports another XSD.
> I would like the types from the second XSD go into a pre-determined
> package. They however go into the default. Any hints on how to achieve
> this customization?
> 
> Here is the setup I have. Directory layout goes like this:
> 
> src/main/
>    jaxb/
>        mobile-partner-schema-binding.xjb
>        troubleticket-schema-binding.xjb
>    xsd/
>        assurance/
>            partner/
>               troubleticket.xsd
>        mobile/
>            partner/
>               Mobile_v2.wsdl
>               Mobile_v2.xsd
> 
> Mobile_v2.wsdl:
> <?xml version="1.0" encoding="UTF-8"?>
> <wsdl:definitions name="Mobile"
>     targetNamespace="urn:mobile.ws.test"
>     xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
>     xmlns:tns="urn:mobile.ws.test"
>     xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
>     xmlns:xsd="http://www.w3.org/2001/XMLSchema">
> 
>     <wsdl:types>
>         <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
>             <xsd:import namespace="urn:mobile.ws.test"
> schemaLocation="Mobile_v2.xsd" />
>         </xsd:schema>
>     </wsdl:types>
> 
> ...
> </wsdl:definitions>
> 
> Mobile_v2.xsd:
> <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
>            xmlns="urn:mobile.ws.test"
>            xmlns:tns="urn:mobile.ws.test"
>            xmlns:tt="urn:troubleticket.ws.test"
>            targetNamespace="urn:mobile.ws.test"
>            elementFormDefault="qualified">
> 
>     <xs:import namespace="urn:troubleticket.ws.test"
>                schemaLocation="../../assurance/partner/troubleticket.xsd" />
> ...
> 
> </xs:schema>
> 
> troubleticket.xsd:
> <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
>            xmlns="urn:troubleticket.ws.test"
>            targetNamespace="urn:troubleticket.ws.test"
>            elementFormDefault="qualified">
> 
>     <xs:complexType name="TroubleTicket">
>         <xs:annotation>
>             <xs:documentation>Trouble ticket.</xs:documentation>
>         </xs:annotation>
> ...
>     </xs:complexType>
> 
> ...
> 
> </xs:schema>
> 
> 
> troubleticket-schema-binding.xjb:
> <jxb:bindings version="1.0"
> 	xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
> 	xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
> 	xmlns:xs="http://www.w3.org/2001/XMLSchema">
> 
> 	<jxb:bindings schemaLocation="../xsd/assurance/partner/troubleticket.xsd"
> node="/xs:schema">
> 		<jxb:schemaBindings>
> 			<jxb:package name="troubleticket.app.ws.partner.types"/>
> 		</jxb:schemaBindings>
> 	</jxb:bindings>
> 
> </jxb:bindings>
> 
> the pom config for the plugin is like so:
> 
>                               <wsdlOption>
>                                     <wsdl>
> 
> ${basedir}/src/main/xsd/mobile/partner/Mobile_v2.wsdl
>                                     </wsdl>
>                                     <extraargs>
>                                         <extraarg>-validate</extraarg>
>                                         <extraarg>-b</extraarg>
>                                         <extraarg>
> 
> ${basedir}/src/main/jaxb/mobile-partner-schema-binding.xjb
>                                         </extraarg>
>                                         <extraarg>-b</extraarg>
>                                         <extraarg>
> 
> ${basedir}/src/main/jaxws/troubleticket-definitions-binding.xjb
>                                         </extraarg>
>                                         <extraarg>-verbose</extraarg>
>                                     </extraargs>
>                                 </wsdlOption>
> 
> Somehow, TroubleTicket type gets generated to the default package
> test.ws.troubleticket instead of my expected package that I am trying
> to bind to troubleticket.app.ws.partner.types
> 
> Any ideas on how I can force the CXF's hand on this and have the types
> to generate into the package I want?
> 
> Thanks,
> Alex.
-- 
Daniel Kulp
dkulp@apache.org
http://dankulp.com/blog
Talend - http://www.talend.com