use of org.apache.cxf.service.model.OperationInfo in project cxf by apache.
the class CorbaStreamOutEndingInterceptor method handleOutBoundMessage.
private void handleOutBoundMessage(CorbaMessage message, BindingOperationInfo boi) {
OperationInfo opInfo = boi.getOperationInfo();
OperationType opType = boi.getExtensor(OperationType.class);
List<ParamType> paramTypes = opType.getParam();
MessageInfo outMsgInfo = opInfo.getOutput();
String wrapNSUri = null;
boolean wrap = false;
if (boi.isUnwrappedCapable()) {
wrap = true;
if (outMsgInfo != null) {
wrapNSUri = getWrappedParamNamespace(outMsgInfo);
if (!CorbaUtils.isElementFormQualified(service, wrapNSUri)) {
wrapNSUri = "";
}
}
}
CorbaStreamWriter writer = (CorbaStreamWriter) message.getContent(XMLStreamWriter.class);
CorbaObjectHandler[] objs = writer.getCorbaObjects();
int count = 0;
int msgIndex = 0;
ArgType returnParam = opType.getReturn();
if (returnParam != null) {
QName retName;
if (wrap) {
retName = new QName(wrapNSUri, returnParam.getName());
} else {
retName = getMessageParamQName(outMsgInfo, returnParam.getName(), msgIndex);
}
QName retIdlType = returnParam.getIdltype();
CorbaObjectHandler obj = CorbaHandlerUtils.initializeObjectHandler(orb, retName, retIdlType, typeMap, service);
CorbaStreamable streamable = message.createStreamableObject(obj, retName);
message.setStreamableReturn(streamable);
msgIndex++;
}
for (Iterator<ParamType> iter = paramTypes.iterator(); iter.hasNext(); ) {
ParamType param = iter.next();
QName idlType = param.getIdltype();
QName paramName;
CorbaObjectHandler obj = null;
if (param.getMode().equals(ModeType.OUT)) {
if (wrap) {
paramName = new QName(wrapNSUri, param.getName());
} else {
paramName = getMessageParamQName(outMsgInfo, param.getName(), msgIndex);
}
obj = CorbaHandlerUtils.initializeObjectHandler(orb, paramName, idlType, typeMap, service);
msgIndex++;
} else {
obj = objs[count++];
paramName = obj.getName();
}
CorbaStreamable streamable = message.createStreamableObject(obj, paramName);
ModeType paramMode = param.getMode();
if (paramMode.value().equals("in")) {
streamable.setMode(org.omg.CORBA.ARG_IN.value);
} else if (paramMode.value().equals("inout")) {
streamable.setMode(org.omg.CORBA.ARG_INOUT.value);
}
// default mode is out
message.addStreamableArgument(streamable);
}
}
use of org.apache.cxf.service.model.OperationInfo in project cxf by apache.
the class ReflectionServiceFactoryTest method testWrappedBuild.
@Test
public void testWrappedBuild() throws Exception {
Service service = createService(true);
ServiceInfo si = service.getServiceInfos().get(0);
InterfaceInfo intf = si.getInterface();
assertEquals(4, intf.getOperations().size());
String ns = si.getName().getNamespaceURI();
OperationInfo sayHelloOp = intf.getOperation(new QName(ns, "sayHello"));
assertNotNull(sayHelloOp);
assertEquals("sayHello", sayHelloOp.getInput().getName().getLocalPart());
List<MessagePartInfo> messageParts = sayHelloOp.getInput().getMessageParts();
assertEquals(1, messageParts.size());
assertNotNull(messageParts.get(0).getXmlSchema());
// test unwrapping
assertTrue(sayHelloOp.isUnwrappedCapable());
OperationInfo unwrappedOp = sayHelloOp.getUnwrappedOperation();
assertEquals("sayHello", unwrappedOp.getInput().getName().getLocalPart());
messageParts = unwrappedOp.getInput().getMessageParts();
assertEquals(0, messageParts.size());
// test output
messageParts = sayHelloOp.getOutput().getMessageParts();
assertEquals(1, messageParts.size());
assertEquals("sayHelloResponse", sayHelloOp.getOutput().getName().getLocalPart());
messageParts = unwrappedOp.getOutput().getMessageParts();
assertEquals("sayHelloResponse", unwrappedOp.getOutput().getName().getLocalPart());
assertEquals(1, messageParts.size());
MessagePartInfo mpi = messageParts.get(0);
assertEquals("return", mpi.getName().getLocalPart());
assertEquals(String.class, mpi.getTypeClass());
}
use of org.apache.cxf.service.model.OperationInfo in project cxf by apache.
the class ServiceJavascriptBuilder method begin.
@Override
public void begin(OperationInfo op) {
if (op.isUnwrapped()) {
isInUnwrappedOperation = true;
return;
}
currentOperation = op;
OperationInfo conflict = localOperationsNameMap.get(op.getName().getLocalPart());
if (conflict != null) {
operationsWithNameConflicts.add(conflict);
operationsWithNameConflicts.add(op);
}
localOperationsNameMap.put(op.getName().getLocalPart(), op);
opFunctionPropertyName = getFunctionPropertyName(operationsWithNameConflicts, op, op.getName());
opFunctionGlobalName = getFunctionGlobalName(op.getName(), "op");
}
use of org.apache.cxf.service.model.OperationInfo in project cxf by apache.
the class JaxWsServiceConfigurationTest method testGetOutPartName.
@Test
public void testGetOutPartName() throws Exception {
QName opName = new QName("http://cxf.com/", "sayHi");
Method sayHiMethod = Hello.class.getMethod("sayHi", new Class[] {});
ServiceInfo si = getMockedServiceModel("/wsdl/default_partname_test.wsdl");
JaxWsServiceConfiguration jwsc = new JaxWsServiceConfiguration();
JaxWsServiceFactoryBean bean = new JaxWsServiceFactoryBean();
bean.setServiceClass(Hello.class);
jwsc.setServiceFactory(bean);
// clear the output
OperationInfo op = si.getInterface().getOperation(opName);
op.setOutput("output", new MessageInfo(op, MessageInfo.Type.OUTPUT, new QName("http://cxf.com/", "output")));
QName partName = jwsc.getOutPartName(op, sayHiMethod, -1);
assertEquals("get wrong return partName", new QName("http://cxf.com/", "return"), partName);
}
use of org.apache.cxf.service.model.OperationInfo in project cxf by apache.
the class JaxWsServiceFactoryBeanTest method testWrappedDocLit.
@Test
public void testWrappedDocLit() throws Exception {
ReflectionServiceFactoryBean bean = new JaxWsServiceFactoryBean();
Bus bus = getBus();
bean.setBus(bus);
bean.setServiceClass(org.apache.hello_world_doc_lit.Greeter.class);
Service service = bean.create();
ServiceInfo si = service.getServiceInfos().get(0);
InterfaceInfo intf = si.getInterface();
assertEquals(4, intf.getOperations().size());
String ns = si.getName().getNamespaceURI();
assertEquals("http://apache.org/hello_world_doc_lit", ns);
OperationInfo greetMeOp = intf.getOperation(new QName(ns, "greetMe"));
assertNotNull(greetMeOp);
assertEquals("greetMe", greetMeOp.getInput().getName().getLocalPart());
assertEquals("http://apache.org/hello_world_doc_lit", greetMeOp.getInput().getName().getNamespaceURI());
List<MessagePartInfo> messageParts = greetMeOp.getInput().getMessageParts();
assertEquals(1, messageParts.size());
MessagePartInfo inMessagePart = messageParts.get(0);
assertEquals("http://apache.org/hello_world_doc_lit", inMessagePart.getName().getNamespaceURI());
assertEquals("http://apache.org/hello_world_doc_lit/types", inMessagePart.getElementQName().getNamespaceURI());
// test output
messageParts = greetMeOp.getOutput().getMessageParts();
assertEquals(1, messageParts.size());
assertEquals("greetMeResponse", greetMeOp.getOutput().getName().getLocalPart());
MessagePartInfo outMessagePart = messageParts.get(0);
// assertEquals("result", outMessagePart.getName().getLocalPart());
assertEquals("http://apache.org/hello_world_doc_lit", outMessagePart.getName().getNamespaceURI());
assertEquals("http://apache.org/hello_world_doc_lit/types", outMessagePart.getElementQName().getNamespaceURI());
OperationInfo greetMeOneWayOp = si.getInterface().getOperation(new QName(ns, "greetMeOneWay"));
assertEquals(1, greetMeOneWayOp.getInput().getMessageParts().size());
assertNull(greetMeOneWayOp.getOutput());
Collection<SchemaInfo> schemas = si.getSchemas();
assertEquals(1, schemas.size());
}
Aggregations