2014-07-08 30 views
0

我正在处理webservices以与应用程序集成,并且作为newbee需要更多输入。为什么wsimport工具从wsdl文件生成文件不工作显示错误代码400

任何谁能告诉我这个问题,为什么wsimport的抛出错误控制台上:服务器返回的HTTP响应代码:400网址:

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文件>>。

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

回答

0

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

  • 禁用代理设置。