use of org.apache.cxf.service.model.OperationInfo in project cxf by apache.
the class WSDLServiceBuilder method buildInterfaceOperation.
private void buildInterfaceOperation(InterfaceInfo inf, Operation op) {
OperationInfo opInfo = inf.addOperation(new QName(inf.getName().getNamespaceURI(), op.getName()));
if (recordOriginal) {
opInfo.setProperty(WSDL_OPERATION, op);
}
copyDocumentation(opInfo, op);
List<String> porderList = CastUtils.cast((List<?>) op.getParameterOrdering());
opInfo.setParameterOrdering(porderList);
this.copyExtensors(opInfo, op.getExtensibilityElements());
this.copyExtensionAttributes(opInfo, op);
Input input = op.getInput();
if (input != null) {
if (input.getMessage() == null) {
throw new WSDLRuntimeException(LOG, "NO_MESSAGE", "input", op.getName(), input.getName());
}
MessageInfo minfo = opInfo.createMessage(input.getMessage().getQName(), MessageInfo.Type.INPUT);
opInfo.setInput(input.getName(), minfo);
buildMessage(minfo, input.getMessage());
copyExtensors(minfo, input.getExtensibilityElements());
copyExtensionAttributes(minfo, input);
}
Output output = op.getOutput();
if (output != null) {
if (output.getMessage() == null) {
throw new WSDLRuntimeException(LOG, "NO_MESSAGE", "output", op.getName(), output.getName());
}
MessageInfo minfo = opInfo.createMessage(output.getMessage().getQName(), MessageInfo.Type.OUTPUT);
opInfo.setOutput(output.getName(), minfo);
buildMessage(minfo, output.getMessage());
copyExtensors(minfo, output.getExtensibilityElements());
copyExtensionAttributes(minfo, output);
}
Map<?, ?> m = op.getFaults();
for (Map.Entry<?, ?> rawentry : m.entrySet()) {
Map.Entry<String, Fault> entry = cast(rawentry, String.class, Fault.class);
FaultInfo finfo = opInfo.addFault(new QName(inf.getName().getNamespaceURI(), entry.getKey()), entry.getValue().getMessage().getQName());
copyDocumentation(finfo, entry.getValue());
buildMessage(finfo, entry.getValue().getMessage());
copyExtensors(finfo, entry.getValue().getExtensibilityElements());
copyExtensionAttributes(finfo, entry.getValue());
}
checkForWrapped(opInfo, allowRefs, false, unwrapLogLevel);
}
use of org.apache.cxf.service.model.OperationInfo in project cxf by apache.
the class DocLiteralInInterceptorTest method testUnmarshalSourceDataWrapped.
@Test
public void testUnmarshalSourceDataWrapped() throws Exception {
XMLStreamReader reader = StaxUtils.createXMLStreamReader(getClass().getResourceAsStream("resources/docLitWrappedReq.xml"));
assertEquals(XMLStreamConstants.START_ELEMENT, reader.nextTag());
XMLStreamReader filteredReader = new PartialXMLStreamReader(reader, new QName("http://schemas.xmlsoap.org/soap/envelope/", "Body"));
// advance the xml reader to the message parts
StaxUtils.read(filteredReader);
assertEquals(XMLStreamConstants.START_ELEMENT, reader.nextTag());
Message m = new MessageImpl();
// request to keep the document as wrapped
m.put(DocLiteralInInterceptor.KEEP_PARAMETERS_WRAPPER, true);
Exchange exchange = new ExchangeImpl();
Service service = control.createMock(Service.class);
exchange.put(Service.class, service);
EasyMock.expect(service.getDataBinding()).andReturn(new SourceDataBinding()).anyTimes();
EasyMock.expect(service.size()).andReturn(0).anyTimes();
EasyMock.expect(service.isEmpty()).andReturn(true).anyTimes();
Endpoint endpoint = control.createMock(Endpoint.class);
exchange.put(Endpoint.class, endpoint);
// wrapped
OperationInfo operationInfo = new OperationInfo();
MessageInfo messageInfo = new MessageInfo(operationInfo, Type.INPUT, new QName(NS, "foo"));
messageInfo.addMessagePart(new MessagePartInfo(new QName(NS, "personId"), null));
messageInfo.addMessagePart(new MessagePartInfo(new QName(NS, "ssn"), null));
messageInfo.getMessagePart(0).setConcreteName(new QName(NS, "personId"));
messageInfo.getMessagePart(1).setConcreteName(new QName(NS, "ssn"));
operationInfo.setInput("inputName", messageInfo);
// wrapper
OperationInfo operationInfoWrapper = new OperationInfo();
MessageInfo messageInfoWrapper = new MessageInfo(operationInfo, Type.INPUT, new QName(NS, "foo"));
messageInfoWrapper.addMessagePart(new MessagePartInfo(new QName(NS, "GetPerson"), null));
messageInfoWrapper.getMessagePart(0).setConcreteName(new QName(NS, "GetPerson"));
operationInfoWrapper.setInput("inputName", messageInfoWrapper);
operationInfoWrapper.setUnwrappedOperation(operationInfo);
ServiceInfo serviceInfo = control.createMock(ServiceInfo.class);
EasyMock.expect(serviceInfo.getName()).andReturn(new QName("http://foo.com", "service")).anyTimes();
InterfaceInfo interfaceInfo = control.createMock(InterfaceInfo.class);
EasyMock.expect(serviceInfo.getInterface()).andReturn(interfaceInfo).anyTimes();
EasyMock.expect(interfaceInfo.getName()).andReturn(new QName("http://foo.com", "interface")).anyTimes();
BindingInfo bindingInfo = new BindingInfo(serviceInfo, "");
BindingOperationInfo boi = new BindingOperationInfo(bindingInfo, operationInfoWrapper);
exchange.put(BindingOperationInfo.class, boi);
EndpointInfo endpointInfo = control.createMock(EndpointInfo.class);
BindingInfo binding = control.createMock(BindingInfo.class);
EasyMock.expect(endpoint.getEndpointInfo()).andReturn(endpointInfo).anyTimes();
EasyMock.expect(endpointInfo.getBinding()).andReturn(binding).anyTimes();
EasyMock.expect(binding.getProperties()).andReturn(new HashMap<String, Object>()).anyTimes();
EasyMock.expect(endpointInfo.getProperties()).andReturn(new HashMap<String, Object>()).anyTimes();
EasyMock.expect(endpoint.size()).andReturn(0).anyTimes();
EasyMock.expect(endpoint.isEmpty()).andReturn(true).anyTimes();
EasyMock.expect(endpointInfo.getService()).andReturn(serviceInfo).anyTimes();
EasyMock.expect(endpointInfo.getName()).andReturn(new QName("http://foo.com", "endpoint")).anyTimes();
EasyMock.expect(endpointInfo.getProperty("URI", URI.class)).andReturn(new URI("dummy")).anyTimes();
List<OperationInfo> operations = new ArrayList<>();
EasyMock.expect(interfaceInfo.getOperations()).andReturn(operations).anyTimes();
m.setExchange(exchange);
m.put(Message.SCHEMA_VALIDATION_ENABLED, false);
m.setContent(XMLStreamReader.class, reader);
control.replay();
new DocLiteralInInterceptor().handleMessage(m);
MessageContentsList params = (MessageContentsList) m.getContent(List.class);
// we expect a wrapped document
assertEquals(1, params.size());
Map<String, String> ns = new HashMap<>();
ns.put("ns", NS);
XPathUtils xu = new XPathUtils(ns);
assertEquals("hello", xu.getValueString("//ns:GetPerson/ns:personId", ((DOMSource) params.get(0)).getNode().getFirstChild()));
assertEquals("1234", xu.getValueString("//ns:GetPerson/ns:ssn", ((DOMSource) params.get(0)).getNode().getFirstChild()));
}
use of org.apache.cxf.service.model.OperationInfo in project cxf by apache.
the class WSDLServiceBuilderTest method testExtensions.
@Test
public void testExtensions() throws Exception {
setUpWSDL("hello_world_ext.wsdl", 0);
String ns = "http://apache.org/hello_world_soap_http";
QName pingMeOpName = new QName(ns, "pingMe");
QName greetMeOpName = new QName(ns, "greetMe");
QName faultName = new QName(ns, "pingMeFault");
// portType extensions
InterfaceInfo ii = serviceInfo.getInterface();
assertEquals(2, ii.getExtensionAttributes().size());
assertNotNull(ii.getExtensionAttribute(EXTENSION_ATTR_BOOLEAN));
assertNotNull(ii.getExtensionAttribute(EXTENSION_ATTR_STRING));
assertEquals(1, ii.getExtensors(UnknownExtensibilityElement.class).size());
assertEquals(EXTENSION_ELEM, ii.getExtensor(UnknownExtensibilityElement.class).getElementType());
// portType/operation extensions
OperationInfo oi = ii.getOperation(pingMeOpName);
assertPortTypeOperationExtensions(oi, true);
assertPortTypeOperationExtensions(ii.getOperation(greetMeOpName), false);
// portType/operation/[input|output|fault] extensions
assertPortTypeOperationMessageExtensions(oi, true, true, faultName);
assertPortTypeOperationMessageExtensions(ii.getOperation(greetMeOpName), false, true, null);
// service extensions
assertEquals(1, serviceInfo.getExtensionAttributes().size());
assertNotNull(serviceInfo.getExtensionAttribute(EXTENSION_ATTR_STRING));
assertEquals(1, serviceInfo.getExtensors(UnknownExtensibilityElement.class).size());
assertEquals(EXTENSION_ELEM, serviceInfo.getExtensor(UnknownExtensibilityElement.class).getElementType());
// service/port extensions
EndpointInfo ei = serviceInfo.getEndpoints().iterator().next();
assertEquals(1, ei.getExtensionAttributes().size());
assertNotNull(ei.getExtensionAttribute(EXTENSION_ATTR_STRING));
assertEquals(1, ei.getExtensors(UnknownExtensibilityElement.class).size());
assertEquals(EXTENSION_ELEM, ei.getExtensor(UnknownExtensibilityElement.class).getElementType());
// binding extensions
BindingInfo bi = ei.getBinding();
// REVISIT: bug in wsdl4j?
// getExtensionAttributes on binding element returns an empty map
// assertEquals(1, bi.getExtensionAttributes().size());
// assertNotNull(bi.getExtensionAttribute(EXTENSION_ATTR_STRING));
assertEquals(1, bi.getExtensors(UnknownExtensibilityElement.class).size());
assertEquals(EXTENSION_ELEM, bi.getExtensor(UnknownExtensibilityElement.class).getElementType());
// binding/operation extensions
BindingOperationInfo boi = bi.getOperation(pingMeOpName);
assertBindingOperationExtensions(boi, true);
assertBindingOperationExtensions(bi.getOperation(greetMeOpName), false);
// binding/operation/[input|output|fault] extensions
assertBindingOperationMessageExtensions(boi, true, true, faultName);
assertBindingOperationMessageExtensions(bi.getOperation(greetMeOpName), false, true, null);
control.verify();
}
use of org.apache.cxf.service.model.OperationInfo in project cxf by apache.
the class WSDLServiceBuilderTest method doDiffPortTypeNsImport.
private void doDiffPortTypeNsImport() {
if (serviceInfo.getName().getLocalPart().endsWith("Rpc")) {
String ns = serviceInfo.getInterface().getName().getNamespaceURI();
OperationInfo oi = serviceInfo.getInterface().getOperation(new QName(ns, "NewOperationRpc"));
assertNotNull(oi);
ns = oi.getInput().getName().getNamespaceURI();
MessagePartInfo mpi = oi.getInput().getMessagePart(new QName(ns, "NewOperationRequestRpc"));
assertNotNull(mpi);
} else {
String ns = serviceInfo.getInterface().getName().getNamespaceURI();
OperationInfo oi = serviceInfo.getInterface().getOperation(new QName(ns, "NewOperation"));
assertNotNull(oi);
ns = oi.getInput().getName().getNamespaceURI();
MessagePartInfo mpi = oi.getInput().getMessagePart(new QName(ns, "NewOperationRequest"));
assertNotNull(mpi);
}
}
use of org.apache.cxf.service.model.OperationInfo in project cxf by apache.
the class WSDLServiceBuilderTest method testParameterOrder.
@Test
public void testParameterOrder() throws Exception {
String ns = "http://apache.org/hello_world_xml_http/bare";
setUpWSDL("hello_world_xml_bare.wsdl", 0);
OperationInfo operation = serviceInfo.getInterface().getOperation(new QName(ns, "testTriPart"));
assertNotNull(operation);
List<MessagePartInfo> parts = operation.getInput().getMessageParts();
assertNotNull(parts);
assertEquals(3, parts.size());
assertEquals("in3", parts.get(0).getName().getLocalPart());
assertEquals("in1", parts.get(1).getName().getLocalPart());
assertEquals("in2", parts.get(2).getName().getLocalPart());
List<String> order = operation.getParameterOrdering();
assertNotNull(order);
assertEquals(3, order.size());
assertEquals("in1", order.get(0));
assertEquals("in3", order.get(1));
assertEquals("in2", order.get(2));
parts = operation.getInput().getOrderedParts(order);
assertNotNull(parts);
assertEquals(3, parts.size());
assertEquals("in1", parts.get(0).getName().getLocalPart());
assertEquals("in3", parts.get(1).getName().getLocalPart());
assertEquals("in2", parts.get(2).getName().getLocalPart());
operation = serviceInfo.getInterface().getOperation(new QName(ns, "testTriPartNoOrder"));
assertNotNull(operation);
parts = operation.getInput().getMessageParts();
assertNotNull(parts);
assertEquals(3, parts.size());
assertEquals("in3", parts.get(0).getName().getLocalPart());
assertEquals("in1", parts.get(1).getName().getLocalPart());
assertEquals("in2", parts.get(2).getName().getLocalPart());
control.verify();
}
Aggregations