1

同じ操作名と要求パラメーター名を持つ 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);
4

1 に答える 1

0

このアプリケーションは正常に動作しています。あなたがやったことは、パラメーター処理のラッパー スタイルです。その他のスタイルは裸のスタイルです (Single Part 引数は 1 つの Java オブジェクトになります)

入力メッセージの単一パートの要素名が操作名と同じ場合、Java への SOAP リクエストのアンマーシャリングで、カプセル化された 1 つの Java オブジェクトではなく、複数のパラメータが生成されます。これは、パラメーター処理の「ラッパー スタイル」として知られています。

<wsdl:part element="tns:transact" name="parameters"/>
<wsdl:operation name="transact">

シングルパート (XSD の複合タイプ) を使用しているため、WSDL バインディング タイプは「ドキュメント スタイル」のままです。

参照 URL:
https://myarch.com/wrappernon-wrapper-web-service-styles-things-you-need-to-know/ http://www.ibm.com/developerworks/library/ws-usagewsdl/

解決策は、次の 2 つの XML エントリを変更することです

<xsd:element name="transactNew">
<wsdl:part element="tns:transactNew" name="parameters"/>

transacttransactNewに変更すると、OperationName(transact) とは異なるものになり、操作名と単一引数名が異なるため、問題が解決します。

于 2015-07-20T12:10:08.503 に答える