为什么wsimport工具用于生成wsdl文件中的文件无效,显示错误代码400

时间:2014-07-08 12:15:51

标签: web-services soap wsdl

我正在研究webservices以与应用程序集成,并且作为newbee需要更多的输入。

任何人都可以告诉我为什么wsimport在控制台上抛出错误的问题:服务器返回HTTP响应代码:400为URL:

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

以下是我的代码:

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());
    }

}

现在,当我想从wsdl文件生成存根文件时。它给出了以下错误:

注意:使用命令提示符并在命令行中输入以下内容:

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文件&gt;&gt;。

<?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>

1 个答案:

答案 0 :(得分:0)

尝试从命令行生成客户端时,我遇到了完全相同的问题。切换我的代理设置后,错误就消失了,我成功生成了客户端文件。

  • 禁用代理设置。