1

I am using Spring Tool Suite 4 with JAVA on the JDK 1.8.0.181. I have the wsdl linking of the Web Service Server and i want to create the coresponding Web Service Client on my project. I have configured the CXF preferences as follows:

CXF Preferences

My steps to create the Customer Web Service:

  1. On my maven project, right click on "New" -> "Other" -> "Web Service Client",
  2. I choose the Tomcat server (previously configured in 8.5),
  3. I choose the configuration environment (previously configured on CXF),
  4. I copy the WSDL link in the corresponding field.

After copying the link, and after a few seconds of waiting, STS returns the following error:

Could not retrieve the WSDL file "...wsdladresse.wsdl". Do you want to continueto wait for this file ?

I clicked on continue and was able to add an empty xml file (for the moment) of binding. Once the wsdl recovery process is finished, STS returns the error below:

WSDLToJava Error: Schema Error : cos-st-restricts.1.1 : Le type 'anySimpleType' étant non décomposable, sa valeur {base type definition}, 'anyType', doit être une définition de type simple atomique ou un type de données primitif intégré.

After some research on the Internet, I understood that I had to create my class proposals (here for the "anySimpleType" type) and add them to my binding xml file. How do I know the correct structure of my class to make sure that STS takes it into account when importing the WSDL?

Thank you

Chamila Maddumage
  • 3,304
  • 2
  • 32
  • 43
m.allain
  • 11
  • 3

2 Answers2

0

Please can you add apache CXF in your STS and after that in STS it is very easy to generate Web Service Client classes,You can achieve this by following steps .

Right Click on any Project->Create New Other ->Web Services->Web Service Client->Then paste the wsdl url(or location) in Service Definition->Next->Finish

You will see the generated classes are inside your src folder.

NOTE :Without eclipse also you can generate client classes from wsdl file by using wsimport command utility which ships with JDK.

refer this link 'https://help.eclipse.org/oxygen/index.jsp?topic=%2Forg.eclipse.jst.ws.cxf.doc.user%2Ftasks%2Fcreate_client.html' and 'https://help.eclipse.org/neon/index.jsp?topic=%2Forg.eclipse.wst.wsdl.ui.doc.user%2Ftasks%2Ftimpwsdl.html'

Bheem Singh
  • 607
  • 7
  • 13
  • Thanks for the help but I have already done all the steps and I get the errors previously mentioned in my help request. I also already tried the "wsimport" service and the result and the same. re there any options to check or uncheck in the step below? https://www.zupimages.net/up/19/12/5xqn.png – m.allain Mar 22 '19 at 09:39
  • can you please check you wsdl url working or not, you can check using browser or any client its working fine so next step is check your server url is correct or not in wsdl file. – Bheem Singh Mar 22 '19 at 09:47
  • you can use cmd also for that link is 'http://www.thejavageek.com/2015/01/28/using-wsimport-command-generate-web-service-client/' – Bheem Singh Mar 22 '19 at 09:49
  • The WSDL is correct since I can access it via the browser.https://www.zupimages.net/up/19/12/ubz7.png – m.allain Mar 22 '19 at 09:50
  • one more time can you use dynamic web project don't use maven project. – Bheem Singh Mar 22 '19 at 09:52
  • "you can use cmd also for that link is 'thejavageek.com/2015/01/28/…' " I get this error : [ERROR] undefined element declaration 's:schema' Exception in thread "main" com.sun.tools.internal.ws.wscompile.AbortException – m.allain Mar 22 '19 at 09:53
  • "one more time can you use dynamic web project don't use maven project" I get the same mistakes. – m.allain Mar 22 '19 at 09:57
0

