我有一个简单的小数据库,我想创建一些Web服务来理解netbeans向导。
我有三张桌子:
当我得到
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”实体的条目。为什么呢?
答案 0 :(得分: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>