Mule 3.2.1 调用 Mule 2.2.1

                              异常解析

Session variable "��sr#org.mule.session.DefaultMuleSession.�v��a�

ZvalidL[1]idtLjava/lang/String" is malfomed and cannot be read

 

发生过程:Mule 3.2.1 通过binding方式调用其他service部署在Mule 2.2.1版本下:

主要原因由于:使用的SessionHandler的问题:相关类:Base64Encoder,MuleSessionHandler,LegacySessionHandler下面是两段代码:

Mule 2.2.1-MuleSessionHandler


  
  
  
  
  1. public void storeSessionInfoToMessage(MuleSession session, MuleMessage message) throws MuleException 
  2.  { 
  3.      StringBuffer buf = new StringBuffer(); 
  4.      buf.append(getSessionIDKey()).append("=").append(session.getId()); 
  5.      for (Iterator iterator = session.getPropertyNames(); iterator.hasNext();) 
  6.      { 
  7.          Object o = iterator.next(); 
  8.          buf.append(";"); 
  9.          buf.append(o).append("=").append(session.getProperty(o)); 
  10.          if (logger.isDebugEnabled()) 
  11.          { 
  12.              logger.debug("Adding property to session header: " + o + "=" + session.getProperty(o)); 
  13.          } 
  14.      } 
  15.      String sessionString = buf.toString(); 
  16.      if (logger.isDebugEnabled()) 
  17.      { 
  18.          logger.debug("Adding session header to message: " + sessionString); 
  19.      } 
  20.      sessionString = (String) encoder.transform(sessionString); 
  21.      message.setProperty(MuleProperties.MULE_SESSION_PROPERTY, sessionString); 
  22.  } 

Mule 3.2.1-SerializeAndEncodeSessionHandler

 

  
  
  
  
  1. @Override 
  2.   public void storeSessionInfoToMessage(MuleSession session, MuleMessage message) throws MuleException 
  3.   {         
  4.       byte[] serializedSession = SerializationUtils.serialize(removeNonSerializableProperties(session,message.getMuleContext())); 
  5.       String serializedEncodedSession; 
  6.       try 
  7.       { 
  8.           serializedEncodedSession = Base64.encodeBytes(serializedSession, Base64.DONT_BREAK_LINES); 
  9.       } 
  10.       catch (IOException e) 
  11.       { 
  12.           throw new SessionException(MessageFactory.createStaticMessage("Unable to serialize MuleSession"), e); 
  13.       } 
  14.        
  15.       if (logger.isDebugEnabled()) 
  16.       { 
  17.           logger.debug("Adding serialized and base64-encoded Session header to message: " + serializedEncodedSession); 
  18.       } 
  19.       message.setOutboundProperty(MuleProperties.MULE_SESSION_PROPERTY, serializedEncodedSession); 
  20.   } 

解决方案:使用Mule3.2.1中的LegacySessionHandler类来作为莫尔纳的sessionHandler

 

  
  
  
  
  1. <?xml version="1.0" encoding="UTF-8"?> 
  2. <mule xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
  3.     xmlns:spring="http://www.springframework.org/schema/beans" xmlns:cxf="http://www.mulesoft.org/schema/mule/cxf" 
  4.     xmlns:quartz="http://www.mulesoft.org/schema/mule/quartz" xmlns:test="http://www.mulesoft.org/schema/mule/test" 
  5.     xmlns:vm="http://www.mulesoft.org/schema/mule/vm" xmlns:smtp="http://www.mulesoft.org/schema/mule/smtp" 
  6.     xmlns:email="http://www.mulesoft.org/schema/mule/email" xmlns:http="http://www.mulesoft.org/schema/mule/http" 
  7.     xsi:schemaLocation=" 
  8.        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd 
  9.        http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/3.2/mule.xsd 
  10.        http://www.mulesoft.org/schema/mule/test http://www.mulesoft.org/schema/mule/test/3.2/mule-test.xsd 
  11.        http://www.mulesoft.org/schema/mule/quartz http://www.mulesoft.org/schema/mule/quartz/3.2/mule-quartz.xsd 
  12.        http://www.mulesoft.org/schema/mule/vm http://www.mulesoft.org/schema/mule/vm/3.2/mule-vm.xsd 
  13.        http://www.mulesoft.org/schema/mule/smtp http://www.mulesoft.org/schema/mule/smtp/3.2/mule-smtp.xsd 
  14.        http://www.mulesoft.org/schema/mule/email http://www.mulesoft.org/schema/mule/email/3.2/mule-email.xsd 
  15.        http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/3.2/mule-http.xsd 
  16.        http://www.mulesoft.org/schema/mule/cxf http://www.mulesoft.org/schema/mule/cxf/3.2/mule-cxf.xsd"> 
  17.    <http:connector name="legacyConnector"
  18.      <service-overrides sessionHandler="org.mule.session.LegacySessionHandler"/> 
  19.    </http:connector> 
  20.  
  21.     <flow name="cxfBinding1FlowWSDL"
  22.         <inbound-endpoint address="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" /> 
  23.         <cxf:jaxws-service 
  24.             serviceClass="com.synnex.ws.demo.cxf.bindingclient.BindingServiceImpl" /> 
  25.         <component class="com.synnex.ws.demo.cxf.bindingclient.BindingServiceImpl"
  26.             <binding interface="com.synnex.ws.demo.cxf.bindingclient.BindingInterface" 
  27.                 method="login"
  28.                 <outbound-endpoint name="testClient1" 
  29.                     address="xxxxxxxxxxxxxxxxxxxx" connector-ref="legacyConnector" 
  30.                     > 
  31.                     <cxf:jaxws-client operation="login" serviceClass="xxxxxxxxxxxxxxx"
  32.                     </cxf:jaxws-client> 
  33.                 </outbound-endpoint> 
  34.             </binding> 
  35.         </component> 
  36.     </flow> 
  37.  
  38.  
  39. </mule> 

 

你可能感兴趣的:(职场,mule,休闲)