gpt4 book ai didi

java - HashMap、Arraylist 和带有标题的列表编码到 OMElement 作为 webservice wsdl 中的响应?

转载 作者:太空宇宙 更新时间:2023-11-04 15:05:35 25 4
gpt4 key购买 nike

设置 WSDL 响应的响应。其中响应由 List inside list 组成 map 或列表中的 map 列表或 map 可以包含内部 map 。

最佳答案

private OMElement marshallMapIntoElements(String responseName, LinkedHashMap responseMap)
{
OMFactory fac = OMAbstractFactory.getOMFactory();
OMNamespace omNS = fac.createOMNamespace("http://something.com/w-ww", "w-w-w");
OMElement responseElement = fac.createOMElement(responseName, omNS);
Iterator responseIterator = responseMap.keySet().iterator();
responseElement.addChild(recursiveMapRetrive(responseMap,responseElement));
return responseElement;
}

public OMElement recursiveMapRetrive(LinkedHashMap<String, Object> response, OMElement responseElement) {

for (Map.Entry<String, Object> entry : response.entrySet()) {
OMFactory fac = OMAbstractFactory.getOMFactory();
OMNamespace omNS = fac.createOMNamespace("http://services.xm.org/xsd", "tns");
OMElement fieldElement1 = responseElement;
LinkedHashMap responseMap = new LinkedHashMap();
ArrayList arrayList = new ArrayList();
String field = entry.getKey();
Object value = entry.getValue();
if (value instanceof LinkedHashMap) {
fieldElement1 = fac.createOMElement(field, omNS);
fieldElement1.addChild(recursiveMapRetrive((LinkedHashMap) value, fieldElement1));

} else if (value instanceof ArrayList) {
OMElement fieldElement = null;
for (Object object : (ArrayList) value) {
if (object instanceof LinkedHashMap) {
fieldElement = fac.createOMElement(field, omNS);
fieldElement1.addChild(recursiveMapRetrive((LinkedHashMap) object,fieldElement));
} else {
fieldElement = fac.createOMElement(field, omNS);
fieldElement.addChild(fac.createOMText(fieldElement1,object.toString()));
fieldElement1.addChild(fieldElement);
}
}
return fieldElement1;
} else {
fieldElement1 = fac.createOMElement(field, omNS);
fieldElement1.addChild(fac.createOMText(fieldElement1,value.toString()));
}
responseElement.addChild(fieldElement1);
}
return responseElement;
}

关于java - HashMap、Arraylist 和带有标题的列表编码到 OMElement 作为 webservice wsdl 中的响应?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22031864/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com