3

編集私は以下の例から始めましたが、今は次のとおりです:

  • W3C仕様の例を試しました。別のエラーを修正した後 (バインディングが別のStockQuoteSoapBinding場所で呼び出されたStockQuoteBinding)、同じ問題が発生します。
  • モノジェネレーターwsdlを試して、それが原因かどうかを確認wsimportしました。同等のエラーが発生します。

したがって、SOAP についての誇大宣伝にもかかわらず、実際には機能していないように思えます。少なくとも、宣伝されているほどではありません。これらのジェネレーターを介して最も見つけやすい wsdl の例を誰も実行していないとは信じられません。

元の質問

次の wsdl で wsimport が失敗します。

<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions name="OrdersService"
  xmlns:xsd="http://www.w3.org/1999/XMLSchema"
  xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
  xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
  xmlns:os="http://example/schema/OrdersService"
  xmlns:tns="http://example/ns/OrdersService"
  targetNamespace="http://example/ns/OrdersService"
  >

  <wsdl:types>
    <xsd:schema
      targetNamespace="http://example/schema/OrdersService">

      <xsd:element name="o:GetOrders">
    <xsd:complexType>
      <xsd:sequence>
        <xsd:element name="criteria" type="string"/>
      </xsd:sequence>
    </xsd:complexType>
      </xsd:element>

      <xsd:element name="os:GetOrdersResponse">
    <xsd:complexType>
      <xsd:all>
        <xsd:element name="orders" type="string"/>
      </xsd:all>
    </xsd:complexType>
      </xsd:element>

    </xsd:schema>
  </wsdl:types>

  <wsdl:message name="GetOrdersRequest">
    <wsdl:part name="parameters" element="os:GetOrders"/>
  </wsdl:message>

  <wsdl:message name="GetOrdersResponse">
    <wsdl:part name="parameters" element="os:GetOrdersResponse"/>
  </wsdl:message>

  <wsdl:portType name="GetOrdersPortType">
    <wsdl:operation name="GetOrders">
      <wsdl:input message="tns:GetOrdersRequest"/>
      <wsdl:output message="tns:GetOrdersResponse"/>
    </wsdl:operation>
  </wsdl:portType>

  <wsdl:binding name="GetOrdersBinding" type="tns:GetOrdersPortType">
    <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
    <wsdl:operation name="GetOrders">
      <soap:operation soapAction=""/>
      <wsdl:input><soap:body use="literal"/></wsdl:input>
      <wsdl:output><soap:body use="literal"/></wsdl:output>
    </wsdl:operation>
  </wsdl:binding>

  <wsdl:service name="OrdersService">
    <wsdl:port name="GetOrdersPort" binding="tns:GetOrdersBinding">
      <soap:address location="http://localhost:8080/svc/OrdersService/GetOrders"/>
    </wsdl:port>
  </wsdl:service>

</wsdl:definitions>

と:

parsing WSDL...


[ERROR] Schema descriptor {http://example/schema/OrdersService}GetOrders in message part "parameters" is not defined and could not be bound to Java. Perhaps the schema descriptor {http://example/schema/OrdersService}GetOrders is not defined in the schema imported/included in the WSDL. You can either add such imports/includes or run wsimport and provide the schema location using -b switch.
  line 35 of file:test.wsdl
4

2 に答える 2

5

質問はかなり古いですが、これは実際の WSDL です。

<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions name="OrdersService"
  xmlns:xsd="http://www.w3.org/2001/XMLSchema"
  xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
  xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
  xmlns:os="http://example/schema/OrdersService"
  xmlns:tns="http://example/ns/OrdersService"
  targetNamespace="http://example/ns/OrdersService">

  <wsdl:types>
    <xsd:schema targetNamespace="http://example/schema/OrdersService">

      <xsd:element name="GetOrders">
        <xsd:complexType>
          <xsd:sequence>
            <xsd:element name="criteria" type="xsd:string" />
          </xsd:sequence>
        </xsd:complexType>
      </xsd:element>

      <xsd:element name="GetOrdersResponse">
        <xsd:complexType>
          <xsd:all>
            <xsd:element name="orders" type="xsd:string" />
          </xsd:all>
        </xsd:complexType>
      </xsd:element>

    </xsd:schema>
  </wsdl:types>

  <wsdl:message name="GetOrdersRequest">
    <wsdl:part name="parameters" element="os:GetOrders" />
  </wsdl:message>

  <wsdl:message name="GetOrdersResponse">
    <wsdl:part name="parameters" element="os:GetOrdersResponse" />
  </wsdl:message>

  <wsdl:portType name="GetOrdersPortType">
    <wsdl:operation name="GetOrders">
      <wsdl:input message="tns:GetOrdersRequest" />
      <wsdl:output message="tns:GetOrdersResponse" />
    </wsdl:operation>
  </wsdl:portType>

  <wsdl:binding name="GetOrdersBinding" type="tns:GetOrdersPortType">
    <soap:binding style="document"
       transport="http://schemas.xmlsoap.org/soap/http" />
    <wsdl:operation name="GetOrders">
      <soap:operation soapAction="" />
      <wsdl:input>
        <soap:body use="literal" />
      </wsdl:input>
      <wsdl:output>
        <soap:body use="literal" />
      </wsdl:output>
    </wsdl:operation>
  </wsdl:binding>

  <wsdl:service name="OrdersService">
    <wsdl:port name="GetOrdersPort" binding="tns:GetOrdersBinding">
      <soap:address
         location="http://localhost:8080/svc/OrdersService/GetOrders" />
    </wsdl:port>
  </wsdl:service>

</wsdl:definitions>

私が変更したこと:

  • の代わりに設定xmlns:xsdします(1999 年版はかなり古くなっています)。http://www.w3.org/2001/XMLSchemahttp://www.w3.org/1999/XMLSchema

  • スキーマ要素から識別される名前空間を削除 (GetOrdersの代わりにo:GetOrdersおよびのGetOrdersResponse代わりにos:GetOrdersResponse) (名前空間修飾子はname、要素または型定義の属性内では許可されません)

  • criteriaサブ要素とorders:xsd:stringの代わりに正しいタイプを使用しましたstring


WSDL は最初は難しいかもしれませんが、一度理解すれば、明確に定義されたインターフェースに勝るものはありません。選択肢があれば、ためらうことなくjson-REST-APIよりもwsdlを好むでしょう。でもそれは好みの問題だと思います(-_-;)

于 2012-01-03T04:14:57.347 に答える
0

私の記憶が正しければ、wsimport では、WSDL ファイルでそれらの要素を使用するために、外部の名前空間をインポートする必要があります。あなたの場合:

 <import namespace="http://example/schema/OrdersService"/>
于 2009-11-05T22:17:39.647 に答える