简体   繁体   English

XSD中嵌套的ComplexType的正确JSON请求正文

[英]Correct JSON request body for nested ComplexType in XSD

I have a Restful interface setup using XSD and the jaxb2-maven-plugin. 我有一个使用XSD和jaxb2-maven-plugin的Restful接口设置。 I am now trying to make a restful call and I cannot pass in a 'FilePair' properly. 我现在正在尝试打个安静的电话,而我无法正确传递“ FilePair”。

XSD Snippet: XSD片段:

    <xsd:complexType name="FilePair">
           <xsd:sequence>
               <xsd:element minOccurs="1" maxOccurs="1" name="requestFile" type="xsd:string" />
               <xsd:element minOccurs="1" maxOccurs="1" name="responseFile" type="xsd:string" />
           </xsd:sequence>
   </xsd:complexType>

   <xsd:complexType name="ValidateCcmtaFileRequest">
       <xsd:sequence>
           <xsd:element minOccurs="1" maxOccurs="1" name="RequestToken" type="xsd:string" />
           <xsd:element minOccurs="1" maxOccurs="1" name="OnCompletionURI" type="xsd:string" />
           <xsd:element minOccurs="1" maxOccurs="unbounded" name="Fileset" type="tns:FilePair" />
       </xsd:sequence>
   </xsd:complexType>

The sample JSON body I am trying to send: 我尝试发送的示例JSON正文:

{
   "requestToken"  : "1234567",
   "onCompletionURI" : "http://someURL",
   "Fileset" : [
        {"requestFile" : "test.in", "responseFile" : "test.out"}
    ]
}

My questions is: 1) is my request body correct for the corresponding xsd and what is the correct JSON. 我的问题是:1)我的请求主体对相应的xsd是否正确,什么是正确的JSON? 2) is there a tool where i can provide a full XSD and it generates JSON request bodies for me. 2)有没有我可以提供完整XSD的工具,它可以为我生成JSON请求正文。

The error with the original JSON was I used Fileset (capital F) instead of fileset (small F) The correct JSON body is: 原始JSON的错误是我使用Fileset(大写F)而不是Fileset(小F)。正确的JSON主体为:

{
   "requestToken"  : "1234567",
   "onCompletionURI" : "http://someURL",
   "fileset" : [
        {"requestFile" : "test.in", "responseFile" : "test.out"}
    ]
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM