use of org.apache.cxf.service.model.InterfaceInfo in project cxf by apache.
the class ProviderServiceFactoryTest method testSAAJProviderCodeFirst.
@Test
public void testSAAJProviderCodeFirst() throws Exception {
JaxWsServiceFactoryBean bean = new JaxWsServiceFactoryBean();
bean.setServiceClass(SAAJProvider.class);
bean.setBus(getBus());
bean.setInvoker(new JAXWSMethodInvoker(new SAAJProvider()));
Service service = bean.create();
assertEquals("SAAJProviderService", service.getName().getLocalPart());
InterfaceInfo intf = service.getServiceInfos().get(0).getInterface();
assertNotNull(intf);
assertEquals(1, intf.getOperations().size());
JaxWsServerFactoryBean svrFactory = new JaxWsServerFactoryBean();
svrFactory.setBus(getBus());
svrFactory.setServiceFactory(bean);
String address = "local://localhost:9000/test";
svrFactory.setAddress(address);
ServerImpl server = (ServerImpl) svrFactory.create();
Endpoint endpoint = server.getEndpoint();
Binding binding = endpoint.getBinding();
assertTrue(binding instanceof SoapBinding);
SoapBindingInfo sb = (SoapBindingInfo) endpoint.getEndpointInfo().getBinding();
assertEquals("document", sb.getStyle());
assertEquals(false, bean.isWrapped());
assertEquals(1, sb.getOperations().size());
Node res = invoke(address, LocalTransportFactory.TRANSPORT_ID, "/org/apache/cxf/jaxws/sayHi.xml");
addNamespace("j", "http://service.jaxws.cxf.apache.org/");
assertValid("/s:Envelope/s:Body/j:sayHi", res);
}
use of org.apache.cxf.service.model.InterfaceInfo in project cxf by apache.
the class JaxWsServiceFactoryBeanTest method testEndpoint.
@Test
public void testEndpoint() throws Exception {
ReflectionServiceFactoryBean bean = new JaxWsServiceFactoryBean();
URL resource = getClass().getResource("/wsdl/hello_world.wsdl");
assertNotNull(resource);
bean.setWsdlURL(resource.toString());
Bus bus = getBus();
bean.setBus(bus);
bean.setServiceClass(GreeterImpl.class);
BeanInvoker invoker = new BeanInvoker(new GreeterImpl());
bean.setInvoker(invoker);
Service service = bean.create();
String ns = "http://apache.org/hello_world_soap_http";
assertEquals("SOAPService", service.getName().getLocalPart());
assertEquals(ns, service.getName().getNamespaceURI());
InterfaceInfo intf = service.getServiceInfos().get(0).getInterface();
OperationInfo op = intf.getOperation(new QName(ns, "sayHi"));
Class<?> wrapper = op.getInput().getMessageParts().get(0).getTypeClass();
assertNotNull(wrapper);
wrapper = op.getOutput().getMessageParts().get(0).getTypeClass();
assertNotNull(wrapper);
assertEquals(invoker, service.getInvoker());
op = intf.getOperation(new QName(ns, "testDocLitFault"));
Collection<FaultInfo> faults = op.getFaults();
assertEquals(2, faults.size());
FaultInfo f = op.getFault(new QName(ns, "BadRecordLitFault"));
assertNotNull(f);
Class<?> c = f.getProperty(Class.class.getName(), Class.class);
assertNotNull(c);
assertEquals(1, f.getMessageParts().size());
MessagePartInfo mpi = f.getMessagePartByIndex(0);
assertNotNull(mpi.getTypeClass());
}
use of org.apache.cxf.service.model.InterfaceInfo in project cxf by apache.
the class JaxWsServiceFactoryBeanTest method testHolder.
@Test
public void testHolder() throws Exception {
ReflectionServiceFactoryBean bean = new JaxWsServiceFactoryBean();
Bus bus = getBus();
bean.setBus(bus);
bean.setServiceClass(TestMtomImpl.class);
Service service = bean.create();
InterfaceInfo intf = service.getServiceInfos().get(0).getInterface();
OperationInfo op = intf.getOperation(new QName("http://cxf.apache.org/mime", "testXop"));
assertNotNull(op);
Iterator<MessagePartInfo> itr = op.getInput().getMessageParts().iterator();
assertTrue(itr.hasNext());
MessagePartInfo part = itr.next();
assertEquals("testXop", part.getElementQName().getLocalPart());
op = op.getUnwrappedOperation();
assertNotNull(op);
// test setup of input parts
itr = op.getInput().getMessageParts().iterator();
assertTrue(itr.hasNext());
part = itr.next();
assertEquals("name", part.getName().getLocalPart());
assertEquals(String.class, part.getTypeClass());
/*
* revisit, try to use other wsdl operation rewrite test in future
assertTrue(itr.hasNext());
part = itr.next();
assertEquals(Boolean.TRUE, part.getProperty(JaxWsServiceFactoryBean.MODE_INOUT));
assertEquals(byte[].class, part.getTypeClass());
assertFalse(itr.hasNext());
// test output setup
itr = op.getOutput().getMessageParts().iterator();
assertTrue(itr.hasNext());
part = itr.next();
assertEquals(Boolean.TRUE, part.getProperty(JaxWsServiceFactoryBean.MODE_INOUT));
*/
}
use of org.apache.cxf.service.model.InterfaceInfo in project cxf by apache.
the class Proxy method createSequence.
public CreateSequenceResponseType createSequence(EndpointReferenceType defaultAcksTo, RelatesToType relatesTo, boolean isServer, final ProtocolVariation protocol, final Exchange exchange, Map<String, Object> context) throws RMException {
this.sequenceContext = context;
SourcePolicyType sp = reliableEndpoint.getManager().getSourcePolicy();
CreateSequenceType create = new CreateSequenceType();
String address = sp.getAcksTo();
EndpointReferenceType acksTo = null;
if (null != address) {
acksTo = RMUtils.createReference(address);
} else {
acksTo = defaultAcksTo;
}
create.setAcksTo(acksTo);
Duration d = sp.getSequenceExpiration();
if (null != d) {
Expires expires = new Expires();
expires.setValue(d);
create.setExpires(expires);
}
if (sp.isIncludeOffer()) {
OfferType offer = new OfferType();
d = sp.getOfferedSequenceExpiration();
if (null != d) {
Expires expires = new Expires();
expires.setValue(d);
offer.setExpires(expires);
}
offer.setIdentifier(reliableEndpoint.getSource().generateSequenceIdentifier());
offer.setEndpoint(acksTo);
create.setOffer(offer);
setOfferedIdentifier(offer);
}
InterfaceInfo ii = reliableEndpoint.getEndpoint(protocol).getEndpointInfo().getService().getInterface();
EncoderDecoder codec = protocol.getCodec();
RMConstants constants = codec.getConstants();
final OperationInfo oi = isServer ? ii.getOperation(constants.getCreateSequenceOnewayOperationName()) : ii.getOperation(constants.getCreateSequenceOperationName());
final Object send = codec.convertToSend(create);
if (isServer) {
LOG.fine("sending CreateSequenceRequest from server side");
Runnable r = new Runnable() {
public void run() {
try {
invoke(oi, protocol, new Object[] { send }, null, exchange);
} catch (RMException ex) {
// already logged
}
}
};
Executor ex = reliableEndpoint.getApplicationEndpoint().getExecutor();
if (ex == null) {
ex = SynchronousExecutor.getInstance();
}
ex.execute(r);
return null;
}
Object resp = invoke(oi, protocol, new Object[] { send }, context, exchange);
return codec.convertReceivedCreateSequenceResponse(resp);
}
use of org.apache.cxf.service.model.InterfaceInfo in project cxf by apache.
the class MAPAggregatorTest method testGetReplyToUsingBaseAddress.
@Test
public void testGetReplyToUsingBaseAddress() throws Exception {
Message message = new MessageImpl();
Exchange exchange = new ExchangeImpl();
message.setExchange(exchange);
final String localReplyTo = "/SoapContext/decoupled";
final String decoupledEndpointBase = "http://localhost:8181/cxf";
final String replyTo = decoupledEndpointBase + localReplyTo;
ServiceInfo s = new ServiceInfo();
Service svc = new ServiceImpl(s);
EndpointInfo ei = new EndpointInfo();
InterfaceInfo ii = s.createInterface(new QName("FooInterface"));
s.setInterface(ii);
ii.addOperation(new QName("fooOp"));
SoapBindingInfo b = new SoapBindingInfo(s, "http://schemas.xmlsoap.org/soap/", Soap11.getInstance());
b.setTransportURI("http://schemas.xmlsoap.org/soap/http");
ei.setBinding(b);
ei.setAddress("http://nowhere.com/bar/foo");
ei.setName(new QName("http://nowhere.com/port", "foo"));
Bus bus = new ExtensionManagerBus();
DestinationFactoryManager dfm = control.createMock(DestinationFactoryManager.class);
DestinationFactory df = control.createMock(DestinationFactory.class);
Destination d = control.createMock(Destination.class);
bus.setExtension(dfm, DestinationFactoryManager.class);
EasyMock.expect(dfm.getDestinationFactoryForUri(localReplyTo)).andReturn(df);
EasyMock.expect(df.getDestination(EasyMock.anyObject(EndpointInfo.class), EasyMock.anyObject(Bus.class))).andReturn(d);
EasyMock.expect(d.getAddress()).andReturn(EndpointReferenceUtils.getEndpointReference(localReplyTo));
Endpoint ep = new EndpointImpl(bus, svc, ei);
exchange.put(Endpoint.class, ep);
exchange.put(Bus.class, bus);
exchange.setOutMessage(message);
setUpMessageProperty(message, REQUESTOR_ROLE, Boolean.TRUE);
message.getContextualProperty(WSAContextUtils.REPLYTO_PROPERTY);
message.put(WSAContextUtils.REPLYTO_PROPERTY, localReplyTo);
message.put(WSAContextUtils.DECOUPLED_ENDPOINT_BASE_PROPERTY, decoupledEndpointBase);
AddressingProperties maps = new AddressingProperties();
AttributedURIType id = ContextUtils.getAttributedURI("urn:uuid:12345");
maps.setMessageID(id);
maps.setAction(ContextUtils.getAttributedURI(""));
setUpMessageProperty(message, CLIENT_ADDRESSING_PROPERTIES, maps);
control.replay();
aggregator.mediate(message, false);
AddressingProperties props = (AddressingProperties) message.get(JAXWSAConstants.ADDRESSING_PROPERTIES_OUTBOUND);
assertEquals(replyTo, props.getReplyTo().getAddress().getValue());
control.verify();
}
Aggregations