POST XML请求中的错误 - Web服务

时间:2015-11-19 19:54:00

标签: java json xml web-services post

我有以下问题:当我尝试使用json的POSTMAN进行POST操作时,我可以毫无问题地执行此操作。这是get操作的结果,该操作列出了id = 3的人的信息(来自我的数据库)。

{
"idPerson": 3,
"firstname": "Padsfsppo",
"lastname": "Pipsdfspo",
"birthdate": null,
"email": null,
"username": null,
"lifeStatus": [
  {
    "idMeasure": 502,
    "value": "85",
    "measureType": {
      "idMeasureDef": 3,
      "name": "steps"
    }
  },
  {
    "idMeasure": 552,
    "value": "85",
    "measureType": {
      "idMeasureDef": 3,
      "name": "steps"
    }
  }
]}

所以,当我用json发出POST请求时,这就是我放入消息正文的内容:

    {
"firstname": "Padsfsppo",
"lastname": "Pipsdfspo",
"birthdate": null,
"email": null,
"username": null,
"lifeStatus": [
  {
    "value": "85",
    "measureType": {
      "idMeasureDef": 3,
      "name": "steps"
    }
  },
  {
    "value": "85",
    "measureType": {
      "idMeasureDef": 3,
      "name": "steps"
    }
  }
]}

它没有问题。

这是xml中的get请求的结果:

<person>
        <idPerson>3</idPerson>
        <firstname>Padsfsppo</firstname>
        <lastname>Pipsdfspo</lastname>
        <healthProfile>
            <lifeStatus>
                <idMeasure>502</idMeasure>
                <measureType>
                    <idMeasureDef>3</idMeasureDef>
                    <name>steps</name>
                </measureType>
                <value>85</value>
            </lifeStatus>
            <lifeStatus>
                <idMeasure>552</idMeasure>
                <measureType>
                    <idMeasureDef>3</idMeasureDef>
                    <name>steps</name>
                </measureType>
                <value>85</value>
            </lifeStatus>
        </healthProfile>
    </person>

对于POST方法,我把它放在身体中:

<person>
    <firstname>Padsfsppo</firstname>
    <lastname>Pipsdfspo</lastname>
    <healthProfile>
        <lifeStatus>
            <measureType>
                <idMeasureDef>3</idMeasureDef>
                <name>steps</name>
            </measureType>
            <value>85</value>
        </lifeStatus>
        <lifeStatus>
            <measureType>
                <idMeasureDef>3</idMeasureDef>
                <name>steps</name>
            </measureType>
            <value>85</value>
        </lifeStatus>
    </healthProfile>
</person>

通过这种方式我收到了这个错误:

  

500内部服务器错误

然而,如果我尝试只发布该人的信息(没有他的healthProfile),它就可以了!

问题出在哪里?谢谢!

0 个答案:

没有答案