简体   繁体   English

为什么从wsdl文件生成文件的wsimport工具无法正常工作,显示错误代码400

[英]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. 我正在研究Web服务以与应用程序集成,而newbee需要更多输入。

Can any anyone tell me the issue why wsimport throws error on console : Server returned HTTP response code: 400 for URL: 任何人都可以告诉我为什么wsimport在控制台上引发错误的问题:服务器返回的HTTP响应代码:URL的400:

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

Following is my code below : 以下是我的代码如下:

HelloWorld.java HelloWorld.java

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

    @WebMethod String getHelloWorldAsString(String msg);

}

HelloWorldImpl.java 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 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. 现在,当我想从wsdl文件生成存根文件时。 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 >>. 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>

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. 禁用代理设置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM