use of org.apache.cxf.binding.soap.model.SoapBindingInfo in project cxf by apache.
the class ClientFactoryBeanTest method testClientFactoryBean.
@Test
public void testClientFactoryBean() throws Exception {
ClientFactoryBean cfBean = new ClientFactoryBean();
cfBean.setAddress("http://localhost/Hello");
cfBean.setBus(getBus());
cfBean.setServiceClass(HelloService.class);
Client client = cfBean.create();
assertNotNull(client);
Service service = client.getEndpoint().getService();
Map<QName, Endpoint> eps = service.getEndpoints();
assertEquals(1, eps.size());
Endpoint ep = eps.values().iterator().next();
EndpointInfo endpointInfo = ep.getEndpointInfo();
BindingInfo b = endpointInfo.getService().getBindings().iterator().next();
assertTrue(b instanceof SoapBindingInfo);
SoapBindingInfo sb = (SoapBindingInfo) b;
assertEquals("HelloServiceSoapBinding", b.getName().getLocalPart());
assertEquals("document", sb.getStyle());
assertEquals(4, b.getOperations().size());
BindingOperationInfo bop = b.getOperations().iterator().next();
SoapOperationInfo sop = bop.getExtensor(SoapOperationInfo.class);
assertNotNull(sop);
assertEquals("", sop.getAction());
assertEquals("document", sop.getStyle());
}
use of org.apache.cxf.binding.soap.model.SoapBindingInfo in project cxf by apache.
the class DispatchImpl method createPayloadEleOpNameMap.
private Map<String, QName> createPayloadEleOpNameMap(BindingInfo bindingInfo, boolean reverseMapping) {
Map<String, QName> payloadElementMap = new java.util.HashMap<String, QName>();
// assume a document binding style, which is default according to W3C spec on WSDL
String bindingStyle = "document";
// if the bindingInfo is a SOAPBindingInfo instance then we can see if it has a style
if (bindingInfo instanceof SoapBindingInfo) {
String tempStyle = ((SoapBindingInfo) bindingInfo).getStyle();
if (tempStyle != null) {
bindingStyle = tempStyle;
}
}
for (BindingOperationInfo bop : bindingInfo.getOperations()) {
SoapOperationInfo soi = bop.getExtensor(SoapOperationInfo.class);
if (soi != null) {
// operation style overrides binding style, if present
String operationStyle = soi.getStyle() != null ? soi.getStyle() : bindingStyle;
if ("document".equals(operationStyle)) {
// if doc
if (bop.getOperationInfo().getInput() != null && bop.getOperationInfo().getInput().getMessagePartsNumber() > 0) {
QName qn = bop.getOperationInfo().getInput().getMessagePartByIndex(0).getElementQName();
QName op = bop.getOperationInfo().getName();
if (reverseMapping) {
payloadElementMap.put(op.toString(), qn);
} else {
payloadElementMap.put(qn.toString(), op);
}
}
} else if ("rpc".equals(operationStyle)) {
// if rpc
QName op = bop.getOperationInfo().getName();
payloadElementMap.put(op.toString(), op);
}
}
}
return payloadElementMap;
}
use of org.apache.cxf.binding.soap.model.SoapBindingInfo 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.binding.soap.model.SoapBindingInfo in project cxf by apache.
the class AbstractWSDLBasedEndpointFactory method createEndpointInfo.
protected EndpointInfo createEndpointInfo(BindingInfo bindingInfo) throws BusException {
// setup the transport ID for the soap over jms if there is only address information
if (transportId == null && getAddress() != null && getAddress().startsWith("jms:") && !"jms://".equals(getAddress())) {
// Set the transportId to be soap over jms transport
transportId = SoapJMSConstants.SOAP_JMS_SPECIFICIATION_TRANSPORTID;
}
// Get the Service from the ServiceFactory if specified
Service service = serviceFactory.getService();
if (bindingInfo == null) {
// SOAP nonsense
bindingInfo = createBindingInfo();
if (bindingInfo instanceof SoapBindingInfo && (((SoapBindingInfo) bindingInfo).getTransportURI() == null || LocalTransportFactory.TRANSPORT_ID.equals(transportId))) {
((SoapBindingInfo) bindingInfo).setTransportURI(transportId);
transportId = "http://schemas.xmlsoap.org/wsdl/soap/";
}
service.getServiceInfos().get(0).addBinding(bindingInfo);
}
if (transportId == null) {
if (bindingInfo instanceof SoapBindingInfo) {
transportId = ((SoapBindingInfo) bindingInfo).getTransportURI();
}
if (transportId == null && getAddress() != null && getAddress().contains("://")) {
transportId = detectTransportIdFromAddress(getAddress());
}
if (transportId == null) {
transportId = "http://schemas.xmlsoap.org/wsdl/http/";
}
}
setTransportId(transportId);
WSDLEndpointFactory wsdlEndpointFactory = getWSDLEndpointFactory();
EndpointInfo ei;
if (wsdlEndpointFactory != null) {
ei = wsdlEndpointFactory.createEndpointInfo(bus, service.getServiceInfos().get(0), bindingInfo, null);
ei.setTransportId(transportId);
} else {
ei = new EndpointInfo(service.getServiceInfos().get(0), transportId);
}
int count = 1;
while (service.getEndpointInfo(endpointName) != null) {
endpointName = new QName(endpointName.getNamespaceURI(), endpointName.getLocalPart() + count);
count++;
}
ei.setName(endpointName);
ei.setAddress(getAddress());
ei.setBinding(bindingInfo);
if (wsdlEndpointFactory != null) {
wsdlEndpointFactory.createPortExtensors(bus, ei, service);
}
service.getServiceInfos().get(0).addEndpoint(ei);
serviceFactory.sendEvent(FactoryBeanListener.Event.ENDPOINTINFO_CREATED, ei);
return ei;
}
use of org.apache.cxf.binding.soap.model.SoapBindingInfo in project cxf by apache.
the class RMEndpoint method buildBindingInfo.
void buildBindingInfo(ServiceInfo si, ProtocolVariation protocol) {
// explicitly
if (null != applicationEndpoint) {
final QName bindingQName = new QName(protocol.getWSRMNamespace(), BINDING_NAME);
SoapBindingInfo sbi = (SoapBindingInfo) applicationEndpoint.getEndpointInfo().getBinding();
SoapVersion sv = sbi.getSoapVersion();
String bindingId = sbi.getBindingId();
SoapBindingInfo bi = new SoapBindingInfo(si, bindingId, sv);
bi.setName(bindingQName);
BindingOperationInfo boi = null;
RMConstants consts = protocol.getConstants();
boi = bi.buildOperation(consts.getCreateSequenceOperationName(), consts.getCreateSequenceOperationName().getLocalPart(), null);
addAction(boi, consts.getCreateSequenceAction(), consts.getCreateSequenceResponseAction());
bi.addOperation(boi);
boi = bi.buildOperation(consts.getTerminateSequenceOperationName(), consts.getTerminateSequenceOperationName().getLocalPart(), null);
if (RM11Constants.NAMESPACE_URI.equals(protocol.getWSRMNamespace())) {
addAction(boi, consts.getTerminateSequenceAction(), RM11Constants.INSTANCE.getTerminateSequenceResponseAction());
} else {
addAction(boi, consts.getTerminateSequenceAction());
}
bi.addOperation(boi);
boi = bi.buildOperation(consts.getTerminateSequenceAnonymousOperationName(), null, consts.getTerminateSequenceAnonymousOperationName().getLocalPart());
addAction(boi, consts.getTerminateSequenceAction());
bi.addOperation(boi);
boi = bi.buildOperation(consts.getSequenceAckOperationName(), null, null);
addAction(boi, consts.getSequenceAckAction());
bi.addOperation(boi);
boi = bi.buildOperation(consts.getCloseSequenceOperationName(), null, null);
if (RM11Constants.NAMESPACE_URI.equals(protocol.getWSRMNamespace())) {
addAction(boi, consts.getCloseSequenceAction(), RM11Constants.INSTANCE.getCloseSequenceResponseAction());
} else {
addAction(boi, consts.getCloseSequenceAction());
}
bi.addOperation(boi);
boi = bi.buildOperation(consts.getAckRequestedOperationName(), null, null);
addAction(boi, consts.getAckRequestedAction());
bi.addOperation(boi);
boi = bi.buildOperation(consts.getCreateSequenceOnewayOperationName(), consts.getCreateSequenceOnewayOperationName().getLocalPart(), null);
addAction(boi, consts.getCreateSequenceAction());
bi.addOperation(boi);
boi = bi.buildOperation(consts.getCreateSequenceResponseOnewayOperationName(), consts.getCreateSequenceResponseOnewayOperationName().getLocalPart(), null);
addAction(boi, consts.getCreateSequenceResponseAction());
bi.addOperation(boi);
si.addBinding(bi);
}
// TODO: BindingFaultInfo (SequenceFault)
}
Aggregations