Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/369.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 使用springrestapi_Java_Spring_Web Services_Rest_Spring Mvc - Fatal编程技术网

Java 使用springrestapi

Java 使用springrestapi,java,spring,web-services,rest,spring-mvc,Java,Spring,Web Services,Rest,Spring Mvc,我想用SpringMVC创建一个RESTfulWebService。我学习了一些教程,可以 了解如何使用spring创建Web服务。但我不知道该怎么做 让它符合我的要求。 我的要求是xyz公司向abc公司发送一个xml文件及其使用细节。 现在,我的公司必须使用SpringRESTAPI使用xml文件,并将详细信息存储在 数据库。任何帮助都将不胜感激。 在SpringWebservices中,我只看到过像crud Opartion这样的例子 但如何使它符合我的要求。 提前谢谢。 下面是我研究的示例

我想用SpringMVC创建一个RESTfulWebService。我学习了一些教程,可以 了解如何使用spring创建Web服务。但我不知道该怎么做 让它符合我的要求。 我的要求是xyz公司向abc公司发送一个xml文件及其使用细节。 现在,我的公司必须使用SpringRESTAPI使用xml文件,并将详细信息存储在 数据库。任何帮助都将不胜感激。 在SpringWebservices中,我只看到过像crud Opartion这样的例子 但如何使它符合我的要求。 提前谢谢。 下面是我研究的示例:

“” “”

假设下面是我的restapi使用的xml,我想把这些细节放到数据库中,我该怎么做呢

<Usage xmlns="http://www.abc.com/abc/It/schema"       
xmlns:id="http://standards.iso.org/iso/19770/-2/2009/schema.xsd">    
    <timestamp>2010-01-01T12:38:11.123Z</timestamp>    
   <proxy>        
  <address>host address</address>        
 <platforms>xyz</platform>    
 </proxy>    
  <as> <label>Label name</label><name>sdff</name>        
  <id><a_id>34D87XHF72122</a_id><line>sadf</line>                                            
   <title>adffdn<title>
  <version>3.1</version> <creator>abc Corp.</creator>
  <license>abcCorp. </license></id>

2010-01-01T12:38:11.123Z
主机地址
xyz
标签名称DFF
34D87XHF72122sadf
adffdn
3.1 abc公司。
abcCorp。

如果xyz公司正在向您的服务器发送XML文件,您可能希望使用类似的方法来处理请求,而不返回任何内容:

@RequestMapping(value="/xyz", method = RequestMethod.POST, consumes = {"text/xml"})
@ResponseStatus(HttpStatus.OK)
public void processXML(@RequestBody Object someObject) {

}

编辑:请参阅@RequestBody:

上的Spring文档,xyz公司发送了一个xml文件,您是否可以显示一个示例xml。创建一个接受POST谓词和应用程序/xml内容类型的REST方法。然后,XYZ公司将发送一个POST请求,其中包含正文中的xml,您的服务将从正文中读取。谢谢您的回复。您是否也可以就如何将其存储在数据库中给出建议。通常您在数据库(DAO)层中使用JPA/Hibernate。您可能想问另一个与此相关的问题,或者编辑您现有的问题,使其更加具体。