use of org.apache.cxf.binding.soap.model.SoapBindingInfo in project cxf by apache.
the class ProviderServiceFactoryTest method testSOAPBindingFromCode.
@Test
public void testSOAPBindingFromCode() throws Exception {
JaxWsServiceFactoryBean bean = new JaxWsServiceFactoryBean();
bean.setServiceClass(SOAPSourcePayloadProvider.class);
bean.setBus(getBus());
bean.setInvoker(new JAXWSMethodInvoker(new SOAPSourcePayloadProvider()));
Service service = bean.create();
assertEquals("SOAPSourcePayloadProviderService", 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();
// See if our endpoint was created correctly
assertEquals(1, service.getServiceInfos().get(0).getEndpoints().size());
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 ReflectionServiceFactoryTest method testServerFactoryBean.
@Test
public void testServerFactoryBean() throws Exception {
Service service = createService(true);
assertEquals("test", service.get("test"));
ServerFactoryBean svrBean = new ServerFactoryBean();
svrBean.setAddress("http://localhost/Hello");
svrBean.setServiceFactory(serviceFactory);
svrBean.setServiceBean(new HelloServiceImpl());
svrBean.setBus(getBus());
Map<String, Object> props = new HashMap<>();
props.put("test", "test");
serviceFactory.setProperties(props);
svrBean.setProperties(props);
Server server = svrBean.create();
assertNotNull(server);
Map<QName, Endpoint> eps = service.getEndpoints();
assertEquals(1, eps.size());
Endpoint ep = eps.values().iterator().next();
EndpointInfo endpointInfo = ep.getEndpointInfo();
assertEquals("test", ep.get("test"));
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 ServiceJavascriptBuilder method begin.
@Override
public void begin(ServiceInfo service) {
code.append("//\n");
code.append("// Definitions for service: " + service.getName().toString() + "\n");
code.append("//\n");
BindingInfo xml = null;
// one for each.
for (BindingInfo bindingInfo : service.getBindings()) {
// there is a JIRA about the confusion / profusion of URLS here.
if (SoapBindingConstants.SOAP11_BINDING_ID.equals(bindingInfo.getBindingId()) || SoapBindingConstants.SOAP12_BINDING_ID.equals(bindingInfo.getBindingId()) || SoapBindingFactory.SOAP_11_BINDING.equals(bindingInfo.getBindingId()) || SoapBindingFactory.SOAP_12_BINDING.equals(bindingInfo.getBindingId())) {
SoapBindingInfo sbi = (SoapBindingInfo) bindingInfo;
if (WSDLConstants.NS_SOAP11_HTTP_TRANSPORT.equals(sbi.getTransportURI()) || WSDLConstants.NS_SOAP12_HTTP_BINDING.equals(sbi.getTransportURI()) || // we do NOT want a dependency on the local transport.
"http://cxf.apache.org/transports/local".equals(sbi.getTransportURI())) {
soapBindingInfo = sbi;
break;
}
} else if (WSDLConstants.NS_BINDING_XML.equals(bindingInfo.getBindingId())) {
xml = bindingInfo;
}
}
// For now, we use soap if its available, and XML if it isn't.\
if (soapBindingInfo == null && xml == null) {
unsupportedConstruct("NO_USABLE_BINDING", service.getName());
}
if (soapBindingInfo != null) {
isRPC = WSDLConstants.RPC.equals(soapBindingInfo.getStyle());
} else if (xml != null) {
xmlBindingInfo = xml;
}
}
use of org.apache.cxf.binding.soap.model.SoapBindingInfo in project cxf by apache.
the class PolicyBasedWSS4JStaxInInterceptor method createPolicyEnforcer.
private PolicyEnforcer createPolicyEnforcer(EndpointInfo endpointInfo, SoapMessage msg) throws WSSPolicyException {
EffectivePolicy dispatchPolicy = null;
List<OperationPolicy> operationPolicies = new ArrayList<>();
Collection<BindingOperationInfo> bindingOperationInfos = endpointInfo.getBinding().getOperations();
for (Iterator<BindingOperationInfo> bindingOperationInfoIterator = bindingOperationInfos.iterator(); bindingOperationInfoIterator.hasNext(); ) {
BindingOperationInfo bindingOperationInfo = bindingOperationInfoIterator.next();
QName operationName = bindingOperationInfo.getName();
// todo: I'm not sure what the effectivePolicy exactly contains,
// a) only the operation policy,
// or b) all policies for the service,
// or c) all policies which applies for the current operation.
// c) is that what we need for stax.
EffectivePolicy policy = (EffectivePolicy) bindingOperationInfo.getProperty("policy-engine-info-serve-request");
// PolicyEngineImpl.POLICY_INFO_REQUEST_SERVER);
if (MessageUtils.isRequestor(msg)) {
policy = (EffectivePolicy) bindingOperationInfo.getProperty("policy-engine-info-client-response");
// Save the Dispatch Policy as it may be used on another BindingOperationInfo
if (policy != null && "http://cxf.apache.org/jaxws/dispatch".equals(operationName.getNamespaceURI())) {
dispatchPolicy = policy;
}
if (bindingOperationInfo.getOutput() != null) {
MessageInfo messageInfo = bindingOperationInfo.getOutput().getMessageInfo();
operationName = messageInfo.getName();
if (messageInfo.getMessagePartsNumber() > 0) {
QName cn = messageInfo.getFirstMessagePart().getConcreteName();
if (cn != null) {
operationName = cn;
}
}
}
} else {
if (bindingOperationInfo.getInput() != null) {
MessageInfo messageInfo = bindingOperationInfo.getInput().getMessageInfo();
operationName = messageInfo.getName();
if (messageInfo.getMessagePartsNumber() > 0) {
QName cn = messageInfo.getFirstMessagePart().getConcreteName();
if (cn != null) {
operationName = cn;
}
}
}
}
SoapOperationInfo soapOperationInfo = bindingOperationInfo.getExtensor(SoapOperationInfo.class);
if (soapOperationInfo != null && policy == null && dispatchPolicy != null) {
policy = dispatchPolicy;
}
if (policy != null && soapOperationInfo != null) {
String soapNS;
BindingInfo bindingInfo = bindingOperationInfo.getBinding();
if (bindingInfo instanceof SoapBindingInfo) {
soapNS = ((SoapBindingInfo) bindingInfo).getSoapVersion().getNamespace();
} else {
// most probably throw an exception:
throw new IllegalArgumentException("BindingInfo is not an instance of SoapBindingInfo");
}
OperationPolicy operationPolicy = new OperationPolicy(operationName);
operationPolicy.setPolicy(policy.getPolicy());
operationPolicy.setOperationAction(soapOperationInfo.getAction());
operationPolicy.setSoapMessageVersionNamespace(soapNS);
operationPolicies.add(operationPolicy);
}
}
String soapAction = SoapActionInInterceptor.getSoapAction(msg);
if (soapAction == null) {
soapAction = "";
}
String actor = (String) msg.getContextualProperty(SecurityConstants.ACTOR);
final Collection<org.apache.cxf.message.Attachment> attachments = msg.getAttachments();
int attachmentCount = 0;
if (attachments != null && !attachments.isEmpty()) {
attachmentCount = attachments.size();
}
return new PolicyEnforcer(operationPolicies, soapAction, isRequestor(msg), actor, attachmentCount, new WSS4JPolicyAsserter(msg.get(AssertionInfoMap.class)));
}
use of org.apache.cxf.binding.soap.model.SoapBindingInfo in project cxf by apache.
the class RMEndpointTest method testCreateEndpoint.
@Test
public void testCreateEndpoint() throws NoSuchMethodException, EndpointException {
Method m = RMEndpoint.class.getDeclaredMethod("getUsingAddressing", new Class[] { EndpointInfo.class });
Service as = control.createMock(Service.class);
EndpointInfo aei = new EndpointInfo();
ae = new EndpointImpl(null, as, aei);
rme = EasyMock.createMockBuilder(RMEndpoint.class).withConstructor(manager, ae).addMockedMethod(m).createMock(control);
rme.setAplicationEndpoint(ae);
rme.setManager(manager);
SoapBindingInfo bi = control.createMock(SoapBindingInfo.class);
aei.setBinding(bi);
SoapVersion sv = Soap11.getInstance();
EasyMock.expect(bi.getSoapVersion()).andReturn(sv);
String ns = "http://schemas.xmlsoap.org/wsdl/soap/";
EasyMock.expect(bi.getBindingId()).andReturn(ns);
aei.setTransportId(ns);
String addr = "addr";
aei.setAddress(addr);
Object ua = new Object();
EasyMock.expect(rme.getUsingAddressing(aei)).andReturn(ua);
control.replay();
rme.createServices();
rme.createEndpoints(null);
Endpoint e = rme.getEndpoint(ProtocolVariation.RM10WSA200408);
WrappedEndpoint we = (WrappedEndpoint) e;
assertSame(ae, we.getWrappedEndpoint());
Service s = rme.getService(ProtocolVariation.RM10WSA200408);
assertEquals(1, s.getEndpoints().size());
assertSame(e, s.getEndpoints().get(RM10Constants.PORT_NAME));
}
Aggregations