Java Code Examples for org.apache.cxf.service.model.BindingMessageInfo#getMessageParts()

The following examples show how to use org.apache.cxf.service.model.BindingMessageInfo#getMessageParts() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SoapClient.java    From jea with Apache License 2.0 6 votes vote down vote up
private Object[] convert(Endpoint endpoint, QName opName, Object... params) throws Exception {
	List<Object> listSoapObject = new ArrayList<Object>();
	BindingOperationInfo boi = endpoint.getEndpointInfo().getBinding().getOperation(opName); // Operation name is processOrder  
       BindingMessageInfo inputMessageInfo = null;
       if (!boi.isUnwrapped()) {
           inputMessageInfo = boi.getWrappedOperation().getInput();
       } else {
           inputMessageInfo = boi.getUnwrappedOperation().getInput();
       }
       List<MessagePartInfo> parts = inputMessageInfo.getMessageParts();
       
       int index = 0;
       for(Object obj : params){
       	MessagePartInfo partInfo = parts.get(index++);
       	Class<?> soapClass = partInfo.getTypeClass();
           Object soapObject = copytoSoapObject(obj, soapClass);
           listSoapObject.add(soapObject);
       }
       
       return listSoapObject.toArray();
}
 
Example 2
Source File: BareOutInterceptor.java    From cxf with Apache License 2.0 5 votes vote down vote up
public void handleMessage(Message message) {
    Exchange exchange = message.getExchange();
    BindingOperationInfo operation = exchange.getBindingOperationInfo();

    if (operation == null) {
        return;
    }

    MessageContentsList objs = MessageContentsList.getContentsList(message);
    if (objs == null || objs.isEmpty()) {
        return;
    }

    List<MessagePartInfo> parts = null;
    BindingMessageInfo bmsg = null;
    boolean client = isRequestor(message);

    if (!client) {
        if (operation.getOutput() != null) {
            bmsg = operation.getOutput();
            parts = bmsg.getMessageParts();
        } else {
            // partial response to oneway
            return;
        }
    } else {
        bmsg = operation.getInput();
        parts = bmsg.getMessageParts();
    }

    writeParts(message, exchange, operation, objs, parts);
}
 
Example 3
Source File: AbstractInDatabindingInterceptor.java    From cxf with Apache License 2.0 4 votes vote down vote up
/**
 * Find the next possible message part in the message. If an operation in
 * the list of operations is no longer a viable match, it will be removed
 * from the Collection.
 *
 * @param exchange
 * @param operations
 * @param name
 * @param client
 * @param index
 */
protected MessagePartInfo findMessagePart(Exchange exchange, Collection<OperationInfo> operations,
                                          QName name, boolean client, int index,
                                          Message message) {
    Endpoint ep = exchange.getEndpoint();
    MessagePartInfo lastChoice = null;
    BindingOperationInfo lastBoi = null;
    BindingMessageInfo lastMsgInfo = null;
    for (Iterator<OperationInfo> itr = operations.iterator(); itr.hasNext();) {
        OperationInfo op = itr.next();

        final BindingOperationInfo boi = ep.getEndpointInfo().getBinding().getOperation(op);
        if (boi == null) {
            continue;
        }
        final BindingMessageInfo msgInfo;
        if (client) {
            msgInfo = boi.getOutput();
        } else {
            msgInfo = boi.getInput();
        }

        if (msgInfo == null) {
            itr.remove();
            continue;
        }

        Collection<MessagePartInfo> bodyParts = msgInfo.getMessageParts();
        if (bodyParts.isEmpty() || bodyParts.size() <= index) {
            itr.remove();
            continue;
        }

        MessagePartInfo p = msgInfo.getMessageParts().get(index);
        if (name.getNamespaceURI() == null || name.getNamespaceURI().isEmpty()) {
            // message part has same namespace with the message
            name = new QName(p.getMessageInfo().getName().getNamespaceURI(), name.getLocalPart());
        }
        if (name.equals(p.getConcreteName())) {
            exchange.put(BindingOperationInfo.class, boi);
            exchange.setOneWay(op.isOneWay());
            return p;
        }

        if (Constants.XSD_ANYTYPE.equals(p.getTypeQName())) {
            lastChoice = p;
            lastBoi = boi;
            lastMsgInfo = msgInfo;
        } else {
            itr.remove();
        }
    }
    if (lastChoice != null) {
        setMessage(message, lastBoi, client, lastBoi.getBinding().getService(),
                   lastMsgInfo.getMessageInfo());
    }
    return lastChoice;
}