2014-07-08 56 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

當試圖從命令行生成客戶端時,我遇到了完全相同的問題。切換我的代理設置後,錯誤消失了,我成功生成了客戶端文件。

  • 禁用代理設置。