如何将原始web服务消息soapenv字符串转换为CXF中的相关对象

时间:2013-02-15 10:45:35

标签: web-services cxf marshalling unmarshalling

我有一个像字符串一样的webservice原始消息。我的目标是改变这个消息的意思,比如再见!到AlteredGoodbye !! 让我知道是否有任何api / utils方法可以做到这一点。我正在使用带有cxf堆栈的jboss 5,因此为此提供了cxf utils。

RAW XML STRING

                               再见!!              

1 个答案:

答案 0 :(得分:0)

您必须添加out interceptor

例如:

public class SoapActionOutInterceptor extends AbstractSoapInterceptor {

   public SoapActionOutInterceptor() {
         super(Phase.POST_LOGICAL);
   }

   public void handleMessage(SoapMessage message) throws Fault {
         if (message.getVersion() instanceof Soap11) {
                PocBean pb = null;
                MessageContentsList list = (MessageContentsList) message.getContent(List.class);
                for (Iterator itList = list.iterator(); itList.hasNext();) {
                       Object content = itList.next();
                       if (content instanceof PocBean) {
                              pb = (PocBean) content;
                              pb.setParam1("AlteredGoodbye!!");

                       }
                }
         }
   }
}

并像这样声明这个拦截器:

       <jaxws:endpoint id="pocWebService" implementor="#pocService"
         address="/pocService">

         <jaxws:properties>
                <entry key="schema-validation-enabled" value="true" />
         </jaxws:properties>
         <jaxws:outInterceptors>
                <bean class="fr.genybet.service.interceptor.SoapActionOutInterceptor" />
         </jaxws:outInterceptors>
   </jaxws:endpoint>