当我使用Java HttpUrlConnection联系Web服务时,它仅返回400错误请求(IOException)。如何获取服务器返回的XML信息;它看起来不在连接的getErrorStream中,也不在任何异常信息中。Java getInputStream 400错误
当我运行针对Web服务下面的PHP代码:
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://www.myclientaddress.com/here/");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST,1);
curl_setopt($ch, CURLOPT_POSTFIELDS,"username=ted&password=scheckler&type=consumer&id=123456789&zip=12345");
$result=curl_exec ($ch);
echo $result;
?>
它返回下列信息:
<?xml version="1.0" encoding="utf-8"?>
<response>
<status>failure</status>
<errors>
<error name="RES_ZIP">Zip code is not valid.</error>
<error name="ZIP">Invalid zip code for residence address.</error>
</errors>
</response>
,所以我知道的信息存在
我没有参与系统设计,所以我无法回答。它也取决于客户端,有些返回XML返回文本。无论如何,连接支持不仅仅是捕获原始回报? – threadhack 2010-06-14 15:24:55