首页 > 解决方案 > 使用axistools-maven-plugin时未检测到全局绑定

问题描述

使用 org.codehaus.mojo > axistools-maven-plugin 生成 wsdl2java。pom.xml 中指定的插件如下:

    <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>axistools-maven-plugin</artifactId>
                <version>1.4</version>
                <configuration>
                    <sourceDirectory>${basedir}/src/wsdl/</sourceDirectory>
                    <typeMappingVersion>1.2</typeMappingVersion>
                    <wrapArrays>false</wrapArrays>
                </configuration>
                <executions>
                    <execution>
                        <id>all</id>
                        <configuration>
                            <wsdlFiles> 
                                <wsdlFile>Market.wsdl</wsdlFile>
                                <wsdlFile>Payment.wsdl</wsdlFile>
                                <wsdlFile>Customer.wsdl</wsdlFile>
                                
                            </wsdlFiles>
                            <bindingFiles>
                                 <bindingFile>${basedir}/src/wsdl/globalBinding.xml</bindingFile>
                            </bindingFiles>
                        </configuration>
                        <goals>
                            <goal>wsdl2java</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

全局绑定.xml

<?xml version="1.0" encoding="UTF-8"?>
<jaxws:bindings 
    xmlns:jaxws="http://java.sun.com/xml/ns/jaxws"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    node="wsdl:definitions/wsdl:types/xs:schema"
    wsdlLocation="Customer.wsdl"
    xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
    xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
    xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" version="2.1"
    xmlns:xs="http://www.w3.org/2001/XMLSchema">

    <jaxws:globalBindings>

        <jaxws:javaType name="java.math.BigDecimal"
            xmlType="xsd:decimal"
            parseMethod="javax.xml.bind.DatatypeConverter.parseDecimal"
            printMethod="javax.xml.bind.DatatypeConverter.printDecimal" />

    </jaxws:globalBindings>
</jaxws:bindings>

想要进行此映射,因为 xsd:complexType 之一的编译失败,其中 xsd:restriction base="xsd:decimal" 因为编译错误如下:

 constructor Object in class java.lang.Object cannot be applied to given types;
[ERROR]   required: no arguments
[ERROR]   found: java.math.BigDecimal
[ERROR]   reason: actual and formal argument lists differ in length

修复此错误,尝试添加绑定,但似乎 globalBinding 没有被使用。

标签: javawsdlaxiswsdl2java

解决方案


推荐阅读