Wsimport无法正常工作

时间:2016-02-26 09:52:21

标签: java wsdl webservice-client

我想用Java编写WebService客户端,但它不起作用。  

我用

#!/bin/sh # second.sh ... if login using ftp worked; then exit 0 else exit 1 fi  

运行命令,我得到的结果如下:操作“Consulta_EDOPROC”多个链接到正文部分。第58行

"c:\Program Files (x86)\Java\jdk1.8.0_60\bin\wsimport.exe" http://ovc.catastro.meh.es/ovcservweb/OVCSWLocalizacionRC/OVCCallejero.asmx?wsdl

2 个答案:

答案 0 :(得分:1)

我有同样的问题,我已经这样解决了:

  1. 我已经创建了一个Maven项目。
  2. 在pom.xml中,我添加了“ org.codehaus.mojo:jaxws-maven-plugin ”插件。
  3. 我已经在 src / main / binding / binding.xml
  4. 中创建了一个绑定文件
  5. 我已经使用服务器https://ovc.catastro.meh.es/的证书路径创建了一个信任库文件。

pom.xml 中的“插件”部分:

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>jaxws-maven-plugin</artifactId>
    <version>2.5</version>
    <configuration>
        <sourceDestDir>${project.build.sourceDirectory}</sourceDestDir>
        <bindingDirectory>${project.basedir}/src/main/bindings</bindingDirectory>
        <extension>true</extension>
        <genWsdl>false</genWsdl>           
        <xdisableSSLHostnameVerification>false</xdisableSSLHostnameVerification>
        <keep>true</keep>
        <protocol>soap1.1</protocol>
        <verbose>true</verbose>
        <xnocompile>true</xnocompile>
        <xdebug>true</xdebug>
    </configuration>
    <executions>
        <execution>
          <goals>
              <goal>wsimport</goal>
          </goals>
          <configuration>
              <vmArgs>
                  <vmArg>-Djavax.net.ssl.trustStore=${project.basedir}/src/main/ssl/catastro.jks</vmArg>
                 <vmArg>-Djavax.net.ssl.trustStorePassword=changeit</vmArg>
             </vmArgs>
             <wsdlUrls>
                 <wsdlUrl>https://ovc.catastro.meh.es/ovcservweb/OVCSWLocalizacionRC/OVCCallejero.asmx?WSDL</wsdlUrl>
             </wsdlUrls>
         </configuration>
        </execution>
    </executions>
</plugin>

重要:使用<extension>true</extension>标签。

binding.xml 源代码:

<?xml version="1.0" encoding="UTF-8"?>
<jxb:bindings version="1.0"
    xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
    xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
    xmlns:annox="http://annox.dev.java.net"
    xmlns:xs="http://www.w3.org/2001/XMLSchema">

    <jxb:globalBindings collectionType="java.util.ArrayList" 
        underscoreBinding="asCharInWord"
        enableJavaNamingConventions="true" generateIsSetMethod="false"
        typesafeEnumBase="xs:string" typesafeEnumMemberName="generateName">
        <jxb:serializable uid="1" />
    </jxb:globalBindings>

</jxb:bindings>

执行mvn clean install,插件将生成JAXB类:

[INFO] Processing: https://ovc.catastro.meh.es/ovcservweb/OVCSWLocalizacionRC/OVCCallejero.asmx?WSDL
[INFO] jaxws:wsimport args: [-keep, -s, '/workspace/catastro-workitem/src/main/java', -d, '/workspace/catastro-workitem/target/classes', -verbose, -encoding, UTF-8, -extension, -Xnocompile, -Xdebug, -b, 'file:/workspace/catastro-workitem/src/main/bindings/binding.xml', "https://ovc.catastro.meh.es/ovcservweb/OVCSWLocalizacionRC/OVCCallejero.asmx?WSDL"]

parsing WSDL...
.../...
.../...
Generating code...

es/meh/catastro/Callejero.java
es/meh/catastro/Consulta_DNP.java
es/meh/catastro/Consulta_DNPPP.java
es/meh/catastro/Municipios.java
es/meh/catastro/ObjectFactory.java
es/meh/catastro/Provincias.java
es/meh/catastro/package-info.java
org/tempuri/ovcservweb/ovccallejero/CallejeroX0020DeX0020LaX0020SedeX0020ElectrónicaX0020DelX0020Catastro.java
org/tempuri/ovcservweb/ovccallejero/CallejeroX0020DeX0020LaX0020SedeX0020ElectrónicaX0020DelX0020CatastroHttpGet.java
org/tempuri/ovcservweb/ovccallejero/CallejeroX0020DeX0020LaX0020SedeX0020ElectrónicaX0020DelX0020CatastroHttpPost.java
org/tempuri/ovcservweb/ovccallejero/CallejeroX0020DeX0020LaX0020SedeX0020ElectrónicaX0020DelX0020CatastroSoap.java
org/tempuri/ovcservweb/ovccallejero/package-info.java

答案 1 :(得分:0)

Theres问题与wsdl一起命名为&#34; Body&#34;就像

一样
<wsdl:message name="Consulta_DNPRCHttpGetOut">
<wsdl:part name="Body"/>
</wsdl:message>

甚至在警告信息中被视为

[WARNING] warning: part Body is ignored, either the "element" or the "type" attribute is required in part "Body"
  line 125 of http://ovc.catastro.meh.es/ovcservweb/OVCSWLocalizacionRC/OVCCallejero.asmx?wsdl

ISSUE是该部分应该有缺少的元素或类型属性。得到纠正&amp;你可以通过wsimport获得相应的java对象。