0

我有一个小而简单的数据库,我想创建一些 Web 服务来理解 netbeans 向导。

我有一个三表:

  • 地区(1:n)(1:n)公社

当我得到

http://myhost/webservices/regione

我有这样的回应:

<?xml version="1.0" encoding="UTF-8"?> 
   <regiones> 
       <regione> 
           <id>1</id> 
           <nome>Piemonte</nome> 
           <ripartizioneGeografica>NORD OCCIDENTALE</ripartizioneGeografica> 
       </regione> 
       <regione> 
           <id>2</id> 
           <nome>Valle d'Aosta</nome> 
           <ripartizioneGeografica>NORD OCCIDENTALE</ripartizioneGeografica> 
       </regione> 
       ........
   </regiones> 

但是我在 Regione 中没有看到任何与“provincia”实体相关的条目。为什么?

4

1 回答 1

0
http://myhost/webservices/regione

索要所有地区的清单。provincias 是一个地区的更详细信息,将被要求

http://myhost/webservices/regione/1

<?xml version="1.0" encoding="UTF-8"?> 
  <regione> 
    <id>1</id> 
    <nome>Piemonte</nome> 
    <ripartizioneGeografica>NORD OCCIDENTALE</ripartizioneGeografica>
    <provincias>
      <provincia>
         ...
      </provincia>
        ...
    </provincias>
  </regione> 

测试项目生成的xml

<regionss uri="http://localhost:8080/WebApplication2/resources/regionss">
  <regions uri="http://localhost:8080/WebApplication2/resources/regionss/1/">
     <id>1</id>
     <name>Region 1</name>
     <provincesCollection  uri="http://localhost:8080/WebApplication2/resources/regionss/1/provincesCollection/">
         <provinces uri="http://localhost:8080/WebApplication2/resources/regionss/1/provincesCollection/1/"/>
         <provinces uri="http://localhost:8080/WebApplication2/resources/regionss/1/provincesCollection/2/"/>
     </provincesCollection>
   </regions>
   <regions uri="http://localhost:8080/WebApplication2/resources/regionss/2/">
       <id>2</id>
       <name>Region 2</name>
       <provincesCollection uri="http://localhost:8080/WebApplication2/resources/regionss/2/provincesCollection/">
            <provinces uri="http://localhost:8080/WebApplication2/resources/regionss/2/provincesCollection/3/"/>
       </provincesCollection>
    </regions>
    <regions uri="http://localhost:8080/WebApplication2/resources/regionss/3/">
         <id>3</id>
         <name>Region 3</name>
         <provincesCollection uri="http://localhost:8080/WebApplication2/resources/regionss/3/provincesCollection/">
              <provinces uri="http://localhost:8080/WebApplication2/resources/regionss/3/provincesCollection/4/"/>
              <provinces uri="http://localhost:8080/WebApplication2/resources/regionss/3/provincesCollection/5/"/>
              <provinces uri="http://localhost:8080/WebApplication2/resources/regionss/3/provincesCollection/6/"/>
          </provincesCollection>
     </regions>
</regionss>
于 2012-12-03T11:58:28.213 回答