cxf-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Santosh Kulkarni" <skulk...@jcpenney.com>
Subject CXF Marshalling interceptors
Date Thu, 31 Jul 2008 20:54:01 GMT
Hi,

I wanted to intercept the marshalling process and catch the exception
and throw a generic fault instead of the standard fault that I see when
I turn on validation.
I tried putting in a validation as given at the end of the email.
Questions:
1) Why doesn't this work? Is my phase constant wrong?
2) Is this the best way to intercept the marshalling process?
Thanks
Santosh


Spring configuration 
<bean name="theInterceptor"
		class="com.company.MarshallInterceptor">
	</bean>
</cxf:features>
        <cxf:inInterceptors>
			<ref bean="theInterceptor" />
		</cxf:inInterceptors>
    </cxf:bus>
<jaxws:endpoint 
        id="paymentService"
        implementor="com.company.ComeServiceImpl"
        wsdlLocation="config/wsdl/someService.wsdl"
        address="/someService">
        <jaxws:properties> 
            <entry key="schema-validation-enabled" value="true" /> 
        </jaxws:properties> 
    </jaxws:endpoint>


Interceptor code:

package com.company;

import java.io.IOException;

import javax.xml.bind.helpers.AbstractMarshallerImpl;

import org.apache.cxf.attachment.AttachmentDeserializer;
import org.apache.cxf.interceptor.Fault;
import org.apache.cxf.message.Message;
import org.apache.cxf.phase.AbstractPhaseInterceptor;
import org.apache.cxf.phase.Phase;

public class MarshallInterceptor extends
AbstractPhaseInterceptor<Message> {
    public MarshallInterceptor() {
        super(Phase.PRE_MARSHAL);
    }

    public void handleMessage(Message message) {
        String contentType = (String) message.get(Message.CONTENT_TYPE);
        System.out.println("handling the message "+contentType);
    }

    public void handleFault(Message messageParam) {
    	System.out.println("there was a fault ");
    }
}

Mime
View raw message