java 没有参数的 WSDL 生成方法

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7406071/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-30 19:49:31  来源:igfitidea点击:

WSDL generate method with no parameters

javaweb-servicesjax-ws

提问by kardanov

I try to generate webservice using WSDL file. There is one method with no input parameter. I did it the following way:

我尝试使用 WSDL 文件生成网络服务。有一种方法没有输入参数。我是通过以下方式做到的:

...
<types>
<xsd:schema targetNamespace="http://api.registration.company.com"
    xmlns:base="http://base.api.registration.company.com">
    ...
    <xsd:element name="RemoveURLRequest">
        <xsd:complexType>
            <xsd:sequence />
        </xsd:complexType>
    </xsd:element>
    <xsd:element name="RemoveURLResponse" type="xsd:boolean" />
</xsd:schema>
</types>
...
<message name="RemoveURLRequest">
    <part name="RemoveURLRequest" element="tns:RemoveURLRequest" />
</message>
<message name="RemoveURLResponse">
    <part name="RemoveURLResponse" element="tns:RemoveURLResponse" />
</message>
...
<portType name="RegistrationService">
    ...
    <operation name="RemoveURL">
        <input message="tns:RemoveURLRequest" />
        <output message="tns:RemoveURLResponse" />
    </operation>
...
</portType>
<binding name="RegistrationServiceSOAP" type="tns:RegistrationService">
    <soap:binding style="document"
        transport="http://schemas.xmlsoap.org/soap/http" />
    ...
    <operation name="RemoveURL">
        <soap:operation soapAction=
            "http://api.registration.company.com/web/services/RegistrationService/RemoveURL"
                style="document" />
            <input>
                <soap:body parts="RemoveURLRequest" use="literal" />
            </input>
            <output>
                <soap:body parts="RemoveURLResponse" use="literal" />
            </output>
    </operation>
</binding>
<service name="RegistrationService">
    <port name="RegistrationServiceSOAP" binding="tns:RegistrationServiceSOAP">
        <soap:address location=
            "http://api.registration.company.com/web/services/RegistrationService" />
    </port>
</service>

According to this WSDL I expect method to be generated like this:

根据这个 WSDL,我希望生成这样的方法:

public boolean removeURL();

But I'm getting this:

但我得到了这个:

public boolean removeURL(RemoveURLRequest removeURLRequest);

Where RemoveURLRequest is an empty class:

其中 RemoveURLRequest 是一个空类:

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "")
@XmlRootElement(name = "RemoveURLRequest")
public class RemoveURLRequest {

}

What am I doing wrong?

我究竟做错了什么?

回答by Amila Suriarachchi

try some thing like this

尝试这样的事情

<message name="RemoveURLRequest">

<message name="RemoveURLRequest">

</message>

</消息>

without using the part element.

不使用零件元素。

回答by Zangdak

You must create an empty complex Type and use it as parameter. see the following post which is a similar question : WSDL Type for getter without parameter.

您必须创建一个空的复杂类型并将其用作参数。请参阅以下帖子,这是一个类似的问题:不带参数的 getter 的 WSDL 类型

回答by gastush

Jax-WS usually generate such code when the message/part/schema types ends with the keyword "Request". Give it a try without by removing the "Request" part of the name. This should give you the expected results

当消息/部分/模式类型以关键字“Request”结尾时,Jax-WS 通常会生成这样的代码。通过删除名称的“请求”部分来尝试一下。这应该会给你预期的结果