XML映射服务

时间:2015-08-12 12:37:42

标签: xml spring web-services

我需要帮助创建客户端。 我得到了一些请求的例子,我应该为此做客户:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:rtdm="http://www.test.com/xml/schema/test-svcs/rtdm-1.1">
<soapenv:Header />
<soapenv:Body>
    <rtdm:Event name="Call">
        <rtdm:Header>
            <!--Optional: -->
            <rtdm:Identity>TEST</rtdm:Identity>
            <rtdm:ClientTimeZoneID>EUROPE/BELGRADE</rtdm:ClientTimeZoneID>
        </rtdm:Header>
        <rtdm:Body>
            <rtdm:Data name="CLIENTID">
                <!--You have a CHOICE of the next 2 items at this level -->
                <rtdm:String>
                    <!--Optional: -->
                    <rtdm:Val>16</rtdm:Val>
                </rtdm:String>
            </rtdm:Data>
            <rtdm:Data name="AGENT_ID">
                <!--You have a CHOICE of the next 2 items at this level -->
                <rtdm:String>
                    <!--Optional: -->
                    <rtdm:Val>10</rtdm:Val>
                </rtdm:String>
            </rtdm:Data>
            <rtdm:Data name="balance">
                <rtdm:Float>
                    <rtdm:Val>100</rtdm:Val>
                </rtdm:Float>
            </rtdm:Data>
            </rtdm:Body>
    </rtdm:Event>
</soapenv:Body>

到目前为止,我已经上课了:

@XmlElement(name = "Header", namespace = "http://www.test.com/xml/schema/test-svcs/rtdm-1.1")
private HeaderType header;

@XmlElement(name = "Body", namespace = "http://www.test.com/xml/schema/test-svcs/rtdm-1.1")
private BodyType body;

我开始制作BodyType类:

@XmlElement(name = "CLIENTID", namespace = "http://www.test.com/xml/schema/test-svcs/rtdm-1.1")
private String clientId;

@XmlElement(name = "AGENT_ID", namespace = "http://www.test.com/xml/schema/test-svcs/rtdm-1.1")
private String agentId;

@XmlElement(name = "balance", namespace = "http://www.test.com/xml/schema/test-svcs/rtdm-1.1")
private Double accountBalance; 

但我不确定如何从示例中做到这一点:

<rtdm:Data name="CLIENTID">
    <rtdm:String>
            <rtdm:Val>16</rtdm:Val>
    </rtdm:String>
</rtdm:Data>

<rtdm:Data name="AGENTID">
    <rtdm:String>
        <rtdm:Val>10</rtdm:Val>
    </rtdm:String>
</rtdm:Data>
.....

这是Data类的一些列表以及如何使属性名= ClientID,name = AGENTID ... 以及如何生成在该类中具有此效果:

<rtdm:String>
            <rtdm:Val>16</rtdm:Val>
    </rtdm:String>

这是wsdl:

    <?xml version="1.0" encoding="utf-8"?>
