Search code examples
web-servicessoapwsdl

Why wsimport tool for generating files from wsdl file not working showing error code 400


I am working on webservices to integrate with the application and as a newbee needs more input.

Can any anyone tell me the issue why wsimport throws error on console : Server returned HTTP response code: 400 for URL:

http://localhost:8084/service/HelloWorld.wsdl

Following is my code below :

HelloWorld.java

//Service Endpoint Interface
@WebService
@SOAPBinding(style = Style.RPC)
public interface HelloWorld {

    @WebMethod String getHelloWorldAsString(String msg);

}

HelloWorldImpl.java

@WebService(endpointInterface = "com.pack.service.HelloWorld")
public class HelloWorldImpl implements HelloWorld{

    @Override
    public String getHelloWorldAsString(String msg) {
        return "Hello, "+msg+ "  How are you ?" ;
    }

}

HelloWorldPublisher.java

//Endpoint Publisher
public class HelloWorldPublisher {

    public static void main(String[] args){
        System.out.println("Webservice Running ... ");
        Endpoint.publish("http://localhost:8084/service/HelloWorld", new HelloWorldImpl());
    }

}

Now, when i want to generate stub files from wsdl file. It gives the following error :

Note : Using command prompt and entering the following on command line :

wsimport -keep http://localhost:8084/service/HelloWorld?wsdl
At command line it shows >>
D:\Personal\WebService>wsimport -keep http://localhost:8084/service/HelloWorld?wsdl
parsing WSDL...


[ERROR] Server returned HTTP response code: 400 for URL: http://localhost:8084/service/HelloWorld?wsdl

Failed to read the WSDL document: http://localhost:8084/service/HelloWorld?wsdl, because 1) could not find the document; /2) the document could not be read; 3) the root element of the document is not
<wsdl:definitions>.


[ERROR] failed.noservice=Could not find wsdl:service in the provided WSDL(s):

 At least one WSDL with at least one service definition needs to be provided.


        Failed to parse the WSDL.

D:\Personal\WebService>

wsdl file >>.

<?xml version="1.0" encoding="UTF-8"?>
<!-- Published by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is JAX-WS RI 2.2-hudson-740-. -->
<!-- Generated by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is JAX-WS RI 2.2-hudson-740-. -->
<definitions xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:wsp="http://www.w3.org/ns/ws-policy" xmlns:wsp1_2="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://service.pack.com/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.xmlsoap.org/wsdl/" targetNamespace="http://service.pack.com/" name="HelloWorldImplService">
<types/>
<message name="getHelloWorldAsString">
<part name="arg0" type="xsd:string"/>
</message>
<message name="getHelloWorldAsStringResponse">
<part name="return" type="xsd:string"/>
</message>
<portType name="HelloWorld">
<operation name="getHelloWorldAsString">
<input wsam:Action="http://service.pack.com/HelloWorld/getHelloWorldAsStringRequest" message="tns:getHelloWorldAsString"/>
<output wsam:Action="http://service.pack.com/HelloWorld/getHelloWorldAsStringResponse" message="tns:getHelloWorldAsStringResponse"/>
</operation>
</portType>
<binding name="HelloWorldImplPortBinding" type="tns:HelloWorld">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="rpc"/>
<operation name="getHelloWorldAsString">
<soap:operation soapAction=""/>
<input>
<soap:body use="literal" namespace="http://service.pack.com/"/>
</input>
<output>
<soap:body use="literal" namespace="http://service.pack.com/"/>
</output>
</operation>
</binding>
<service name="HelloWorldImplService">
<port name="HelloWorldImplPort" binding="tns:HelloWorldImplPortBinding">
<soap:address location="http://localhost:8084/service/HelloWorld"/>
</port>
</service>
</definitions>

Solution

  • I had the exact same issue when trying to generate the client side from the command line. After switching of my proxy settings, the error went away and I successfully generated the client files.

    • Disable Proxy Settings.