I tried a new solution, using NetBeans. After several problems with the xsd:schema, I had to add two xml files of settings:

  1. "XMLSchema.xsd"
  2. "custom.xml" which contains the following elements :

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

  <globalBindings>
    <xjc:simple />
  </globalBindings>

  <bindings scd="~xsd:complexType">
    <class name="ComplexTypeType"/>
  </bindings>

  <bindings scd="~xsd:simpleType">
    <class name="SimpleTypeType"/>
  </bindings>

  <bindings scd="~xsd:group">
    <class name="GroupType"/>
  </bindings>

  <bindings scd="~xsd:attributeGroup">
    <class name="AttributeGroupType"/>
  </bindings>

  <bindings scd="~xsd:element">
    <class name="ElementType"/>
  </bindings>

  <bindings scd="~xsd:attribute">
    <class name="attributeType"/>
  </bindings>
</bindings>

As well as the two dtd datatypes.dtd and XMLSchema.dtd. In the first generation, the wsdl catalogue was published. . I then used it in the JAXB options. I tried one last time, the recovery of the WSDL in JAVA classes and I get the error below:

Created dir: C:\Users\DEV-04\Documents\NetBeansProjects\JavaApplication1\build\generated-sources\jaxb
Created dir: C:\Users\DEV-04\Documents\NetBeansProjects\JavaApplication1\build\generated\jaxbCache
Created dir: C:\Users\DEV-04\Documents\NetBeansProjects\JavaApplication1\build\generated\jaxbCache\PMS
Compiling file:/C:/Users/DEV-04/Documents/NetBeansProjects/JavaApplication1/xml-resources/jaxb/PMS/aspx/shprocess/v3/pmslinking.asmx.wsdl
C:\Users\DEV-04\Documents\NetBeansProjects\JavaApplication1\nbproject\xml_binding_build.xml:15: 
java.lang.IllegalArgumentException: can't parse argument number: ''http://java.sun.com/xml/ns/jaxb''
 at java.text.MessageFormat.makeFormat(MessageFormat.java:1429)
 at java.text.MessageFormat.applyPattern(MessageFormat.java:479)
 at java.text.MessageFormat.<init>(MessageFormat.java:362)
 at java.text.MessageFormat.format(MessageFormat.java:840)
 at com.sun.tools.xjc.Messages.format(Messages.java:54)
 at com.sun.tools.xjc.ModelLoader.buildDOMForest(ModelLoader.java:338)
 at com.sun.tools.xjc.ModelLoader.loadWSDL(ModelLoader.java:392)
 at com.sun.tools.xjc.ModelLoader.load(ModelLoader.java:171)
 at com.sun.tools.xjc.ModelLoader.load(ModelLoader.java:120)
 at com.sun.tools.xjc.XJC2Task._doXJC(XJC2Task.java:511)
 at com.sun.tools.xjc.XJC2Task.doXJC(XJC2Task.java:454)
 at com.sun.tools.xjc.XJC2Task.execute(XJC2Task.java:379)
 at com.sun.istack.tools.ProtectedTask.execute(ProtectedTask.java:103)
 at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
 at sun.reflect.GeneratedMethodAccessor102.invoke(Unknown Source)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
 at java.lang.reflect.Method.invoke(Method.java:498)
 at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
 at org.apache.tools.ant.Task.perform(Task.java:348)
 at org.apache.tools.ant.Target.execute(Target.java:435)
 at org.apache.tools.ant.Target.performTasks(Target.java:456)
 at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1393)
 at org.apache.tools.ant.Project.executeTarget(Project.java:1364)
 at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
 at org.apache.tools.ant.Project.executeTargets(Project.java:1248)
 at org.apache.tools.ant.module.bridge.impl.BridgeImpl.run(BridgeImpl.java:286)
 at org.apache.tools.ant.module.run.TargetExecutor.run(TargetExecutor.java:555)
 at org.netbeans.core.execution.RunClassThread.run(RunClassThread.java:153)
Caused by: java.lang.NumberFormatException: For input string: "''http://java.sun.com/xml/ns/jaxb''"
 at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
 at java.lang.Integer.parseInt(Integer.java:569)
 at java.lang.Integer.parseInt(Integer.java:615)
 at java.text.MessageFormat.makeFormat(MessageFormat.java:1427)
 ... 27 more
BUILD FAILED (total time: 15 seconds)
m.allain
  • 11
  • 3