funny-shmunny
funny-shmunny

Reputation: 97

Multiple <schemaBindings> for the target namespace in single file

I'm using maven-jaxb2-plugin for generating java files from wsdl one. After running "generate-sources" goal I get the following error

[ERROR] Error while parsing schema(s).Location[
file:/home/*/src/main/resources/soap/binding.xjb{8,30} ]. 
com.sun.istack.SAXParseException2; systemId: file:/home/*/src/main/resources/soap/binding.xjb; lineNumber: 8; columnNumber: 30; 
Multiple <schemaBindings> are defined for the target namespace "http://schemas.***"

There are several wsdl files and for each of them I need different target package, so I tried using binding file, but for only 1 wsdl for now.

Here is my plugin configuraiton

<configuration>
    <schemaLanguage>WSDL</schemaLanguage>
    <schemaDirectory>
        ${basedir}/src/main/resources/soap
    </schemaDirectory>
    <schemaIncludes>
        <include>manager/*.wsdl</include>
    </schemaIncludes>
    <bindingDirectory>
        ${basedir}/src/main/resources/soap
    </bindingDirectory>
</configuration>

Here is binding.xjb file

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<jaxb:bindings
        version="2.1"
        xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
        xmlns:xs="http://www.w3.org/2001/XMLSchema">

    <jaxb:bindings schemaLocation="manager/service.wsdl" multiple="true" node="//xs:schema">
        <jaxb:schemaBindings>
            <jaxb:package name="com.test.manager"/>
        </jaxb:schemaBindings>
    </jaxb:bindings>
</jaxb:bindings>

Beginning of service.wsdl file

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
                  xmlns:sch0="http://schemas.***"
                  xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
                  xmlns:tns="http://schemas.***"
                  targetNamespace="http://schemas.***">
    <wsdl:types>
        <xs:schema xmlns="http://schemas.***" 
                   xmlns:xs="http://www.w3.org/2001/XMLSchema" 
                   attributeFormDefault="unqualified" 
                   elementFormDefault="qualified" 
                   targetNamespace="http://schemas.***">
            <xs:simpleType name="NumericReference">
                ***
            </xs:simpleType> 
            <xs:simpleType name="EntityNumber">
                ***
            </xs:simpleType>
        </xs:schema>
        <xs:schema xmlns="http://schemas.***" 
                   xmlns:xs="http://www.w3.org/2001/XMLSchema" 
                   attributeFormDefault="unqualified" 
                   elementFormDefault="qualified" 
                   targetNamespace="http://schemas.***">
            <xs:complexType name="DisplayGroup">

Looks like the problem is connected with multiple xs:schema elements with same targetNamespace, but I can't find how to fix it without modifying wsdl.

Upvotes: 0

Views: 2488

Answers (1)

lexicore
lexicore

Reputation: 43651

JAXB typically maps one target namespace onto one package, so you can't specify different schemaBindings for the same target namespace.

Upvotes: 2

Related Questions