2

I am trying to run a service in a server. But when I run it, it throws the exception below:

javax.wsdl.WSDLException: WSDLException (at /soapenv:Envelope): faultCode=INVALID_WSDL: Expected element '{http://schemas.xmlsoap.org/wsdl/}definitions'.
        at com.ibm.wsdl.xml.WSDLReaderImpl.checkElementName(Unknown Source)
        at com.ibm.wsdl.xml.WSDLReaderImpl.parseDefinitions(Unknown Source)
        at com.ibm.wsdl.xml.WSDLReaderImpl.readWSDL(Unknown Source)
        at com.ibm.wsdl.xml.WSDLReaderImpl.readWSDL(Unknown Source)
        at org.apache.cxf.wsdl11.WSDLManagerImpl.loadDefinition(WSDLManagerImpl.java:229)
        at org.apache.cxf.wsdl11.WSDLManagerImpl.getDefinition(WSDLManagerImpl.java:179)
        at org.apache.cxf.wsdl11.WSDLServiceFactory.<init>(WSDLServiceFactory.java:91)

Where do I need to put our WSDL file in our project? I have generated the WSDL to Java client code and imported it to my project. In a separate folder, I imported my all WSDL files.

LHM
  • 721
  • 12
  • 31
BKK
  • 1,199
  • 6
  • 16
  • 24

3 Answers3

3

It looks like your WSDL is not valid. As Andrzej Doyle said, your WSDL might be missing the element or if your WSDL has that element then it contains wrong information. It should look like...

<definitions name="HelloService"
targetNamespace="http://www.examples.com/wsdl/HelloService.wsdl" 
xmlns="http://schemas.xmlsoap.org/wsdl/" 
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" 
xmlns:tns="http://www.examples.com/wsdl/HelloService.wsdl" 
xmlns:xsd="http://www.w3.org/2001/XMLSchema"> 
</definitions>
  • does your targetnamespace tag contain the correct location of wsdl??

You can get more information from how-can-i-make-this-a-valid-wsdl and wsdl-soap-test-with-soapui

Note: In any case, you have to correct your wsdl. So, please make sure that you have changed your wsdl in both places (In actual wsdl and in your separate folder)

LHM
  • 721
  • 12
  • 31
Manan Shah
  • 1,042
  • 2
  • 14
  • 26
3

In my case the problem was that I was trying to access the WS in the client using a URL like http://foo.bar/ws/WSName and I needed to use one like http://foo.bar/ws/WSName?WSDL (notice the &WSDL part).

Hope this helps someone.

Alfergon
  • 5,463
  • 6
  • 36
  • 56
1

As the exception states, your WSDL is invalid.

I would hazard a guess that you haven't included a <definitions> element where one was expected/required. But in any case, you need to fix up the WSDL with which you're defining the service.

Andrzej Doyle
  • 102,507
  • 33
  • 189
  • 228