Search in sources :

Example 61 with Message

use of org.apache.cxf.message.Message in project jbossws-cxf by jbossws.

the class AnotherEndpointImpl method echo.

@WebMethod
public String echo(String input) {
    Logger.getLogger(this.getClass()).info("echo:." + input);
    Message cxfMessage = (Message) ctx.getMessageContext().get(Message.class.getName());
    cxfMessage.getExchange().put(Counter.class, new Counter() {

        @Override
        public void increment() {
            counter.incrementAndGet();
        }
    });
    return input + "." + cxfMessage.get(StringBuilder.class) + "." + counter.get();
}
Also used : Message(org.apache.cxf.message.Message) WebMethod(javax.jws.WebMethod)

Example 62 with Message

use of org.apache.cxf.message.Message in project jbossws-cxf by jbossws.

the class EndpointImpl method echo.

@WebMethod
public String echo(String input) {
    Logger.getLogger(this.getClass()).info("echo: " + input);
    Message cxfMessage = (Message) ctx.getMessageContext().get(Message.class.getName());
    cxfMessage.getExchange().put(Counter.class, new Counter() {

        @Override
        public void increment() {
            counter.incrementAndGet();
        }
    });
    return input + " " + cxfMessage.get(StringBuilder.class) + " " + counter.get();
}
Also used : Message(org.apache.cxf.message.Message) WebMethod(javax.jws.WebMethod)

Example 63 with Message

use of org.apache.cxf.message.Message in project jbossws-cxf by jbossws.

the class SOAPConnectionImpl method get.

@Override
public SOAPMessage get(Object addressObject) throws SOAPException {
    checkClosed();
    String address = getAddress(addressObject);
    ConduitInitiator ci = getConduitInitiator(address);
    // create a new Message and Exchange
    EndpointInfo info = new EndpointInfo();
    info.setAddress(address);
    Message outMessage = new MessageImpl();
    Exchange exch = new ExchangeImpl();
    outMessage.setExchange(exch);
    // sent GET request
    try {
        // TODO verify bus
        final Conduit c = ci.getConduit(info, BusFactory.getThreadDefaultBus(false));
        if (c instanceof HTTPConduit) {
            ((HTTPConduit) c).getClient().setAutoRedirect(true);
        }
        outMessage.put(Message.HTTP_REQUEST_METHOD, "GET");
        c.prepare(outMessage);
        c.setMessageObserver(createMessageObserver(c));
        c.close(outMessage);
    } catch (Exception ex) {
        throw MESSAGES.getRequestCouldNotBeSent(ex);
    }
    // read SOAPMessage
    return readSoapMessage(exch);
}
Also used : Exchange(org.apache.cxf.message.Exchange) HTTPConduit(org.apache.cxf.transport.http.HTTPConduit) EndpointInfo(org.apache.cxf.service.model.EndpointInfo) Message(org.apache.cxf.message.Message) SOAPMessage(javax.xml.soap.SOAPMessage) Conduit(org.apache.cxf.transport.Conduit) HTTPConduit(org.apache.cxf.transport.http.HTTPConduit) ConduitInitiator(org.apache.cxf.transport.ConduitInitiator) MessageImpl(org.apache.cxf.message.MessageImpl) ExchangeImpl(org.apache.cxf.message.ExchangeImpl) SOAPException(javax.xml.soap.SOAPException) IOException(java.io.IOException)

Example 64 with Message

use of org.apache.cxf.message.Message in project jbossws-cxf by jbossws.

the class SOAPConnectionImpl method createMessageObserver.

@SuppressWarnings("unchecked")
private MessageObserver createMessageObserver(final Conduit c) {
    return new MessageObserver() {

        public void onMessage(Message inMessage) {
            LoadingByteArrayOutputStream bout = new LoadingByteArrayOutputStream();
            try {
                IOUtils.copy(inMessage.getContent(InputStream.class), bout);
                inMessage.getExchange().put(InputStream.class, bout.createInputStream());
                Map<String, List<String>> inHeaders = (Map<String, List<String>>) inMessage.get(Message.PROTOCOL_HEADERS);
                inMessage.getExchange().put(Message.PROTOCOL_HEADERS, inHeaders);
                c.close(inMessage);
            } catch (IOException e) {
                // ignore
                Logger.getLogger(SOAPConnectionImpl.class).trace(e);
            }
        }
    };
}
Also used : MessageObserver(org.apache.cxf.transport.MessageObserver) LoadingByteArrayOutputStream(org.apache.cxf.helpers.LoadingByteArrayOutputStream) Message(org.apache.cxf.message.Message) SOAPMessage(javax.xml.soap.SOAPMessage) InputStream(java.io.InputStream) ArrayList(java.util.ArrayList) List(java.util.List) IOException(java.io.IOException) HashMap(java.util.HashMap) Map(java.util.Map)

Example 65 with Message

use of org.apache.cxf.message.Message in project jbossws-cxf by jbossws.

the class UDPConduit method dataReceived.

private void dataReceived(Message message, byte[] bytes, boolean async) {
    final Message inMessage = new MessageImpl();
    inMessage.setExchange(message.getExchange());
    message.getExchange().setInMessage(inMessage);
    inMessage.setContent(InputStream.class, new ByteArrayInputStream(bytes));
    incomingObserver.onMessage(inMessage);
    if (!message.getExchange().isSynchronous()) {
        message.getExchange().setInMessage(null);
    }
}
Also used : Message(org.apache.cxf.message.Message) ByteArrayInputStream(java.io.ByteArrayInputStream) MessageImpl(org.apache.cxf.message.MessageImpl)

Aggregations

Message (org.apache.cxf.message.Message)1002 Test (org.junit.Test)507 MessageImpl (org.apache.cxf.message.MessageImpl)291 Exchange (org.apache.cxf.message.Exchange)199 ExchangeImpl (org.apache.cxf.message.ExchangeImpl)169 Endpoint (org.apache.cxf.endpoint.Endpoint)91 Interceptor (org.apache.cxf.interceptor.Interceptor)87 ClassResourceInfo (org.apache.cxf.jaxrs.model.ClassResourceInfo)85 ArrayList (java.util.ArrayList)83 EndpointInfo (org.apache.cxf.service.model.EndpointInfo)76 List (java.util.List)75 IOException (java.io.IOException)73 OperationResourceInfo (org.apache.cxf.jaxrs.model.OperationResourceInfo)73 Method (java.lang.reflect.Method)69 Bus (org.apache.cxf.Bus)69 QName (javax.xml.namespace.QName)62 SoapMessage (org.apache.cxf.binding.soap.SoapMessage)55 HashMap (java.util.HashMap)53 Fault (org.apache.cxf.interceptor.Fault)51 ByteArrayInputStream (java.io.ByteArrayInputStream)49