同じ操作名と要求パラメーター名を持つ WSDL ファイルがあります。WSDL ファイルを使用してクライアント スタブを生成すると、ポート クラスは void 戻り型のメソッドを生成します。さらに、リクエストパラメーターは、単一のオブジェクトからその単一のオブジェクトのコンテンツに変更されます。
WSDL ファイルの操作名を別の名前に変更すると機能します。ただし、WSDL ファイルを変更することは悪い習慣だと思います。さらに、実際の Web サービスにはアクセスできません。そのため、Web サービスの実際の操作名も変更できません。
wsimport
操作名とリクエストパラメータ名を混同しない方法はありますか? wsimport で属性を使用してみ-B-XautoNameResolution
ましたが、問題は解決しませんでした。
私の WSDL ファイルは次のようになります。
<xsd:schema targetNamespace="http://com.example">
<xsd:element name="transact">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="from" type="xsd:string"></xsd:element>
<xsd:element name="to" type="xsd:string"></xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<wsdl:message name="requestdata">
<wsdl:part element="tns:transact" name="parameters"/>
</wsdl:message>
<wsdl:message name="responsedata">
<wsdl:part element="tns:responsedata" name="parameters"/>
</wsdl:message>
<wsdl:portType name="portname">
<wsdl:operation name="transact">
<wsdl:input message="tns:requestdata"/>
<wsdl:output message="tns:responsedata"/>
</wsdl:operation>
</wsdl:portType>
結果のクラスは次のようになります (戻り値の型は void であり、入力型は で宣言されていRequestWrapper
ますが、transact メソッド内で宣言されたメソッドはオブジェクト自体ではありません)。
@WebMethod(action = "http://com.example/transact")
@RequestWrapper(localName = "transact", targetNamespace = "http://com.example", className = "com.example.Transact")
@ResponseWrapper(localName = "transactresponse", targetNamespace = "http://com.example", className = "com.example.TransactResponse")
public void transact(
@WebParam(name = "to", targetNamespace = "")
String to,
@WebParam(name = "from", targetNamespace = "")
String from);