我尝试使用WSDL文件生成webservice。有一种方法没有输入参数。我是通过以下方式做到的:
...
<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 {
}
我做错了什么?
答案 0 :(得分:1)
尝试这样的事情
&lt; message name =“RemoveURLRequest”&gt;
&LT; /消息&GT;
不使用part元素。
答案 1 :(得分:1)
您必须创建一个空的复杂类型并将其用作参数。请参阅以下帖子,这是一个类似的问题:WSDL Type for getter without parameter。
答案 2 :(得分:0)
当消息/部分/模式类型以关键字“请求”结束时,Jax-WS通常会生成此类代码。试一试,不要删除名称的“请求”部分。这应该给你预期的结果