(si 2.11是特定的,spring 3.1.1)getStandardRequestHeaderNames可以被覆蓋以在si消息頭中包含附加應用程序特定對象。我們的應用程序依賴於這種能力(可能是錯誤的)來覆蓋這種方法,並提供一個自定義的POJO,由許多分離器,聚合器等組成,由下游組成。該應用程序使用ws入站網關並使用header-mapper屬性來指定自定義肥皂頭映射器。彈簧整合DefaultSoapHeaderMapper - getStandardRequestHeaderNames - 覆蓋以前si版本中的
爲什麼getStandardRequestHeaderNames無法被覆蓋的背後推理的任何線索?
需要一些建議,我可以如何遷移到當前的春季版本。 要求是從soapHeader中提取元素,並將它們映射到SI消息頭中作爲POJO並將其發送到下游。 所有幫助表示讚賞。
代碼片段:與舊版本春天
<int-ws:inbound-gateway id="webservice-inbound-gateway"
request-channel="input-request-channel"
reply-channel="output-response-channel"
header-mapper="CustomSoapHeaderMapper"
marshaller="marshaller"
unmarshaller="marshaller" />
@Component("CustomSoapHeaderMapper")
public class CustomSoapHeaderMapper extends DefaultSoapHeaderMapper {
private static final Logger logger = Logger.getLogger("CustomSoapHeaderMapper");
public static final String HEADER_SEARCH_METADATA = SearchMetadata.HEADER_ATTRIBUTE_NAME;
public static final String HEADER_SERVICE_AUDIT = "XXXXXXXX";
// Use simulation if security token is set to this value
public static final String SECURITY_TOKEN_SIMULATION = "XXXX";
private static final List<String> CUSTOM_HEADER_NAMES = new ArrayList<String>();
static {
CUSTOM_HEADER_NAMES.add(WebServiceHeaders.SOAP_ACTION);
CUSTOM_HEADER_NAMES.add(HEADER_SEARCH_METADATA);
}
private int version =SearchMetadata.VERSION_CURRENT;
public void setVersion(int version) {
this.version = version;
}
@Override
protected List<String> getStandardRequestHeaderNames() {
return CUSTOM_HEADER_NAMES;
}
@Override
protected Map<String, Object> extractUserDefinedHeaders(SoapMessage source) {
// logger.log(Level.INFO,"extractUserDefinedHeaders");
// call base class to extract header
Map<String, Object> map = super.extractUserDefinedHeaders(source);
Document doc = source.getDocument();
SearchMetadata searchMetadata = new SearchMetadata();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
try {
source.writeTo(baos);
baos.flush();
searchMetadata.setRequestXML(baos.toString());
baos.close();
} catch (IOException e1) {
}
//logger.log(Level.WARNING, "Incoming Message " + baos.toString());
SOAPMessage soapMessage = ((SaajSoapMessage) source).getSaajMessage();
// generate TransactionID with UUID value
String transactionID = UUID.randomUUID().toString();
// logger.log(Level.WARNING, "TransactionID=" + transactionID);
Date now = new Date();
searchMetadata.setTransactionID(transactionID);
searchMetadata.setRequestType(SearchMetadata.REQUEST_TYPE_SYNCHRONOUS);
searchMetadata.setRequestTime(now);// initialize the request time
searchMetadata.setReceivedTime(now);// mark time system receives request
searchMetadata.setVersion(version);
Map<String, Object> finalHeaders = new HashMap<String, Object>();
finalHeaders.put(HEADER_SEARCH_METADATA, searchMetadata);
if (!CollectionUtils.isEmpty(map)) {
// copy from other map
finalHeaders.putAll(map);
// check if ServiceAudit is available
SoapHeaderElement serviceAuditElement = null;
for (String key : map.keySet()) {
// logger.log(Level.WARNING, "SoapHeader.{0}", key);
if (StringUtils.contains(key, HEADER_SERVICE_AUDIT)) {
serviceAuditElement = (SoapHeaderElement) map.get(key);
break;
}
}
}
return finalHeaders;
}
// GK Key Thing here for performance improvement is avoiding marshalling
public gov.dhs.ice.ess.schema.ServiceAudit ExtractAuditHeader(Document doc) {
....
}
return serviceAudit;
}
}
感謝響應。我真的很感激 。肯定會重新發布最低限度的代碼以突出問題。我對SI的知識非常有限,請原諒無知。我可以很容易地從傳入的soap消息頭中提取感興趣的元素。 extractuserDefinedHeaders返回包含新元素的Map。我找不到在SoapHeaderMapper中訪問SI消息的方法。我甚至嘗試過實現多個接口的自定義SoapheaderMapper,包括普通的headerMapper。 –
你不需要擔心這個級別的消息。所有userDefinedHeaders將移動到消息標題。你不需要做那個標準的頭文件。 –
請參閱requestHeaderNames選項 –