Fer*_*cal 2 xsd soap wsdl web-services
我有一个服务器(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>
仍然没有提示:(
wie*_*rob 10
您需要以"Document/literal wrapped"方式编写WSDL.这些WSDL的风格是有点混乱,但这里是一个很好的对比.
从本质上讲,你需要将你包装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>
并指定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>