1

I am new to Java. I am trying to create SOAP Web service client to consume a vendors webservice which requires username password and ssl certificate.

A vendor provided me SoapUI project file. I imported the project file in SoapUI and ran the tests. Those tests worked successfully.

I then exported the wsdl file using SoapUI and tried to generate java code using wsimport. I am unable to generate code. I am getting all sorts of errors which I tried to resolve by searching online but none of the solutions work.

I am using jdk1.8.0_152. and SoapUI version 5.3.0 by SmartBear.

I tried to use this wsimport command on command line of Windows 7:

wsimport -keep -verbose -s src vendor.wsdl

and I received this message:

[WARNING] Simple type "RiskType" was not mapped to Enum due to EnumMemberSizeCap limit. Facets count: 365, current limit: 256. You can use customization attribute "typesafeEnumMaxMembers" to extend the limit.

line 4317 of file:/C:/Projects/soapclient/vendor.xsd

With the SoapUI Project file they also sent me the below files:

  • jaxbbinding.xml
  • wsdlbinding.xml
  • ACORD_v2.2.0.xsd
  • ACORD-WSP_v2.0.0.xsd
  • Soap12-Envelope.xsd
  • xml.xsd

So tried wsimport with -b option like below:

wsimport -keep -verbose -s src vendor.wsdl -b ../jaxb/jaxbbinding.xml -b ../jaxb/wsdlbinding.xml

I received this error :

[ERROR] "file:/C:/Projects/soapclient/.../ACORD_v2.2.0.xsd" is not a part of this compilation. Is this a mistake for "file:/C:/Projects/soapclient/..../ProcessSuretyBond_1_2.xsd"?
  line 13 of file:/C:/Projects/TestProjects/soapclient/..../jaxb/jaxbbinding.xml

Exception in thread "main" com.sun.tools.internal.ws.wscompile.AbortException
        at com.sun.tools.internal.ws.processor.modeler.wsdl.JAXBModelBuilder.bind(JAXBModelBuilder.java:129)
        at com.sun.tools.internal.ws.processor.modeler.wsdl.WSDLModeler.buildJAXBModel(WSDLModeler.java:2283)
        at com.sun.tools.internal.ws.processor.modeler.wsdl.WSDLModeler.internalBuildModel(WSDLModeler.java:183)
        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:498)
        at com.sun.tools.internal.ws.Invoker.invoke(Invoker.java:159)
        at com.sun.tools.internal.ws.WsImport.main(WsImport.java:42)

Not sure but should I request new binding files from the vendor ?

It works in SoapUI so shouldn't it work with wsimport ?

I tried all solution out there to resolve this issue including creating jaxb.properties file in jdk folder, adding jvm argument in maven's system settings etc. None worked.

I will appreciate if someone can point me in right direction and help resolve this issue. Many thanks in advance.

Alex K
  • 39
  • 1
  • 1
  • 8
  • 1
    That first message you got is only a warning, not an error. I don't know what wsimport does, but it should have still done it successfully if all it gave you was a warning. – Harun Dec 01 '17 at 00:14
  • 1
    perhaps you need to look at your directory structures with WSDL, XSD and other files. My guess is that references in `schemaLocation` in import elements in WSDL, XSD or some path in jaxbbinding.xml do not match your directory structure. – Vadim Dec 01 '17 at 00:20
  • @Harun Sorry I did not include the hole thing. There are few lines of errors too below the line I pasted in my question. But all are either -> "A class/interface with same name" -OR- -> "Two declarations cause a collision in the ObjectFactory class". What can I do to resolve this please? – Alex K Dec 01 '17 at 00:30
  • @Vadim - Thank you for your feedback. Let me check the wsdl location etc. like you suggested. Since I used SoapUI to generate the wsdl, I was hoping it to do it right. I guess not. – Alex K Dec 01 '17 at 00:31
  • I did not do such things with SoapUI for a long time. I remember I had some troubles with it, so I do all manually. But about other issues it could be worse. Usually it means there is a violation of namespaces purpose. There are two (or more) schema with the same namespace, same XML type (or element) name, but with different structure.(not rare situation). So that is bindings stand for to map namespace from each such schema to the different java package. I guess all is because of directory/path structure inconsistency and when all be clean errors go away. good luck... – Vadim Dec 01 '17 at 05:52
  • I'm trying to fix the xsd and wsdl and see if that works. – Alex K Dec 01 '17 at 17:46

1 Answers1

4

Try this:

wsimport ./vendor.wsdl -Xnocompile -d ./src -extension -keep -XadditionalHeaders -B-XautoNameResolution

You don’t need to use the binding files from your vendor. You will need the last 4 files you received from your vendor to make the above command work.

Nikhil Dèvrè
  • 383
  • 1
  • 6