有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!


共 (5) 个答案

  1. # 1 楼答案

    JAXB不支持RPC/编码。使用JAX-RPC解决此问题

  2. # 2 楼答案

    我使用的是axis1的wsdl2java实用程序。我们在数组上得到了类似的错误

    Exception in thread "main" org.apache.axis2.wsdl.codegen.CodeGenerationException: java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
                at org.apache.axis2.wsdl.codegen.CodeGenerationEngine.generate(CodeGenerationEngine.java:271)
                at org.apache.axis2.wsdl.WSDL2Code.main(WSDL2Code.java:35)
                at org.apache.axis2.wsdl.WSDL2Java.main(WSDL2Java.java:24)
        Caused by: java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
                at org.apache.axis2.wsdl.codegen.extension.SimpleDBExtension.engage(SimpleDBExtension.java:53)
                at org.apache.axis2.wsdl.codegen.CodeGenerationEngine.generate(CodeGenerationEngine.java:224)
                ... 2 more
        Caused by: java.lang.reflect.InvocationTargetException
                at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                at java.lang.reflect.Method.invoke(Method.java:597)
                at org.apache.axis2.wsdl.codegen.extension.SimpleDBExtension.engage(SimpleDBExtension.java:50)
                ... 3 more
        Caused by: org.apache.axis2.schema.SchemaCompilationException: can not find type {http://schemas.xmlsoap.org/soap/encoding/}Array from the parent schema ....
                at org.apache.axis2.schema.SchemaCompiler.copyMetaInfoHierarchy(SchemaCompiler.java:1296)
                at org.apache.axis2.schema.SchemaCompiler.processComplexContent(SchemaCompiler.java:1258)
                at org.apache.axis2.schema.SchemaCompiler.processContentModel(SchemaCompiler.java:1153)
                at org.apache.axis2.schema.SchemaCompiler.processComplexType(SchemaCompiler.java:1097)
                at org.apache.axis2.schema.SchemaCompiler.processNamedComplexSchemaType(SchemaCompiler.java:1017)
    

    正如上面soapenc上的一个答案所解释的。在xsd中,我尝试通过创建soapenc来更新我的wsdl文件。包含网站“http://schemas.xmlsoap.org/soap/encoding/”内容的xsd。 如下图所示,这对我来说非常有效

    <definitions xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:ns1= .. xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns=.. xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace=..>
    <types>
        <schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:soap-enc="http://schemas.xmlsoap.org/soap/encoding/" targetNamespace=.. xmlns:ns1=.. xmlns:ns2=.. xmlns:tns=.. xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"/>
    </types>
    <import location="soapenc.xsd" namespace="http://schemas.xmlsoap.org/soap/encoding/"/>
    <message name="Input">
        <part name=../>
    </message>
    <message name="Output">
        <part name=../>
    </message>
    <portType name=".."> .. </portType>
    <binding name="..." type="tns:"..">
        <operation name="...">          ..          </operation>
        <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
    </binding>
    <service name="...">
        <port binding="tns:..." name="...">         <soap:address location="..."/>      </port>
    </service>
    

  3. # 3 楼答案

    我认为最好的方法是使用旧的好轴1.4。它被设计为与rpc服务一起工作,并且通常完成它的工作。主要的问题是这个库非常非常旧(jar在2006年被上传到了central),它不再被维护

    如果您决定尝试一下,只需在pom中添加以下依赖项:

    <dependency>
        <groupId>axis</groupId>
        <artifactId>axis</artifactId>
        <version>1.4</version>
    </dependency>
    

    添加以下插件:

    <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>axistools-maven-plugin</artifactId>
        <version>1.4</version>
        <executions>
            <execution>
                <goals>
                    <goal>wsdl2java</goal>
                </goals>
            </execution>
        </executions>
        <dependencies>
            <dependency>
                <groupId>javax.activation</groupId>
                <artifactId>javax.activation-api</artifactId>
                <version>1.2.0</version>
            </dependency>
            <dependency>
                <groupId>javax.mail</groupId>
                <artifactId>mail</artifactId>
                <version>1.4.7</version>
            </dependency>
        </dependencies>
        <configuration>
            <sourceDirectory>${project.basedir}/src/main/resources</sourceDirectory>
            <wsdlFiles>
                <wsdlFile>my_service.wsdl</wsdlFile>
            </wsdlFiles>
        </configuration>
    </plugin>
    

    将您的wsdl文件放入src/main/resources/my_service.wsdl,并通过mvn clean package构建应用程序

    插件详细信息可在here中找到

  4. # 4 楼答案

    您的架构引用了架构xmlns:SOAP-ENC=”中定义的类型SOAP-ENC:Arrayhttp://schemas.xmlsoap.org/soap/encoding/“但该模式不包括在wsdl中

    我遇到了一个类似的问题,必须使用目录来告诉jaxb/xjc在哪里可以找到模式

    转到http://schemas.xmlsoap.org/soap/encoding/并另存为soapenc。xsd

    然后创建一个包含以下内容的纯文本文件

    PUBLIC "http://schemas.xmlsoap.org/soap/encoding/" "soapenc.xsd"
    

    然后将该文件作为目录文件传递给xjc


    更新:如果你在maven上,这就是它如何结合在一起的

    放置模式soapenc。xsd和目录。src/main/resources中的cat(纯文本文件)

    然后告诉jaxb插件将目录传递给xjc

    <plugin>
        <groupId>org.jvnet.jaxb2.maven2</groupId>
        <artifactId>maven-jaxb2-plugin</artifactId>
        <executions>
          <execution>
            <id>wsdl-generate</id>
            <configuration>
              <schemaIncludes>
                <include>*.wsdl</include>
              </schemaIncludes>
              <catalog>${project.basedir}/src/main/resources/catalog.cat</catalog>
            </configuration>
            <goals>
              <goal>generate</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    
  5. # 5 楼答案

    检查WS-I基本配置文件-1.1规范 http://www.ws-i.org/Profiles/BasicProfile-1.1.html#soapenc_Array

    它说:

    R2110在描述中,声明不能扩展或限制soapenc:Array类型

    R2111在描述中,声明不能在类型声明中使用wsdl:arrayType属性

    R2112在描述中,不应使用约定ArrayOfXXX命名元素

    R2113信封不得包含soapenc:arrayType属性

    哟!