use of org.apache.cxf.service.model.InterfaceInfo in project cxf by apache.
the class JAXWSFrontEndProcessor method serviceInfo2JavaInf.
public JavaInterface serviceInfo2JavaInf(ServiceInfo service) {
JavaInterface javaInf = new JavaInterface();
InterfaceInfo inf = service.getInterface();
for (OperationInfo op : inf.getOperations()) {
JavaMethod jm = new JavaMethod();
Method m = (Method) op.getProperty(ReflectionServiceFactoryBean.METHOD);
jm.setName(m.getName());
int i = 0;
for (Type type : m.getGenericParameterTypes()) {
JavaParameter jp = new JavaParameter();
jp.setClassName(getClassName(type));
jp.setStyle(Style.IN);
jp.setName("arg" + i++);
jm.addParameter(jp);
}
for (Type type : m.getGenericExceptionTypes()) {
JavaException jex = new JavaException();
String className = getClassName(type);
jex.setClassName(className);
jex.setName(className);
jm.addException(jex);
}
JavaReturn jreturn = new JavaReturn();
jreturn.setClassName(getClassName(m.getGenericReturnType()));
jreturn.setStyle(Style.OUT);
jm.setReturn(jreturn);
String pkg = PackageUtils.getPackageName(m.getDeclaringClass());
javaInf.setPackageName(pkg.length() > 0 ? pkg : ToolConstants.DEFAULT_PACKAGE_NAME);
javaInf.addMethod(jm);
javaInf.setName(inf.getName().getLocalPart());
jm.getParameterList();
}
return javaInf;
}
use of org.apache.cxf.service.model.InterfaceInfo in project cxf by apache.
the class STSUtils method createSTSEndpoint.
// CHECKSTYLE:OFF
private static Endpoint createSTSEndpoint(Bus bus, String namespace, String transportId, String location, String soapVersion, Policy policy, QName epName, boolean sc) throws BusException, EndpointException {
// CHECKSTYLE:ON
Service service = null;
String ns = namespace + "/wsdl";
ServiceInfo si = new ServiceInfo();
QName iName = new QName(ns, sc ? "SecureConversationTokenService" : "SecurityTokenService");
si.setName(iName);
InterfaceInfo ii = new InterfaceInfo(si, iName);
OperationInfo ioi = addIssueOperation(ii, namespace, ns);
OperationInfo coi = addCancelOperation(ii, namespace, ns);
OperationInfo roi = addRenewOperation(ii, namespace, ns);
si.setInterface(ii);
service = new ServiceImpl(si);
BindingFactoryManager bfm = bus.getExtension(BindingFactoryManager.class);
BindingFactory bindingFactory = bfm.getBindingFactory(soapVersion);
BindingInfo bi = bindingFactory.createBindingInfo(service, soapVersion, null);
si.addBinding(bi);
if (transportId == null) {
ConduitInitiatorManager cim = bus.getExtension(ConduitInitiatorManager.class);
ConduitInitiator ci = cim.getConduitInitiatorForUri(location);
transportId = ci.getTransportIds().get(0);
}
EndpointInfo ei = new EndpointInfo(si, transportId);
ei.setBinding(bi);
ei.setName(epName == null ? iName : epName);
ei.setAddress(location);
si.addEndpoint(ei);
if (policy != null) {
ei.addExtensor(policy);
}
BindingOperationInfo boi = bi.getOperation(ioi);
SoapOperationInfo soi = boi.getExtensor(SoapOperationInfo.class);
if (soi == null) {
soi = new SoapOperationInfo();
boi.addExtensor(soi);
}
soi.setAction(namespace + (sc ? "/RST/SCT" : "/RST/Issue"));
boi = bi.getOperation(coi);
soi = boi.getExtensor(SoapOperationInfo.class);
if (soi == null) {
soi = new SoapOperationInfo();
boi.addExtensor(soi);
}
soi.setAction(namespace + (sc ? "/RST/SCT/Cancel" : "/RST/Cancel"));
boi = bi.getOperation(roi);
soi = boi.getExtensor(SoapOperationInfo.class);
if (soi == null) {
soi = new SoapOperationInfo();
boi.addExtensor(soi);
}
soi.setAction(namespace + (sc ? "/RST/SCT/Renew" : "/RST/Renew"));
service.setDataBinding(new SourceDataBinding());
return new EndpointImpl(bus, service, ei);
}
use of org.apache.cxf.service.model.InterfaceInfo in project cxf by apache.
the class WSDLServiceBuilder method buildInterface.
public void buildInterface(ServiceInfo si, PortType p) {
InterfaceInfo inf = si.createInterface(p.getQName());
DescriptionInfo d = si.getDescription();
if (null != d) {
d.getDescribed().add(inf);
}
copyDocumentation(inf, p);
this.copyExtensors(inf, p.getExtensibilityElements());
this.copyExtensionAttributes(inf, p);
if (recordOriginal) {
inf.setProperty(WSDL_PORTTYPE, p);
}
for (Operation op : cast(p.getOperations(), Operation.class)) {
buildInterfaceOperation(inf, op);
}
}
use of org.apache.cxf.service.model.InterfaceInfo 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.InterfaceInfo 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();
}
Aggregations