Soap WSDL ComplexType published as wrong argument type

I have a server (SoapUI) responding to WSDL requests.

When sending test requests, my server code gets a list of arguments, but I am trying to achieve a single complex type argument like:

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

      

My types are as follows:

  <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 someone help me understand why WSDL makes SoapUI send arguments as a list of simple arguments rather than a single complex argument?

EDIT: It might be a problem with the sequence tag, but I can't seem to find the problem in this, just needs a little light. Thanks in advance!


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

      

No clues yet :(

+2


source to share


4 answers


You need to write a "Document / literal wrapped" style WSDL. These WSDL types are a little confusing, but here 's a good comparison.

In essence, you need to wrap yours complexType

in 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 send as a message



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

      

So the received SOAP message contains this 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>

      

+10


source


I don't think this is a WSDL Type (IngredientRequest) issue, you can show the complete WSDL, especially the operation you are testing, if it takes an array of type IngredientRequest, then this is the answer why SOAP UI is sending argument list.



+1


source


Ok after using WSDL to generate sample request using my SOAP interface here is what I see

    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ing="/ingredient">
   <soapenv:Header/>
   <soapenv:Body>
      <ing:getIngredientInfo>
         <ingredient_id>?</ingredient_id>
         <something>?</something>
      </ing:getIngredientInfo>
   </soapenv:Body>
</soapenv:Envelope>

      

So as you can see, the creation of a single getIngredientInfo request object does not contain arrays. Please confirm, try using the latest SOAP interface if necessary!

0


source


I understand that you currently have something like the following (I am making a web service call in Java, so I will give an example):

SOAPCaller.getIngredientInformation(3, "something");

      

However, you would like the following:

IngredientRequest ingredientRequest = new IngredientRequest(3, "something");
SOAPCaller.getIngredientInformation(ingredientRequest);

      

Trying something like what Vierob suggested, the first case was what was created for me. Unfortunately, the only way I have found to achieve the second is to do some extra encapsulation, which is messy (additional classes are generated). However, it allows you to send one object and return one object, not a number of objects. Here's an example:

<!-- assume the including of your complex types from above -->
<xsd:element name="getIngredientInfo" >
  <xsd:complexType>
    <xsd:sequence>
      <xsd:element name="ingredient" type="tns:IngredientRequest" />
    </xsd:sequence>
  </xsd:complexType>
</xsd:element>

<xsd:element name="getIngredientInfoResponse" >
  <xsd:complexType>
    <xsd:sequence>
      <xsd:element name="ingredientResponse" type="tns:ingredient" />
    </xsd:sequence>
  </xsd:complexType>
</xsd:element>

      

0


source







All Articles