0
シンプルなHttpServletを使用して別のサーバーからSOAPリクエストを管理しようとしています。 リクエストにはbyte []タイプのパラメータが1つしかありません(単純な文字列です)。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