不带参数的 WSDL 生成方法

发布于 2024-12-04 04:22:13 字数 2419 浏览 2 评论 0原文

我尝试使用 WSDL 文件生成 Web 服务。有一种方法没有输入参数。我按照以下方式做到了:

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

根据此 WSDL,我希望生成如下所示的方法:

public boolean removeURL();

但我得到的是:

public boolean removeURL(RemoveURLRequest removeURLRequest);

其中RemoveURLRequest 是一个空类:

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

}

我做错了什么?

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

...
<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:

public boolean removeURL();

But I'm getting this:

public boolean removeURL(RemoveURLRequest removeURLRequest);

Where RemoveURLRequest is an empty class:

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

}

What am I doing wrong?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

烙印 2024-12-11 04:22:14

尝试这样的事情

不使用part元素。

try some thing like this

<message name="RemoveURLRequest">

</message>

without using the part element.

最美不过初阳 2024-12-11 04:22:14

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

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.

黒涩兲箜 2024-12-11 04:22:14

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

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文