27

I have tested my web services (wsdl/soap) with soapui. and i have the errors : http/log : error 400 BAD REQUEST.

What can be the error please with my wsdl ?

error/log :

un Jun 05 14:10:37 CEST 2011:ERROR:javax.wsdl.WSDLException: WSDLException (at /html): faultCode=INVALID_WSDL: Expected element '{http://schemas.xmlsoap.org/wsdl/}definitions'.
   javax.wsdl.WSDLException: WSDLException (at /html): 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 com.ibm.wsdl.xml.WSDLReaderImpl.readWSDL(Unknown Source)
    at com.ibm.wsdl.xml.WSDLReaderImpl.readWSDL(Unknown Source)
    at com.ibm.wsdl.xml.WSDLReaderImpl.readWSDL(Unknown Source)
    at com.eviware.soapui.impl.wsdl.support.wsdl.WsdlInterfaceDefinition.load(WsdlInterfaceDefinition.java:48)
    at com.eviware.soapui.impl.wsdl.support.wsdl.WsdlContext.loadDefinition(WsdlContext.java:66)
    at com.eviware.soapui.impl.wsdl.support.wsdl.WsdlContext.loadDefinition(WsdlContext.java:30)
    at com.eviware.soapui.impl.support.definition.support.AbstractDefinitionContext.cacheDefinition(AbstractDefinitionContext.java:264)
    at com.eviware.soapui.impl.support.definition.support.AbstractDefinitionContext.access$400(AbstractDefinitionContext.java:44)
    at com.eviware.soapui.impl.support.definition.support.AbstractDefinitionContext$Loader.construct(AbstractDefinitionContext.java:230)
    at com.eviware.soapui.support.swing.SwingWorkerDelegator.construct(SwingWorkerDelegator.java:46)
    at com.eviware.soapui.support.swing.SwingWorker$2.run(SwingWorker.java:140)
    at java.lang.Thread.run(Thread.java:637)
samir
  • 4,501
  • 6
  • 49
  • 76

9 Answers9

39

definitions is a root element of WSDL so it looks like you are not loading WSDL.

Edit:

I tested it and it looks like the whole problem is with your web server. Your web server returns WSDL to browser but it doesn't return it to any tool because these tools are using very minimalistic HTTP requests without many HTTP headers. One of missing headers is Accept. Once this header is not included in the request your server throws HTTP 400 Bad request.

The easy approach to continue is opening WSDL in the browser, save the wsdl to a file and import that file to soapUI instead of the WSDL from URL.

