use of org.apache.cxf.binding.soap.model.SoapBindingInfo 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();
}
use of org.apache.cxf.binding.soap.model.SoapBindingInfo in project cxf by apache.
the class ManagedRMManagerTest method createTestEndpoint.
private Endpoint createTestEndpoint() throws Exception {
ServiceInfo svci = new ServiceInfo();
svci.setName(new QName(TEST_URI, "testService"));
Service svc = new ServiceImpl(svci);
SoapBindingInfo binding = new SoapBindingInfo(svci, WSDLConstants.NS_SOAP11);
binding.setTransportURI(WSDLConstants.NS_SOAP_HTTP_TRANSPORT);
EndpointInfo ei = new EndpointInfo();
ei.setAddress(TEST_URI);
ei.setName(new QName(TEST_URI, "testPort"));
ei.setBinding(binding);
ei.setService(svci);
return new EndpointImpl(bus, svc, ei);
}
use of org.apache.cxf.binding.soap.model.SoapBindingInfo in project cxf by apache.
the class SoapBindingFactoryTest method testSoap12Factory.
@Test
public void testSoap12Factory() throws Exception {
Definition d = createDefinition("/wsdl_soap/hello_world_soap12.wsdl");
Bus bus = getMockBus();
BindingFactoryManager bfm = getBindingFactoryManager(WSDLConstants.NS_SOAP12, bus);
expect(bus.getExtension(BindingFactoryManager.class)).andReturn(bfm);
DestinationFactoryManager dfm = control.createMock(DestinationFactoryManager.class);
expect(bus.getExtension(DestinationFactoryManager.class)).andStubReturn(dfm);
control.replay();
WSDLServiceBuilder builder = new WSDLServiceBuilder(bus);
ServiceInfo serviceInfo = builder.buildServices(d, new QName("http://apache.org/hello_world_soap12_http", "SOAPService")).get(0);
BindingInfo bi = serviceInfo.getBindings().iterator().next();
assertTrue(bi instanceof SoapBindingInfo);
SoapBindingInfo sbi = (SoapBindingInfo) bi;
assertEquals("document", sbi.getStyle());
assertEquals(WSDLConstants.NS_SOAP_HTTP_TRANSPORT, sbi.getTransportURI());
assertTrue(sbi.getSoapVersion() instanceof Soap12);
BindingOperationInfo boi = sbi.getOperation(new QName("http://apache.org/hello_world_soap12_http", "sayHi"));
SoapOperationInfo sboi = boi.getExtensor(SoapOperationInfo.class);
assertNotNull(sboi);
assertEquals("document", sboi.getStyle());
assertEquals("sayHiAction", sboi.getAction());
BindingMessageInfo input = boi.getInput();
SoapBodyInfo bodyInfo = input.getExtensor(SoapBodyInfo.class);
assertEquals("literal", bodyInfo.getUse());
List<MessagePartInfo> parts = bodyInfo.getParts();
assertNotNull(parts);
assertEquals(1, parts.size());
boi = sbi.getOperation(new QName("http://apache.org/hello_world_soap12_http", "pingMe"));
sboi = boi.getExtensor(SoapOperationInfo.class);
assertNotNull(sboi);
assertEquals("document", sboi.getStyle());
assertEquals("", sboi.getAction());
Collection<BindingFaultInfo> faults = boi.getFaults();
assertEquals(1, faults.size());
BindingFaultInfo faultInfo = boi.getFault(new QName("http://apache.org/hello_world_soap12_http", "pingMeFault"));
assertNotNull(faultInfo);
}
use of org.apache.cxf.binding.soap.model.SoapBindingInfo in project cxf by apache.
the class SoapBindingFactoryTest method testNoBodyParts.
@Test
public void testNoBodyParts() throws Exception {
Definition d = createDefinition("/wsdl_soap/no_body_parts.wsdl");
Bus bus = getMockBus();
BindingFactoryManager bfm = getBindingFactoryManager(WSDLConstants.NS_SOAP11, bus);
bus.getExtension(BindingFactoryManager.class);
expectLastCall().andReturn(bfm).anyTimes();
DestinationFactoryManager dfm = control.createMock(DestinationFactoryManager.class);
expect(bus.getExtension(DestinationFactoryManager.class)).andStubReturn(dfm);
control.replay();
WSDLServiceBuilder builder = new WSDLServiceBuilder(bus);
ServiceInfo serviceInfo = builder.buildServices(d, new QName("urn:org:apache:cxf:no_body_parts/wsdl", "NoBodyParts")).get(0);
BindingInfo bi = serviceInfo.getBindings().iterator().next();
assertTrue(bi instanceof SoapBindingInfo);
SoapBindingInfo sbi = (SoapBindingInfo) bi;
assertEquals("document", sbi.getStyle());
assertTrue(WSDLConstants.NS_SOAP11_HTTP_TRANSPORT.equalsIgnoreCase(sbi.getTransportURI()));
assertTrue(sbi.getSoapVersion() instanceof Soap11);
BindingOperationInfo boi = sbi.getOperation(new QName("urn:org:apache:cxf:no_body_parts/wsdl", "operation1"));
assertNotNull(boi);
SoapOperationInfo sboi = boi.getExtensor(SoapOperationInfo.class);
assertNotNull(sboi);
assertNull(sboi.getStyle());
assertEquals("", sboi.getAction());
BindingMessageInfo input = boi.getInput();
SoapBodyInfo bodyInfo = input.getExtensor(SoapBodyInfo.class);
assertNull(bodyInfo.getUse());
List<MessagePartInfo> parts = bodyInfo.getParts();
assertNotNull(parts);
assertEquals(0, parts.size());
}
use of org.apache.cxf.binding.soap.model.SoapBindingInfo in project cxf by apache.
the class SoapBindingFactory method createBindingInfo.
public BindingInfo createBindingInfo(ServiceInfo si, String bindingid, Object conf) {
SoapBindingConfiguration config;
if (conf instanceof SoapBindingConfiguration) {
config = (SoapBindingConfiguration) conf;
} else {
config = new SoapBindingConfiguration();
}
if (WSDLConstants.NS_SOAP12.equals(bindingid) || WSDLConstants.NS_SOAP12_HTTP_BINDING.equals(bindingid)) {
config.setVersion(Soap12.getInstance());
config.setTransportURI(WSDLConstants.NS_SOAP_HTTP_TRANSPORT);
}
SoapBindingInfo info = new SoapBindingInfo(si, bindingid, config.getVersion());
info.setName(config.getBindingName(si));
info.setStyle(config.getStyle());
info.setTransportURI(config.getTransportURI());
if (config.isMtomEnabled()) {
info.setProperty(Message.MTOM_ENABLED, Boolean.TRUE);
}
for (OperationInfo op : si.getInterface().getOperations()) {
SoapOperationInfo sop = new SoapOperationInfo();
sop.setAction(config.getSoapAction(op));
sop.setStyle(config.getStyle(op));
BindingOperationInfo bop = info.buildOperation(op.getName(), op.getInputName(), op.getOutputName());
bop.addExtensor(sop);
info.addOperation(bop);
BindingMessageInfo bInput = bop.getInput();
if (bInput != null) {
MessageInfo input = null;
BindingMessageInfo unwrappedMsg = bInput;
if (bop.isUnwrappedCapable()) {
input = bop.getOperationInfo().getUnwrappedOperation().getInput();
unwrappedMsg = bop.getUnwrappedOperation().getInput();
} else {
input = bop.getOperationInfo().getInput();
}
setupHeaders(bop, bInput, unwrappedMsg, input, config);
}
BindingMessageInfo bOutput = bop.getOutput();
if (bOutput != null) {
MessageInfo output = null;
BindingMessageInfo unwrappedMsg = bOutput;
if (bop.isUnwrappedCapable()) {
output = bop.getOperationInfo().getUnwrappedOperation().getOutput();
unwrappedMsg = bop.getUnwrappedOperation().getOutput();
} else {
output = bop.getOperationInfo().getOutput();
}
setupHeaders(bop, bOutput, unwrappedMsg, output, config);
}
}
try {
createSoapBinding(info);
} catch (WSDLException e) {
e.printStackTrace();
}
return info;
}
Aggregations