<definitions name="TEST"
             xmlns="http://schemas.xmlsoap.org/wsdl/"
             targetNamespace="http://www.test.com/xml/schema/test-svcs/rmdt-1.1/wsdl/"
             xmlns:tns="http://www.test.com/xml/schema/test-svcs/rmdt-1.1/wsdl/"
             xmlns:typesns="http://www.test.com/xml/schema/test-svcs/rmdt-1.1"
             xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">

   <types>
      <schema xmlns="http://www.w3.org/2001/XMLSchema"
              targetNamespace="http://www.test.com/xml/schema/test-svcs/rmdt-1.1"
              xmlns:tns="http://www.test.com/xml/schema/test-svcs/rmdt-1.1"
              elementFormDefault="qualified">

         <simpleType name="NameType">
          <annotation>
            <documentation>
                Defines a standard format for names that include spaces.
                e.g. file names
            </documentation>
          </annotation>
          <restriction base="normalizedString">
            <maxLength value="255" />
            <pattern
                value="[^\\/:\*\?&quot;&lt;&gt;\|@&amp;#&apos;~`\[\]\{\}]*" />
          </restriction>
         </simpleType>

         <simpleType name="DataTypes">
           <annotation>
            <documentation>Primitive data types supported </documentation>
           </annotation>
           <restriction base="normalizedString">
            <enumeration value="Int" />
            <enumeration value="Boolean" />
            <enumeration value="Float" />
            <enumeration value="DateTime" />
            <enumeration value="String" />
            <enumeration value="Table" />
           </restriction>
         </simpleType>

         <element name="String">
            <complexType>
               <sequence>
                  <element name="Val" type="string" minOccurs="0"/>
               </sequence>
            </complexType>
         </element>

         <element name="StringArray">
            <complexType>
               <sequence>
                  <element name="Val" minOccurs="0">
                     <complexType>
                        <sequence>
                           <element name="Item" type="string" minOccurs="0" maxOccurs="unbounded"/>
                        </sequence>
                     </complexType>
                  </element>
               </sequence>
            </complexType>
         </element>

         <element name="Int">
            <complexType>
               <sequence>
                  <element name="Val" type="long" minOccurs="0"/>
               </sequence>
            </complexType>
         </element>
         <element name="IntArray">
            <complexType>
               <sequence>
                  <element name="Val" minOccurs="0">
                     <complexType>
                        <sequence>
                           <element name="Item" type="long" minOccurs="0" maxOccurs="unbounded"/>
                        </sequence>
                     </complexType>
                  </element>
               </sequence>
            </complexType>
         </element>

         <element name="Float">
            <complexType>
               <sequence>
                  <element name="Val" type="double" minOccurs="0"/>
               </sequence>
            </complexType>
         </element>
         <element name="FloatArray">
            <complexType>
               <sequence>
                  <element name="Val" minOccurs="0">
                     <complexType>
                        <sequence>
                           <element name="Item" type="double" minOccurs="0" maxOccurs="unbounded"/>
                        </sequence>
                     </complexType>
                  </element>
               </sequence>
            </complexType>
         </element>

         <element name="Boolean">
            <complexType>
               <sequence>
                   <element name="Val" type="boolean" minOccurs="0"/>
               </sequence>
            </complexType>
         </element>
         <element name="BooleanArray">
            <complexType>
               <sequence>
                  <element name="Val" minOccurs="0">
                     <complexType>
                        <sequence>
                           <element name="Item" type="boolean" minOccurs="0" maxOccurs="unbounded"/>
                        </sequence>
                     </complexType>
                  </element>
               </sequence>
            </complexType>
         </element>

         <element name="DateTime">
            <complexType>
               <sequence>
                  <element name="Val" type="dateTime" minOccurs="0"/>
               </sequence>
            </complexType>
         </element>
         <element name="DateTimeArray">
            <complexType>
               <sequence>
                  <element name="Val" minOccurs="0">
                     <complexType>
                        <sequence>
                           <element name="Item" type="dateTime" minOccurs="0" maxOccurs="unbounded"/>
                        </sequence>
                     </complexType>
                  </element>
               </sequence>
            </complexType>
         </element>

         <complexType name="TableDataType">
           <annotation>
              <documentation>
                Only one of the following sequenced elements should be
                included with element TableType.Row.Col below. This schema 
                does not make this constraint visible for reasons previously 
                noted.
              </documentation>
            </annotation>
          <sequence>
            <element ref="tns:String" minOccurs="0" maxOccurs="1" />
            <element ref="tns:Int" minOccurs="0" maxOccurs="1" />
            <element ref="tns:Float" minOccurs="0" maxOccurs="1" />
            <element ref="tns:Boolean" minOccurs="0" maxOccurs="1" />
            <element ref="tns:DateTime" minOccurs="0" maxOccurs="1" />
          </sequence>
        </complexType>
        <complexType name="TableColumnType">
          <attribute name="name" type="tns:NameType" use="required" />
          <attribute name="type" type="tns:DataTypes" use="required" />
        </complexType>

        <complexType name="TableRowType">
           <sequence>
            <!-- A row, if it exists at all, must have at least 1 Col element -->
            <element name="Col" type="tns:TableDataType" minOccurs="1" maxOccurs="unbounded" />
          </sequence>
        </complexType>
        <complexType name="TableType">
          <sequence>
            <!--  Order of Columns must match order of data in Rows
                  Table may be completely empty to start, hence minOccurs 0
            -->
            <element name="Column" type="tns:TableColumnType" minOccurs="0" maxOccurs="unbounded" />
            <element name="Row" type="tns:TableRowType" minOccurs="0" maxOccurs="unbounded" />
          </sequence>
        </complexType>

         <element name="Table">
            <complexType>
              <sequence>
                <element name="Val" type="tns:TableType" minOccurs="0" />
              </sequence>
            </complexType>
         </element> 

        <element name="TableArray">
             <complexType>
               <sequence>
                  <element name="Val" minOccurs="0">
                    <complexType>
                        <sequence>
                            <element name="Item" type="tns:TableType" minOccurs="0" maxOccurs="unbounded" nillable="true" />
                        </sequence>
                    </complexType>
                  </element>
              </sequence>
             </complexType>
        </element>

         <annotation>
            <documentation>
            Input-Type-Mapping:
            [CLIENTID:String],
            [AGENTID:String],
            [BALANCE:Float]
            </documentation>
         </annotation>
         <complexType name="DataItemType">
            <choice>
               <element ref="tns:String"/>
               <element ref="tns:Float"/>
            </choice>
            <attribute name="name" use="required">
               <simpleType>
                  <restriction base="string">
                     <enumeration value="CLIENTID"/>
                     <enumeration value="AGENTID"/>
                     <enumeration value="BALANCE"/>
                  </restriction>
               </simpleType>
            </attribute>
         </complexType>

         <annotation>
            <documentation>
            Output-Type-Mapping:
            [CLIENTID:String],
            [AGENTID:Float],
            [DESCRIPTION:StringArray]
            </documentation>
         </annotation>
         <complexType name="DataItemResponseType">
            <choice>
               <element ref="tns:String"/>
               <element ref="tns:Float"/>
               <element ref="tns:StringArray"/>
            </choice>
            <attribute name="name" use="required">
               <simpleType>
                  <restriction base="string">
                     <enumeration value="CLIENTID"/>
                     <enumeration value="AGENTID"/>
                     <enumeration value="DESCRIPTION"/>
                  </restriction>
               </simpleType>
            </attribute>
         </complexType>

         <complexType name="HeaderType">
            <sequence>
               <element name="Identity" type="string" minOccurs="0"/>
               <element name="ClientTimeZoneID" type="normalizedString" minOccurs="1" maxOccurs="1"/>
            </sequence>
         </complexType>

         <complexType name="HeaderResponseType">
            <sequence>
               <element name="CorrelationId" type="string" minOccurs="0"/>
               <element name="StartTime" type="string"/>
               <element name="CompletionTime" type="string"/>
            </sequence>
         </complexType>

         <complexType name="BodyType">
            <sequence>
               <element name="Data" type="tns:DataItemType" minOccurs="9" maxOccurs="9"/>
            </sequence>
         </complexType>

         <complexType name="BodyResponseType">
            <sequence>
               <element name="Data" type="tns:DataItemResponseType" minOccurs="15" maxOccurs="15"/>
            </sequence>
         </complexType>

         <complexType name="EventType">
            <sequence>
               <element name="Header" type="tns:HeaderType" minOccurs="1" maxOccurs="1"/>
               <element name="Body" type="tns:BodyType"/>
            </sequence>
            <attribute name="name" type="string" use="required" fixed="test"/>
         </complexType>

         <complexType name="EventResponseType">
            <sequence>
               <element name="Header" type="tns:HeaderResponseType"/>
               <element name="Body" type="tns:BodyResponseType"/>
            </sequence>
            <attribute name="name" type="string" use="required" fixed="test"/>
         </complexType>

         <element name="Event" type="tns:EventType"/>
         <element name="EventResponse" type="tns:EventResponseType"/>

         <element name="FaultException" type="tns:FaultException"/>
         <complexType name="FaultException">
            <sequence>
               <element name="ExceptionMessage" type="string" minOccurs="0" maxOccurs="unbounded"/>
            </sequence>
         </complexType>
      </schema>
   </types>

   <message name="eventRequest">
      <part name="parameters" element="typesns:Event"/>
   </message>
   <message name="eventResponse">
      <part name="parameters" element="typesns:EventResponse"/>
   </message>
   <message name="FaultException">
      <part name="detail" element="typesns:FaultException"/>
   </message>

   <portType name="EventPortType">
      <operation name="Event">
         <input message="tns:eventRequest"/>
         <output message="tns:eventResponse"/>
         <fault name="fault" message="tns:FaultException"/>
      </operation>
   </portType>

   <binding name="EventSoapBinding" type="tns:EventPortType">
      <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
      <operation name="Event">
         <soap:operation soapAction=""/>
         <input>
            <soap:body use="literal"/>
         </input>
         <output>
            <soap:body use="literal"/>
         </output>
         <fault name="fault">
            <soap:fault name="fault" use="literal"/>
         </fault>
      </operation>
   </binding>


</definitions>

0 个答案:

没有答案