WSDL或wsimport和wsdl(单声道)都被严重破坏了 [英] Either WSDL or wsimport and wsdl (mono) are horribly broken

查看:64
本文介绍了WSDL或wsimport和wsdl(单声道)都被严重破坏了的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

编辑,我从下面给出的示例开始,但现在有了:

EDIT I started off with the example given below, but I have now:

  • 尝试了W3C规范中的示例.修复了另一个错误(绑定在一个位置称为StockQuoteSoapBinding,在另一个位置称为StockQuoteBinding)之后,它也出现了同样的问题.
  • 尝试了单声道生成器wsdl以查看是否应责怪wsimport.它给出了一个等效的错误.
  • Tried the example from the W3C spec. After fixing another error (binding was called StockQuoteSoapBinding in one place, StockQuoteBinding in another), it gives the same issue.
  • Tried the mono generator wsdl to see if wsimport was to blame. It gives an equivalent error.

因此,在我看来,尽管对SOAP进行了大肆宣传,但它实际上并不起作用-至少不如所宣传的那样.我不敢相信没有人通过这些生成器运行过wsdl的最常见示例.

So it seems to me that despite all the hype about SOAP, it doesn't actually work - at least not as advertised. I can't believe nobody has run the most findable examples of wsdl through these generators.

原始问题

wsimport在以下wsdl上失败:

wsimport is failing on the following wsdl:

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

推荐答案

尽管这个问题已经很老了,但这是一个有效的WSDL:

Although the question is rather old, here's a working 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设置为http://www.w3.org/2001/XMLSchema而不是http://www.w3.org/1999/XMLSchema(1999年的版本已经过时了)

  • set xmlns:xsd to http://www.w3.org/2001/XMLSchema instead of http://www.w3.org/1999/XMLSchema (the 1999 version is quite outdated)

从架构元素(GetOrders代替o:GetOrdersGetOrdersResponse代替os:GetOrdersResponse)标识的命名空间中删除(元素或类型定义的name属性内不允许使用命名空间限定符)

removed namespace identified from the schema elements (GetOrders instead of o:GetOrders and GetOrdersResponse instead of os:GetOrdersResponse) (namespace qualifiers are not allowed within the name attribute of an element or type definition)

为子元素criteriaorders使用了正确的类型:xsd:string而不是string

used the correct types for the subelements criteria and orders: xsd:string instead of string

我同意,WSDL在一开始可能会很困难,但是,一旦掌握了它,没有什么比明确定义的接口更好的了.如果可以选择的话,我会毫不犹豫地选择wsdl而不是json-REST-API.但我想这是一个品味问题;-)

I agree, that a WSDL might be difficult in the beginning, however, once you have a grip on it, there's nothing better than a clearly defined interface. If I had a choice, I would prefer a wsdl over a json-REST-API without hesitation. But I guess that's a matter of taste ;-)

这篇关于WSDL或wsimport和wsdl(单声道)都被严重破坏了的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