-1

I want to program a WebService Client with Java but it doesn't work.

I use

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

Run the command and I obtain like a result: Operation "Consulta_EDOPROC" more than one linked to the body part. line 58

[ERROR] Operación "Consulta_DNPRC": hay más de una parte enlazada al cuerpo.
  línea 58 de http://ovc.catastro.meh.es/ovcservweb/OVCSWLocalizacionRC/OVCCallejero.asmx?wsdl

Exception in thread "main" com.sun.tools.internal.ws.wscompile.AbortException
        at com.sun.tools.internal.ws.processor.modeler.wsdl.WSDLModelerBase.error(WSDLModelerBase.java:732)
        at com.sun.tools.internal.ws.processor.modeler.wsdl.WSDLModeler.setMessagePartsBinding(WSDLModeler.java:1505)
        at com.sun.tools.internal.ws.processor.modeler.wsdl.WSDLModeler.setMessagePartsBinding(WSDLModeler.java:1431)
        at com.sun.tools.internal.ws.processor.modeler.wsdl.WSDLModeler.processLiteralSOAPOperation(WSDLModeler.java:767)
        at com.sun.tools.internal.ws.processor.modeler.wsdl.WSDLModeler.processSOAPOperation(WSDLModeler.java:698)
        at com.sun.tools.internal.ws.processor.modeler.wsdl.WSDLModeler.processPort(WSDLModeler.java:466)
        at com.sun.tools.internal.ws.processor.modeler.wsdl.WSDLModeler.processService(WSDLModeler.java:245)
        at com.sun.tools.internal.ws.processor.modeler.wsdl.WSDLModeler.internalBuildModel(WSDLModeler.java:216)
        at com.sun.tools.internal.ws.processor.modeler.wsdl.WSDLModeler.buildModel(WSDLModeler.java:126)
        at com.sun.tools.internal.ws.wscompile.WsimportTool.buildWsdlModel(WsimportTool.java:429)
        at com.sun.tools.internal.ws.wscompile.WsimportTool.run(WsimportTool.java:190)
        at com.sun.tools.internal.ws.wscompile.WsimportTool.run(WsimportTool.java:168)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:497)
        at com.sun.tools.internal.ws.Invoker.invoke(Invoker.java:159)
        at com.sun.tools.internal.ws.WsImport.main(WsImport.java:42)
1938web
  • 25
  • 1
  • 6

2 Answers2

1

I have the same problem, I have solved it like this:

  1. I have created a Maven project.
  2. In the pom.xml I have added the "org.codehaus.mojo:jaxws-maven-plugin" plugin.
  3. I have created a binding file in src/main/binding/binding.xml
  4. I have create a truststore file with the Certificate Path of the server https://ovc.catastro.meh.es/.

The plugins section in the 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>

Important: Use the <extension>true</extension> tag.

The binding.xml source code:

<?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>

Execute mvn clean install, and the plugin generates the JAXB classes:

[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
nveces
  • 26
  • 1
0

Theres issues with the wsdl wherever the part named "Body" is, like

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

and even its been seen on the warning msg as

[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 is that there should be either element or type attribute on that part which is missing. Get it corrected & you can get respective java objects generated via wsimport.

Avis
  • 2,197
  • 18
  • 28
  • I have a same type of issue but the server side will not do any changes now. Is there an alternative way to parse the wsdl file ? – Raghuveer Mar 22 '18 at 11:08
  • A simple solution will be to copy the WSDL in your local machine and remove elements which are not defined and then use wsimport to generate the POJOs from this modified WSDL. – Avis Mar 23 '18 at 02:20
  • wont that hurt in anyway ? – Raghuveer Mar 23 '18 at 07:23
  • That way you can skip the wsdl elements which are not defined and hence avoid errors and can work with remaining elements. – Avis Mar 23 '18 at 14:44
  • I have onemore question at https://stackoverflow.com/questions/49401040/consume-soap-service-partially-using-spring-web-service please see – Raghuveer Mar 26 '18 at 06:51