Ladislav Mrnka
  • 360,892
  • 59
  • 660
  • 670
  • 1
    Please can you help me ?? it's 5 days i tray to fix the problem. I have not understand your answer, i am sorry. How i can test my wsdl ?? is the log error says that my web services is not working ?? thanks for your answer – samir Jun 05 '11 at 13:25
  • Are you able to add WSDL to soapUI project? http://www.soapui.org/Getting-Started/your-first-soapui-project.html – Ladislav Mrnka Jun 05 '11 at 13:29
  • No, when i add it, it show tho me the " Loading definition from url", it take this for several minutes and it show me " com.ev...: Error importing wsdl . is this mean that my wsdl is not working ? – samir Jun 05 '11 at 13:35
  • Yes that means that WSDL cannot be downloaded or it is not correct. Can you open WSDL in browser? – Ladislav Mrnka Jun 05 '11 at 13:37
  • Yes i can open it in broswer, in Internet explorer it's correct – samir Jun 05 '11 at 13:38
  • It is probably not correct if soapUI cannot load it. Does it reference any external files? – Ladislav Mrnka Jun 05 '11 at 13:44
  • No it does not reference any external files. but when i open it in mozilla there is a message like this : Any style information associated with t... XML – samir Jun 05 '11 at 13:49
  • If you can help me, i can forward you my wsdl by mail. it is verry important to me to fix this today. thanks – samir Jun 05 '11 at 13:54
  • I have add it an remove it. do you have the url ?? – samir Jun 05 '11 at 14:05
  • Thanks for your answer. I would like to know how do you test it and what are the tools do you have used ? – samir Jun 05 '11 at 17:27
  • 2
    I used IE/Firefox to see WSDL and I used Visual studio / svcutil (MS tools for creating service proxies) to simulate soapUI behavior (I don't have soapUI installed at home). I used Fiddler to compare communication over HTTP with your server and to test different HTTP requests until I found the difference causing the problem. – Ladislav Mrnka Jun 05 '11 at 17:52
  • Thanks for all your answers. One last question please, you have said that the server returns the wsdl to the browser. is his sufficient to use the web services, i mean that my web services is good ? or should i use an other web server ?? thanks a lot – samir Jun 05 '11 at 17:58
  • The WSDL is description of your service - you can publish it or not (it depends if you want to expose the service to other clients). In such case you will need to reconfigure server somehow to allow receiving WSDL without all these problems. You are using Apacha - it should be a good choice for hosting PHP code. – Ladislav Mrnka Jun 05 '11 at 18:03
  • @LadislavMrnka: i am working on soap compression(Gzip, axis 1.3) and went through [this](http://www.tgerm.com/2010/11/http-compression-with-apache-axis-huge.html) article. I have configured http transport entry to CommonsHTTPSender in java code. Which compresses the request but Accept field is missing in the header. And i get [400(Bad Request)](http://paste.ubuntu.com/8289286/). Any way out? – itsme Sep 10 '14 at 11:52
9

Another possibility is that you need to add ?wsdl at the end of your service url for SoapUI. That one got me as I'm used to WCFClient which didn't need it.

Mike
  • 857
  • 1
  • 16
  • 29
6

You can try opening the wsdl in web browser and saving with .wsdl extension. And set the WSDL in SOAP UI project to this .wsdl file. This really works.

Juno123
  • 61
  • 1
  • 1
5
  • yes, first ensure you added "?wsdl" to your "http......whatever.svc" link.
    • That didn't fix my problem, though. I had to create a new WCF project from the beginning and manually copy the code. That fixed it. Good luck.

And most important!!!

When you change a namespace in your code, also make sure you change it in web.config!

Cătălin Rădoi
  • 1,804
  • 23
  • 43
2

I faced the same exception while trying to test my web-services deployed to WSO2 ESB.

WSO2 generated both wsdl and wsdl2. I tried to pass a wsdl2 URL and got the above exception. Quick googling showed me, that one of differences between wsdl1.1 and wsdl2.0 is replacing 'definitions' element with 'description'. Also, I found out, that SoapUI does not support wsdl2.

Therefore, for me the solution was to use wsdl1 url instead of wsdl2.

arghtype
  • 4,376
  • 11
  • 45
  • 60
0

For anyone hitting this issue in the future: the specific situation here ("the server isn't sending back the WSDL properly") may or may not always be relevant, but two key aspects should always be:

  1. The message faultCode=INVALID_WSDL: Expected element '{http://schemas.xmlsoap.org/wsdl/}definitions' means that the actual content returned is not XML with a base element of "definitions" in the WSDL namespace.
  2. The message WSDLException (at /html) tells you an important clue about what it did find — for this example, /html strongly implies that a normal webpage was returned, rather than a WSDL. Another common situation is seeing something like /soapenv:Reason, which would indicate that the server was trying to treat it as a SOAP call — for example, this can happen if your URL is for the "base" service URL rather than the WSDL.
Joel Aelwyn
  • 347
  • 5
  • 9
0

A likely possibility is that your browser reaches your web service through a proxy, and SoapUI is not configured to use that proxy. For example, I work in a corporate environment and while my IE and FireFox can access external websites, my SoapUI can only access internal web services.

The easy solution is to just open the WSDL in a browser, save it to a .xml file, and base your SoapUI project on that. This won't work if your WSDL relies on external XSDs that it can't get to, however.

Chris Thornton
  • 15,620
  • 5
  • 37
  • 62
0

I had the same problem, and the solution (for me) was to:

  • open SoapUI Preferences
  • click on SSL Settings
  • clear out the KeyStore and KeyStore Password text boxes
  • untick the bottom checkbox for Client Authentication, requires client authentication.
James K
  • 909
  • 10
  • 26
0

On AspNet services with .svc endding you must terminate URL as "?wsdl". Otherwise, SoapUI will try to read the land page HTML of the Service (that is not a WSDL, right?)

Eg.: http://localhost:1234/WebServices/WsBlahBlahBlah.svc?wsdl