HTTP/1.1 500 Internal Server Error
Content-Type: application/xml; charset=UTF-8
Connection: close
Content-Length: 401
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<fulfillmentService><responseCode>1106</responseCode>
<status>FAILURE</status><systemType>CIS</systemType>
<responseDescription>Sorry! We are unable to process your request. Call 111 for customer care or visit www.mtnzambia.com.</responseDescription><requestId>WEB_10.100.244.97_92505288-f094-4834-a978-658c19e3f656</requestId></fulfillmentService>
我需要一种在java中记录这个XML响应的方法。当我从我的java发送请求时,这是返回的。我需要一种打印出响应描述的方法。
下面是我的java代码:
url = new URL(endpoint);
connection = (HttpURLConnection) url.openConnection();
responseCode = connection.getResponseCode();
respTxt = connection.getResponseMessage();
System.out.println("Status code after sending the the payload to mtn => " + responseCode + " Now waiting for response: ");
Object vm = connection.toString();
// BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
PrintWriter pw = new PrintWriter(connection.getOutputStream());
// send xml to jsp
// pw.write(buffer, 0, bytes_read);
// pw.close();
BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
String inputLine;
while ((inputLine = in.readLine()) != null) {
System.out.println(inputLine);
}
如果响应代码不是200、2xx或3xx,请使用getErrorStream()而不是getInputStream()。
请参阅如何使用HttpURLConnection在返回2xx以外的代码时获取响应正文?
url = new URL(endpoint);
connection = (HttpURLConnection) url.openConnection();
responseCode = connection.getResponseCode();
respTxt = connection.getResponseMessage();
System.out.println("Status code after sending the the payload to mtn => " + responseCode + " Now waiting for response: ");
Object vm = connection.toString();
// BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
//PrintWriter pw = new PrintWriter(connection.getOutputStream());
// send xml to jsp
// pw.write(buffer, 0, bytes_read);
// pw.close();
BufferedReader in;
if(responseCode >= 200 && responseCode < 400) {
in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
} else {
in = new BufferedReader(new InputStreamReader(connection.getErrorStream()));
}
String inputLine;
while ((inputLine = in.readLine()) != null) {
System.out.println(inputLine);
}
下面尝试过,但是直到并且除非我使Acyah geShipmentIn绑定节点为空(删除释放ID="9.2"xmlns="http://schema.infor.com/InforOAGIS/2"xmlns: xs="http://www.w3.org/2001/XMLSchema")选择查询不获取值。
我有一个反向代理设置与nginx。 如何将从后端服务器发送到nginx的http请求(包括头)记录到文件中? 也许nginx http代理模块中的某个指令可以帮助我做到这一点。 但我找不到任何有用的指示。
在spring中提供了三种不同的方法来连接响应端: 我的目标是记录每个响应(标题状态代码),不管结果如何。 我怎样才能知道上述哪种方法是正确的?
控制台中的结果如下: 我不明白为什么会发生这种情况。
我想知道如何缓存来自Web服务器(返回json数据)的okHTTP响应? 你知道如果应用程序只需要在第一次运行时下载数据--然后只有在数据发生变化时才下载数据该怎么办吗?
当我调用服务在日志文件中获取此信息消息时,它工作正常,但将此消息写入日志文件: php.INFO:User Deprecated:The“logger”服务是私有的,从容器中获取它是不推荐的,因为Symfony 3.2,并且将在4.0中失败。您应该公开服务,或者停止直接使用容器,改用依赖项注入。{“异常”:“[object](ErrorException(代码:0):用户已弃用:记录器\”\“服务