Soap WSDL ComplexType being posted as wrong argument type

21,954

Solution 1

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

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>

and specify this element to be send as message

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

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>

Solution 2

I don't think WSDL Type (IngredientRequest) is the issue, can you show the complete WSDL, especially the operation which you are testing if that's accepting a array of IngredientRequest type then that is the answer, why SOAP UI is sending a list of arguments.

Share:
21,954

Related videos on Youtube

Fernando Barrocal
Author by

Fernando Barrocal

Updated on July 05, 2022

Comments

  • Fernando Barrocal
    Fernando Barrocal almost 2 years

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

    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
     ...
    }
    

    My types are as follow:

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

    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?

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


    Sure, I have it right here:

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

    Still have no hints on it :(

  • Fernando Barrocal
    Fernando Barrocal over 14 years
    Sure Thing! Will follow the full comment in next answer
  • Nicolas Miari
    Nicolas Miari about 8 years
    Why is is ingredient_id in the WSDL and ingredient in the SOAP request?