0
我想用一个简单的HttpServlet来管理另一个服务器的肥皂请求。 该请求只有一个byte []类型的参数(它是一个简单的字符串)。与Java HttpServlet的解组肥皂信封
相关代码:
@Override
protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
try {
InputStream is = req.getInputStream();
byte[] body = IOUtils.toByteArray(is);
String stringRequest = new String(body);
log.info("Request -> "+stringRequest);
}catch(Exception){log.error(e);}
我收到请求,如果我打印它似乎在这样:
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<fixedResearch soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<MYPARAMETER xsi:type="xsd:hexBinary">
*****bytearray******
</MYPARAMETER>
</fixedResearch>
</soapenv:Body>
</soapenv:Envelope>
我需要得到MYPARAMETER标签内的值(这是一个字节[])。 有一个聪明的方法,也许使用Axis1的一些utils类(我不能使用Axis2)来处理传入的请求?
几乎完美的一部分,MYPARAMETER的内容是hexBinary。所以要打印正确的值,你应该做新的String(hexStringToByteArray(value))。我省略了hexStringToByteArray的实现,因为我在评论中没有足够的字符。 – drenda