use of org.apache.cxf.service.model.OperationInfo in project cxf by apache.
the class XMLMessageInInterceptorTest method testHandleMessageOnBareMultiParam.
@Test
public void testHandleMessageOnBareMultiParam() throws Exception {
String ns = "http://apache.org/hello_world_xml_http/bare";
prepareMessage("/message-bare-multi-param.xml");
common("/wsdl/hello_world_xml_bare.wsdl", new QName(ns, "XMLPort"), MyComplexStructType.class);
OperationInfo op = serviceInfo.getInterface().getOperation(new QName(ns, "testMultiParamPart"));
op.getInput().getMessagePartByIndex(0).setTypeClass(String.class);
op.getInput().getMessagePartByIndex(1).setTypeClass(MyComplexStructType.class);
in.handleMessage(xmlMessage);
docLitIn.handleMessage(xmlMessage);
List<?> list = xmlMessage.getContent(List.class);
assertNotNull(list);
assertEquals("expect 2 param", 2, list.size());
assertEquals("method input in2 is MyComplexStructType", true, list.get(1) instanceof MyComplexStructType);
assertEquals("method input in1 is String tli", true, ((String) list.get(0)).indexOf("tli") >= 0);
}
use of org.apache.cxf.service.model.OperationInfo in project cxf by apache.
the class XMLMessageInInterceptorTest method testHandleMessageOnBareSingleChild.
@Test
public void testHandleMessageOnBareSingleChild() throws Exception {
String ns = "http://apache.org/hello_world_xml_http/bare";
prepareMessage("/message-bare-single-param-element.xml");
common("/wsdl/hello_world_xml_bare.wsdl", new QName(ns, "XMLPort"));
OperationInfo op = serviceInfo.getInterface().getOperation(new QName(ns, "greetMe"));
op.getInput().getMessagePartByIndex(0).setTypeClass(String.class);
in.handleMessage(xmlMessage);
docLitIn.handleMessage(xmlMessage);
List<?> list = xmlMessage.getContent(List.class);
assertNotNull(list);
assertEquals("expect 1 param", 1, list.size());
assertEquals("method input me is String tli", true, ((String) list.get(0)).indexOf("tli") >= 0);
}
use of org.apache.cxf.service.model.OperationInfo in project cxf by apache.
the class XMLMessageInInterceptorTest method testHandleMessageWrapped.
@Test
public void testHandleMessageWrapped() throws Exception {
String ns = "http://apache.org/hello_world_xml_http/wrapped";
prepareMessage("/message-wrap.xml");
common("/wsdl/hello_world_xml_wrapped.wsdl", new QName(ns, "XMLPort"), GreetMe.class);
OperationInfo op = serviceInfo.getInterface().getOperation(new QName(ns, "greetMe"));
op.getInput().getMessagePartByIndex(0).setTypeClass(GreetMe.class);
in.handleMessage(xmlMessage);
docLitIn.handleMessage(xmlMessage);
List<?> list = xmlMessage.getContent(List.class);
assertNotNull(list);
assertEquals("expect 1 param", 1, list.size());
assertEquals("method input me is String tli", true, list.get(0) instanceof GreetMe);
}
use of org.apache.cxf.service.model.OperationInfo in project cxf by apache.
the class AegisDatabinding method initialize.
/**
* {@inheritDoc} Set up the data binding for a service.
*/
public void initialize(Service s) {
// We want to support some compatibility configuration properties.
if (aegisContext == null) {
aegisContext = new AegisContext();
Object val = s.get("mtom-enabled");
if ("true".equals(val) || Boolean.TRUE.equals(val) || mtomEnabled) {
setMtomEnabled(true);
aegisContext.setMtomEnabled(true);
}
if (mtomUseXmime) {
aegisContext.setMtomUseXmime(true);
}
Map<Class<?>, String> implMap = new HashMap<>();
// now for a really annoying case, the .implementation objects.
for (String key : s.keySet()) {
if (key.endsWith(".implementation")) {
String className = key.substring(0, key.length() - ".implementation".length());
Class<?> clazz = null;
try {
clazz = ClassLoaderUtils.loadClass(className, getClass());
} catch (ClassNotFoundException e) {
Message message = new Message("MAPPED_CLASS_NOT_FOUND", LOG, className, key);
LOG.warning(message.toString());
continue;
}
String implClassName = (String) s.get(key);
implMap.put(clazz, implClassName);
}
}
if (overrideTypes != null) {
aegisContext.setRootClassNames(overrideTypes);
}
if (configuration != null) {
aegisContext.setTypeCreationOptions(configuration);
}
if (!implMap.isEmpty()) {
aegisContext.setBeanImplementationMap(implMap);
}
}
aegisContext.setMappingNamespaceURI(s.getServiceInfos().get(0).getInterface().getName().getNamespaceURI());
aegisContext.initialize();
this.service = s;
s.getInInterceptors().add(new StaxSchemaValidationInInterceptor());
Set<AegisType> deps = new HashSet<>();
for (ServiceInfo info : s.getServiceInfos()) {
for (OperationInfo opInfo : info.getInterface().getOperations()) {
if (opInfo.isUnwrappedCapable()) {
initializeOperation(s, aegisContext.getTypeMapping(), opInfo.getUnwrappedOperation(), deps);
} else {
initializeOperation(s, aegisContext.getTypeMapping(), opInfo, deps);
}
}
}
Collection<AegisType> additional = aegisContext.getRootTypes();
if (additional != null) {
for (AegisType t : additional) {
if (!deps.contains(t)) {
deps.add(t);
}
addDependencies(deps, t);
}
}
createSchemas(s, deps);
for (ServiceInfo info : s.getServiceInfos()) {
for (OperationInfo opInfo : info.getInterface().getOperations()) {
if (opInfo.isUnwrappedCapable()) {
initializeOperationTypes(info, opInfo.getUnwrappedOperation());
} else {
initializeOperationTypes(info, opInfo);
}
}
}
}
use of org.apache.cxf.service.model.OperationInfo in project cxf by apache.
the class XMLFormatValidator method checkXMLFormat.
private boolean checkXMLFormat(BindingInfo binding) {
Collection<BindingOperationInfo> bos = binding.getOperations();
boolean result = true;
boolean needRootNode = false;
for (BindingOperationInfo bo : bos) {
OperationInfo op = binding.getInterface().getOperation(bo.getName());
needRootNode = false;
final int inputPartsNum = op.getInput().getMessagePartsNumber();
if (inputPartsNum == 0 || inputPartsNum > 1) {
needRootNode = true;
}
if (needRootNode) {
String path = "Binding(" + binding.getName().getLocalPart() + "):BindingOperation(" + bo.getName() + ")";
List<XMLBindingMessageFormat> inExtensors = bo.getInput().getExtensors(XMLBindingMessageFormat.class);
Iterator<XMLBindingMessageFormat> itIn = null;
if (inExtensors != null) {
itIn = inExtensors.iterator();
}
if (!findXMLFormatRootNode(itIn, bo, path + "-input")) {
return false;
}
// Input check correct, continue to check output binding
if (op.getOutput() != null) {
needRootNode = false;
final int outputPartsNum = op.getOutput().getMessagePartsNumber();
if (outputPartsNum == 0 || outputPartsNum > 1) {
needRootNode = true;
}
if (needRootNode) {
List<XMLBindingMessageFormat> outExtensors = bo.getOutput().getExtensors(XMLBindingMessageFormat.class);
Iterator<XMLBindingMessageFormat> itOut = null;
if (outExtensors != null) {
itOut = outExtensors.iterator();
}
result = result && findXMLFormatRootNode(itOut, bo, path + "-Output");
if (!result) {
return false;
}
}
}
}
}
return true;
}
Aggregations