ComplexType HOWTO-defined WSDL list, return from service?

How do you define a list of complex type objects in WSDL?

I have a pretty simple WSDL with 2 complex types

<xsd:complexType name="itemProperty">
    <xsd:all>
        <xsd:element name="name" type="xsd:string" />
                <xsd:element name="value" type="xsd:string" />
                <xsd:element name="type" type="xsd:string" />
    </xsd:all>
</xsd:complexType>

Then I try to create a list of this complexType, like this:

<xsd:complexType name="itemPropertyList">
    <xsd:complexContent>
        <xsd:restriction base="SOAP-ENC:Array">
            <xsd:sequence>
                <xsd:element name="item" type="tns:itemProperty"
                    maxOccurs="unbounded" minOccurs="0" />
            </xsd:sequence>
        </xsd:restriction>
    </xsd:complexContent>
</xsd:complexType>

I intend to use this list

<message name="getListRequest"></message>
<message name="getListResponse">
    <part name="return" type="tns:itemPropertyList" />
</message>
<operation name="getList">
    <documentation>Returns an array.</documentation>
    <input message="tns:getListRequest" />
    <output message="tns:getListResponse" />
</operation>

Instead of a list of items like itemProperty, I get this answer, no matter what options I tried (including replacing the base item with explicit string elements)

<SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
    <SOAP-ENV:Body>
    <ns1:getListResponse>
    <return SOAP-ENC:arrayType="ns2:Map[1]" xsi:type="SOAP-ENC:Array">
    <item xsi:type="ns2:Map">
    <item>
        <key xsi:type="xsd:string">name</key>
        <value xsi:type="xsd:string">name_4c3b38b0b77ae</value>
    </item>
    <item>
        <key xsi:type="xsd:string">value</key>
        <value xsi:type="xsd:string">name_4c3b38b0b77ee</value>
    </item>
    <item>
        <key xsi:type="xsd:string">type</key>
        <value xsi:type="xsd:string">name_4c3b38b0b782b</value>
    </item>
    </item>
    </return>
    </ns1:getListResponse>
    </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

Any ideas? What is this ns2: card? It haunted me for more than a week!

+3
source share
1 answer

solvable.

AXIS . namespaces . , , , eclipse WSDL.

<definitions xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:tns="urn:mynamespace"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" 
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns="http://schemas.xmlsoap.org/wsdl/" 
targetNamespace="urn:mynamespace"
xmlns:ns1="http://org.apache.axis2/xsd" 
xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" 
xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
xmlns:ax21="http://example.org/xsd" 
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" 
xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" 
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/">

2

<xsd:schema targetNamespace="urn:mynamespace" attributeFormDefault="qualified" elementFormDefault="qualified">
    ...
</xsd:schema>    

, ComplexType, "" , :

<xsd:element name="getListResponse">
    <xsd:complexType>
        <xsd:sequence>
            <xsd:element maxOccurs="unbounded" minOccurs="0" name="return" nillable="true" type="tns:itemProperty" />
        </xsd:sequence>
    </xsd:complexType>
</xsd:element>    

, ,

<message name="getListResponse">
    <part name="parameters" element="tns:getListResponse" />
</message>    

<message name="getListResponse">
    <part name="return" type="tns:itemPropertyList" />
</message>    

:

<SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:mynamespace" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body>
    <ns1:getListResponse>
        <parameters xsi:type="ns1:getListResponse">
            <return xsi:type="ns1:itemProperty">
                <name xsi:type="xsd:string">name4c4417b644a8e</name>
                <value xsi:type="xsd:string">value4c4417b644aaa</value>
                <type xsi:type="xsd:string">type4c4417b644ae8</type>
            </return>
            <return xsi:type="ns1:itemProperty">
                <name xsi:type="xsd:string">name4c4417b644b26</name>
                <value xsi:type="xsd:string">value4c4417b644b64</value>
                <type xsi:type="xsd:string">type4c4417b644ba1</type>
            </return>
            <return xsi:type="ns1:itemProperty">
                <name xsi:type="xsd:string">name4c4417b644bdf</name>
                <value xsi:type="xsd:string">value4c4417b644c1c</value>
                <type xsi:type="xsd:string">type4c4417b644c59</type>
            </return>
        </parameters>
    </ns1:getListResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
+3

Source: https://habr.com/ru/post/1754255/


All Articles