简体   繁体   中英

Jaxb cxf-xjc pluggin generated with namespace

I am using cfx-xjc-pluging to create some classes. In code I can create the objects, marshal and unmarshal no problem.

Now though I started making the call the the soap endpoint and am running into an issue. The returned object from the service provider does not have namespaces while the marshal and unmarshal appear to expect it.

The build is like so:

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-xjc-plugin</artifactId>
            <version>${cxf.xjc.plugin.version}</version>
            <executions>
                <execution>
                    <id>xjc</id>
                    <phase>generate-sources</phase>
                    <goals>
                        <goal>xsdtojava</goal>
                    </goals>
                    <configuration>
                        <xsdOptions>
                            <xsdOption>
                                <xsdDir>${basedir}\src\main\resources\xsd\TotalView-06-2019</xsdDir>
                                <bindingFile>${basedir}\src\main\resources\bindings\work.xjb</bindingFile>
                                <packagename>${jax.package.name}</packagename>
                            </xsdOption>
                        </xsdOptions>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

What I am seeing is that the generated package-info.java has

@javax.xml.bind.annotation.XmlSchema(namespace ="http://xml.place.com/XMLSchema")
package com.code.place.generated;

Which does not include elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED I think this is what is needed to stop the use of namespaces but this is my first dive into xml in java and could be off base.

Is there a way to stop Jaxb/cfx-xjc-pluging from expecting the namespace or add it to the xml when calling to the service?

Well this is not much of a solution as much as it is a hack. In the provided schema I was able to change elementFormDefault="unqualified" to elementFormDefault="qualified" and the classes do not expect namespaces when marshaling now. I cannot help but think there has to be a better way.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM