Client测试类packageclient;importjava.net.*;importjava.io.*;importjava.lang.*;importsun.misc.BASE64Encoder;publicclassClientApp{publicstaticvoidmain(Stringargs[])throwsUnknownHostException,IOException{//创建通讯并且和主机Rock连接SocketcSocket=newSocket(192.168.1.20,5200);//打开这个Socket的输入/输出流OutputStreamos=cSocket.getOutputStream();BufferedReaderbr=newBufferedReader(newInputStreamReader(cSocket.getInputStream()));StringxmlStringMessage=qflag.xmpp.packet.IQid='xxx'from='xxx'namewanglei/namepassword123/password/qflag.xmpp.packet.IQ;//StringxmlStringMessage=qflag.xmpp.packet.Messageid='yyy'from='yyy'bodyhahaha/body/qflag.xmpp.packet.Message;//xmlStringMessage=ss;//BASE64Encoderbencode=newBASE64Encoder();//xmlStringMessage=bencode.encode(xmlStringMessage.getBytes());os.write(xmlStringMessage.getBytes());//os.write(xmlString.getBytes());Stringmsg=null;System.out.println(start...);try{while((msg=br.readLine())!=null)System.out.println(msg=+msg);}catch(IOExceptione){e.printStackTrace();}}}Server启动类packagexmpp;importorg.mule.api.MuleContext;importorg.mule.api.MuleException;importorg.mule.api.context.MuleContextFactory;importorg.mule.config.spring.SpringXmlConfigurationBuilder;importorg.mule.context.DefaultMuleContextFactory;publicclassServer{publicstaticvoidmain(String[]args){//TODOAuto-generatedmethodstubtry{StringconfigFile=conf/xmpp-config.xml;String[]configFileArr=newString[]{configFile};MuleContextFactorymuleContextFactory=newDefaultMuleContextFactory();MuleContextcontext=muleContextFactory.createMuleContext(newSpringXmlConfigurationBuilder(configFileArr));context.start();System.out.println(success);}catch(MuleExceptiont){t.printStackTrace();}}}Mulexml配置mule做了一周多了,入门很难,光跑那几个demo就很费事情,它提供的很多东西都和文档上的不一致,这点真的想骂人,不成熟的东西就不要拿出来啊,拿出来又用不起,老板又不听这种解释。。。。我真的苦啊!!!不过总算过头了,我成功的调通了mule的xmpp路由功能,虽然里面有bug,但我自己写了一个类的代替它,勉强可以用了。下面我把如何配置xml文件以及如果启动告诉大家,希望对大家有些帮助,不用再花费太多时间去研究!下面是一个完整可运行的,通过测试的xml?xmlversion=1.0encoding=UTF-8?mulexmlns=:xsi=:spring=:stdio=:vm=:tcp=:schemaLocation=://://://://://://://://://=StdinToNameStringclass=org.mule.example.hello.StdinToNameString/custom-transformername=NameStringToChatStringclass=org.mule.example.hello.NameStringToChatString/custom-transformername=ChatStringToStringclass=org.mule.example.hello.ChatStringToString/custom-transformername=ExceptionToStringclass=org.mule.example.hello.ExceptionToString/custom-transformername=StringToStringclass=transformer.StringToString/custom-transformercustom-transformername=XmppPacketToObjectclass=org.mule.transport.xmpp.transformers.XmppPacketToObject/custom-transformername=ObjectToXmppPacketclass=org.mule.transport.xmpp.transformers.ObjectToXmppPacket/custom-transformername=XmppPacketToStringclass=xmpp.XmppPacketToString/custom-transformername=ByteArrayToObjectclass=org.mule.transformer.simple.ByteArrayToObject/custom-transformername=ObjectToTempXmppPacketclass=xmpp.ObjectToTempXmppPacket/!--Aninterceptorisapieceofcodethatcanbeconfiguredtoexecutebeforeand/orafteraneventisreceivedforacomponent.Youcandefineastackofinterceptorsthatwillbeexecutedinsequence.Youcanthenconfigurethestackonyourcomponents.--!--TheMulemodelinitialisesandmanagesyourUMOcomponents--tcp:connectorname=TcpConnectorkeepAlive=truereceiveBufferSize=2048sendBufferSize=2048receiveBacklog=500serverSoTimeout=3000keepSendSocketOpen=truevalidateConnections=truetcp:direct-protocolpayloadOnly=true//tcp:connectortcp:endpointconnector-ref=TcpConnectorname=Endpointhost=192.168.1.20port=5200synchronous=true/modelname=helloSample!--AMuleservicedefinesallthenecessaryinformationabouthowyourcomponentswillinteractwiththeframework,othercomponentsinthesystemandexternalsources.PleaserefertotheConfigurationGuideforafulldescriptionofalltheparameters.--servicename=GreeterUMOinboundtcp:inbound-endpointname=inboundEndpointconnector-ref=TcpConnectorport=5200host=192.168.1.20transformer-refs=ByteArrayToObjectObjectToTempXmppPacket/!--inbound-endpointref=inboundEndpoint/--/inbound!--componentclass=xmpp.XmppOtherComponet/--outboundfiltering-routervm:outbound-endpointpath=iq/payload-type-filterexpectedType=beans.Person//filtering-routerfiltering-routervm:ou