gpt4 book ai didi

web-services - Soap WSDL ComplexType 被发布为错误的参数类型

转载 作者:行者123 更新时间:2023-12-04 02:48:58 25 4
gpt4 key购买 nike

我有一个服务器 (SoapUI) 响应 WSDL 请求。

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

{
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 将参数作为简单参数列表而不是单个复杂参数发送吗?

编辑:可能是序列标签有问题,但我找不到问题所在,只需要一些光照。提前致谢!


当然,我这里有:

<?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 样式有点令人困惑,但是 here是一个很好的比较。

本质上,您需要将 complexType 包装到 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 主体的唯一子元素:

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

关于web-services - Soap WSDL ComplexType 被发布为错误的参数类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1377102/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com