use of org.apache.cxf.endpoint.Endpoint in project camel by apache.
the class WSDLServiceFactoryBean method createEndpoint.
public Endpoint createEndpoint(EndpointInfo ei) throws EndpointException {
Endpoint ep = new EndpointImpl(getBus(), getService(), ei);
sendEvent(Event.ENDPOINT_CREATED, ei, ep, getServiceClass());
return ep;
}
use of org.apache.cxf.endpoint.Endpoint in project camel by apache.
the class RawMessageWSDLGetInterceptor method handleMessage.
public void handleMessage(Message message) throws Fault {
String method = (String) message.get(Message.HTTP_REQUEST_METHOD);
String query = (String) message.get(Message.QUERY_STRING);
if (!"GET".equals(method) || StringUtils.isEmpty(query)) {
return;
}
String baseUri = (String) message.get(Message.REQUEST_URL);
String ctx = (String) message.get(Message.PATH_INFO);
Map<String, String> map = UrlUtils.parseQueryString(query);
if (isRecognizedQuery(map, baseUri, ctx, message.getExchange().getEndpoint().getEndpointInfo())) {
Document doc = getDocument(message, baseUri, map, ctx);
Endpoint e = message.getExchange().get(Endpoint.class);
Message mout = new MessageImpl();
mout.setExchange(message.getExchange());
mout = e.getBinding().createMessage(mout);
mout.setInterceptorChain(OutgoingChainInterceptor.getOutInterceptorChain(message.getExchange()));
message.getExchange().setOutMessage(mout);
mout.put(DOCUMENT_HOLDER, doc);
Iterator<Interceptor<? extends Message>> iterator = mout.getInterceptorChain().iterator();
while (iterator.hasNext()) {
Interceptor<? extends Message> inInterceptor = iterator.next();
if (inInterceptor instanceof AbstractPhaseInterceptor) {
AbstractPhaseInterceptor<?> interceptor = (AbstractPhaseInterceptor<?>) inInterceptor;
if (interceptor.getPhase().equals(Phase.PREPARE_SEND) || interceptor.getPhase().equals(Phase.PRE_STREAM)) {
// just make sure we keep the right interceptors
continue;
}
}
mout.getInterceptorChain().remove(inInterceptor);
}
// notice this is being added after the purge above, don't swap the order!
mout.getInterceptorChain().add(RawMessageWSDLGetOutInterceptor.INSTANCE);
// skip the service executor and goto the end of the chain.
message.getInterceptorChain().doInterceptStartingAt(message, OutgoingChainInterceptor.class.getName());
}
}
use of org.apache.cxf.endpoint.Endpoint in project camel by apache.
the class DefaultCxfBindingTest method testPopupalteCxfResponseFromExchange.
@Test
public void testPopupalteCxfResponseFromExchange() {
DefaultCxfBinding cxfBinding = new DefaultCxfBinding();
cxfBinding.setHeaderFilterStrategy(new DefaultHeaderFilterStrategy());
Exchange exchange = new DefaultExchange(context, ExchangePattern.InOut);
org.apache.cxf.message.Exchange cxfExchange = new org.apache.cxf.message.ExchangeImpl();
exchange.setProperty(CxfConstants.DATA_FORMAT_PROPERTY, DataFormat.PAYLOAD);
exchange.getOut().setHeader("soapAction", "urn:hello:world");
exchange.getOut().setHeader("MyFruitHeader", "peach");
exchange.getOut().addAttachment("att-1", new DataHandler(new FileDataSource("pom.xml")));
exchange.getOut().getAttachmentObject("att-1").setHeader("attachment-header", "value 1");
IMocksControl control = EasyMock.createNiceControl();
Endpoint endpoint = control.createMock(Endpoint.class);
Binding binding = control.createMock(Binding.class);
EasyMock.expect(endpoint.getBinding()).andReturn(binding);
org.apache.cxf.message.Message cxfMessage = new org.apache.cxf.message.MessageImpl();
EasyMock.expect(binding.createMessage()).andReturn(cxfMessage);
cxfExchange.put(Endpoint.class, endpoint);
control.replay();
cxfBinding.populateCxfResponseFromExchange(exchange, cxfExchange);
cxfMessage = cxfExchange.getOutMessage();
assertNotNull(cxfMessage);
Map<String, List<String>> headers = CastUtils.cast((Map<?, ?>) cxfMessage.get(Message.PROTOCOL_HEADERS));
assertNotNull(headers);
assertTrue(headers.size() == 2);
verifyHeader(headers, "soapaction", "urn:hello:world");
verifyHeader(headers, "SoapAction", "urn:hello:world");
verifyHeader(headers, "SOAPAction", "urn:hello:world");
verifyHeader(headers, "myfruitheader", "peach");
verifyHeader(headers, "myFruitHeader", "peach");
verifyHeader(headers, "MYFRUITHEADER", "peach");
Collection<Attachment> attachments = cxfMessage.getAttachments();
assertNotNull(attachments);
assertNotNull(attachments.size() == 1);
Attachment att = attachments.iterator().next();
assertEquals("att-1", att.getId());
assertEquals("value 1", att.getHeader("attachment-header"));
}
use of org.apache.cxf.endpoint.Endpoint in project midpoint by Evolveum.
the class Action method createModelPort.
protected ModelPortType createModelPort() {
ModelService modelService = new ModelService();
ModelPortType port = modelService.getModelPort();
BindingProvider bp = (BindingProvider) port;
Client client = ClientProxy.getClient(port);
Endpoint endpoint = client.getEndpoint();
HTTPConduit http = (HTTPConduit) client.getConduit();
HTTPClientPolicy httpClientPolicy = http.getClient();
if (httpClientPolicy == null) {
httpClientPolicy = new HTTPClientPolicy();
http.setClient(httpClientPolicy);
}
httpClientPolicy.setConnectionTimeout(10000);
Map<String, Object> requestContext = bp.getRequestContext();
requestContext.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, params.getUrl().toString());
requestContext.put(WSHandlerConstants.ACTION, WSHandlerConstants.USERNAME_TOKEN);
requestContext.put(WSHandlerConstants.USER, params.getUsername());
requestContext.put(WSHandlerConstants.PASSWORD_TYPE, WSConstants.PW_DIGEST);
ClientPasswordHandler handler = new ClientPasswordHandler();
handler.setPassword(params.getInsertedPassword());
requestContext.put(WSHandlerConstants.PW_CALLBACK_REF, handler);
WSS4JOutInterceptor wssOut = new WSS4JOutInterceptor(requestContext);
endpoint.getOutInterceptors().add(wssOut);
if (params.isVerbose()) {
endpoint.getOutInterceptors().add(new LoggingOutInterceptor());
endpoint.getInInterceptors().add(new LoggingInInterceptor());
}
return port;
}
use of org.apache.cxf.endpoint.Endpoint in project tomee by apache.
the class CalculatorTest method testCalculatorViaWsInterfaceWithUsernameTokenPlainPassword.
public void testCalculatorViaWsInterfaceWithUsernameTokenPlainPassword() throws Exception {
final Service calcService = Service.create(new URL("http://localhost:" + port + "/webservice-ws-security/CalculatorImplUsernameTokenPlainPassword?wsdl"), new QName("http://superbiz.org/wsdl", "CalculatorWsService"));
assertNotNull(calcService);
// for debugging (ie. TCPMon)
calcService.addPort(new QName("http://superbiz.org/wsdl", "CalculatorWsService2"), SOAPBinding.SOAP12HTTP_BINDING, "http://127.0.0.1:8204/CalculatorImplUsernameTokenPlainPassword");
// CalculatorWs calc = calcService.getPort(
// new QName("http://superbiz.org/wsdl", "CalculatorWsService2"),
// CalculatorWs.class);
final CalculatorWs calc = calcService.getPort(CalculatorWs.class);
final Client client = ClientProxy.getClient(calc);
final Endpoint endpoint = client.getEndpoint();
endpoint.getOutInterceptors().add(new SAAJOutInterceptor());
final Map<String, Object> outProps = new HashMap<String, Object>();
outProps.put(WSHandlerConstants.ACTION, WSHandlerConstants.USERNAME_TOKEN);
outProps.put(WSHandlerConstants.USER, "jane");
outProps.put(WSHandlerConstants.PASSWORD_TYPE, WSConstants.PW_TEXT);
outProps.put(WSHandlerConstants.PW_CALLBACK_REF, new CallbackHandler() {
@Override
public void handle(final Callback[] callbacks) throws IOException, UnsupportedCallbackException {
final WSPasswordCallback pc = (WSPasswordCallback) callbacks[0];
pc.setPassword("waterfall");
}
});
final WSS4JOutInterceptor wssOut = new WSS4JOutInterceptor(outProps);
endpoint.getOutInterceptors().add(wssOut);
assertEquals(10, calc.sum(4, 6));
}
Aggregations