私はapache cxfエンドポイントでエスケープされていないxml文字列を返す必要があります。私は私のコードのセクションを貼り付け下に、現在のXML文字列が返されると、所望のXML文字列:Unescape Xml Apache Cxfエンドポイントでの特殊文字
@WebService(endpointInterface = "net.system.soapservice.result.ResultMgrPortType", serviceName = "ResultMgrPortType")
public class ResultServiceImpl implements ResultMgrPortType {
@Override
public String genericAPIResult(String resultMsg) {
Map<String, String> processedResultMsg = DataFormatUtil.parseResultMsg(resultMsg);
String response = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\">"
+ "<soapenv:Body>"
+ "<req:ResponseMsg"
+ " xmlns:req=\"http://api-v1.gen.mm.vodafone.com/mminterface/request\"><![CDATA[<?xml"
+ " version=\"1.0\""
+ "encoding=\"UTF-8\"?><response"
+ " xmlns=\"http://api-"
+ "v1.gen.mm.vodafone.com/mminterface/response\">"
+ "<ResponseCode>"+processedResultMsg.get("ResultCode")+"</ResponseCode>"
+ "<ConversationID>"+processedResultMsg.get("ConversationID")+"</ConversationID>"
+ "<ResponseDesc>Service result processed successfully.</ResponseDesc>"
+ "<OriginatorConversationID>"+processedResultMsg.get("OriginatorConversationID")+"</OriginatorConversationID>"
+ "<ServiceStatus>0</ServiceStatus>"
+ "</response>]]></req:ResponseMsg>"
+ "</soapenv:Body>"
+ "</soapenv:Envelope>";
return response;
}
}
私のログに見られるように、上記エンドポイントからのXML応答:
ID: 4
Response-Code: 200
Encoding: UTF-8
Content-Type: text/xml
Headers: {}
Payload: <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ResponseMsg xmlns="http://api-v1.gen.mm.vodafone.com/mminterface/result"><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<req:ResponseMsg
xmlns:req="http://api-v1.gen.mm.vodafone.com/mminterface/request"><![CDATA[<?xml
version="1.0"
encoding="UTF-8"?><response
xmlns="http://api-
v1.gen.mm.vodafone.com/mminterface/response"><ResponseCode>0</ResponseCode><ConversationID>AG_20170411_000059047aba809d6631</ConversationID><ResponseDesc>Service result processed successfully.</ResponseDesc><OriginatorConversationID>902004_fhltd_60575.0</OriginatorConversationID><ServiceStatus>0</ServiceStatus></response>]]></req:ResponseMsg>
</soapenv:Body>
</soapenv:Envelope></ResponseMsg></soap:Body></soap:Envelope>
--------------------------------------
クライアントが期待するのxml:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<ResponseMsg xmlns="http://api-v1.gen.mm.vodafone.com/mminterface/result">
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<req:ResponseMsg xmlns:req="http://api-v1.gen.mm.vodafone.com/mminterface/request"><![CDATA[<?xml version="1.0"encoding="UTF-8"?><response xmlns="http://api-v1.gen.mm.vodafone.com/mminterface/response"><ResponseCode>0</ResponseCode><ConversationID>AG_20170406_00004ddc3d70f6ba93f0</ConversationID><ResponseDesc>Service result processed successfully.</ResponseDesc><OriginatorConversationID>902004_fhltd_94802.0</OriginatorConversationID><ServiceStatus>0</ServiceStatus></response>]]></req:ResponseMsg>
</soapenv:Body>
</soapenv:Envelope>
</ResponseMsg>
</soap:Body>
</soap:Envelope>
NB:レスポンスがを持つべきではありませんおよび>
。 apache-cxf-services.xml
ファイルに設定を追加するか、この動作を変更するためのインターセプタを作成する必要があります。あなたの時間と労力に事前に感謝します。