Soap WSDL ComplexType 被发布为错误的参数类型 [英] Soap WSDL ComplexType being posted as wrong argument type

查看:29
本文介绍了Soap WSDL ComplexType 被发布为错误的参数类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个服务器 (SoapUI) 来响应 WSDL 的请求.

I have a server (SoapUI) answering requests for a WSDL.

发送测试请求时,我的服务器代码正在接收一个list参数,但我试图实现的是复杂类型的单个参数,例如:

When sending test requests, my server code is receiving a list of arguments, but I'm trying to achieve is a single argument, of complex type, eg:

{
 ingredient_id   => INT
 something       => STRING
 ...
}

我的类型如下:

  <wsdl:types>
    <xsd:schema targetNamespace="/ingredient">
      <xsd:element name="getIngredientInfo" type="tns:IngredientRequest"></xsd:element>
      <xsd:element name="getIngredientInfoResponse" type="tns:ingredient"></xsd:element>

      <xsd:complexType name="ingredient">
        <xsd:sequence>
            <xsd:element name="ingredient_id" type="xsd:int" minOccurs="1" maxOccurs="1"></xsd:element>
            <xsd:element name="ingredient_name" type="xsd:string" minOccurs="1" maxOccurs="1"></xsd:element>
            <xsd:element name="status_gm" type="xsd:boolean" minOccurs="1" maxOccurs="1"></xsd:element>
            <xsd:element name="status_vegan" type="xsd:boolean" minOccurs="1" maxOccurs="1"></xsd:element>
            <xsd:element name="status_vegetarian" type="xsd:boolean" minOccurs="1" maxOccurs="1"></xsd:element>
            <xsd:element name="author_id" type="xsd:int" block="#all" minOccurs="1" maxOccurs="1"></xsd:element>
        </xsd:sequence>
      </xsd:complexType>

      <xsd:complexType name="IngredientRequest">
        <xsd:sequence>
            <xsd:element name="ingredient_id" type="xsd:int"></xsd:element>
            <xsd:element name="something" type="xsd:string"></xsd:element>
        </xsd:sequence>
      </xsd:complexType>

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

有人可以帮助我理解为什么 WSDL 使 SoapUI 将参数作为简单参数列表而不是单个复杂参数发送吗?

Can somebody help me to understand why WSDL is making SoapUI send the arguments as a list of simple arguments, instead of a single complex argument?

序列标签可能有问题,但我找不到问题所在,只需要一些光线.提前致谢!

It might be some problem with sequence tag, but I can't find the issue in that, just need some light. Thanks in advance!

当然,我这里有:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<wsdl:definitions
  name="ingredient"
  targetNamespace="/ingredient"
  xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
  xmlns:tns="/ingredient"
  xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
  xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <wsdl:types>
    <xsd:schema targetNamespace="/ingredient">
      <xsd:element name="getIngredientInfo" type="tns:IngredientRequest"></xsd:element>
      <xsd:element name="getIngredientInfoResponse" type="tns:ingredient"></xsd:element>

      <xsd:complexType name="ingredient">
        <xsd:sequence>
            <xsd:element name="ingredient_id" type="xsd:int" minOccurs="1" maxOccurs="1"></xsd:element>
            <xsd:element name="ingredient_name" type="xsd:string" minOccurs="1" maxOccurs="1"></xsd:element>

            <xsd:element name="status_gm" type="xsd:boolean" minOccurs="1" maxOccurs="1"></xsd:element>
            <xsd:element name="status_vegan" type="xsd:boolean" minOccurs="1" maxOccurs="1"></xsd:element>
            <xsd:element name="status_vegetarian" type="xsd:boolean" minOccurs="1" maxOccurs="1"></xsd:element>
            <xsd:element name="author_id" type="xsd:int" block="#all" minOccurs="1" maxOccurs="1"></xsd:element>
        </xsd:sequence>
      </xsd:complexType>


      <xsd:complexType name="IngredientRequest">
        <xsd:sequence>
            <xsd:element name="ingredient_id" type="xsd:int"></xsd:element>

            <xsd:element name="something" type="xsd:string"></xsd:element>
        </xsd:sequence>
      </xsd:complexType>
    </xsd:schema>
  </wsdl:types>
  <wsdl:message name="getIngredientInfoRequest">
    <wsdl:part element="tns:getIngredientInfo" name="parameters"/>
  </wsdl:message>
  <wsdl:message name="getIngredientInfoResponse">

    <wsdl:part element="tns:getIngredientInfoResponse"
        name="parameters" />
  </wsdl:message>
  <wsdl:portType name="ingredient">
    <wsdl:operation name="getIngredientInfo">
      <wsdl:input message="tns:getIngredientInfoRequest"/>
      <wsdl:output message="tns:getIngredientInfoResponse"/>
    </wsdl:operation>
  </wsdl:portType>
  <wsdl:binding name="ingredientSOAP" type="tns:ingredient">

    <soap:binding style="document"
        transport="http://schemas.xmlsoap.org/soap/http" />
    <wsdl:operation name="getIngredientInfo">
        <soap:operation
            soapAction="http://entropy.homelinux.org/kasak/" />
        <wsdl:input>
            <soap:body use="literal" />
        </wsdl:input>
        <wsdl:output>
            <soap:body use="literal" />
        </wsdl:output>

    </wsdl:operation>
  </wsdl:binding>
  <wsdl:service name="ingredient">
    <wsdl:port binding="tns:ingredientSOAP" name="ingredientSOAP">
      <soap:address location="http://entropy.homelinux.org/kasak/"/>
    </wsdl:port>
  </wsdl:service>
</wsdl:definitions>

仍然没有任何提示:(

推荐答案

您需要以文档/文字包装"样式编写您的 WSDL.这些 WSDL 样式有点令人困惑,但 这里 是一个很好的选择对比.

You need to write your WSDL in "Document/literal wrapped"-style. These WSDL-styles are a bit confusing but here is a good comparison.

本质上,您需要将 complexType 包装到 element 中:

In essence you will need to wrap your complexType into an element:

<element name="IngredientInfo">
  <complexType>
    <sequence>
            <element name="ingredient_id" type="xsd:int"></xsd:element>
            <element name="something" type="xsd:string"></xsd:element>
    </sequence>
  </complexType>
</element>

并指定此元素作为消息发送

<message name="getIngredientInfoRequest">
    <part name="parameters" element="IngredientInfo"/>
</message>

因此,生成的 SOAP 消息包含 IngredientInfo-element 作为 SOAP 正文的唯一子项:

Thus the resulting SOAP message contains this the IngredientInfo-element as the only child of the SOAP body:

<soap:envelope>
    <soap:body>
        <IngredientInfo>
            <ingredient_id>42</ingredient_id>
            <something>"What is..."</something>
        </IngredientInfo>
    </soap:body>
</soap:envelope>

这篇关于Soap WSDL ComplexType 被发布为错误的参数类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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