📄 soapconnection.java
字号:
/* * JORAM: Java(TM) Open Reliable Asynchronous Messaging * Copyright (C) 2001 - 2005 ScalAgent Distributed Technologies * Copyright (C) 1996 - 2000 Dyade * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 * USA. * * Initial developer(s): Frederic Maistre (INRIA) * Contributor(s): ScalAgent Distributed Technologies */package org.objectweb.joram.client.jms.soap;import java.io.IOException;import java.net.MalformedURLException;import java.net.URL;import java.util.Timer;import java.util.Vector;import java.util.Hashtable;import java.lang.reflect.Method;import javax.jms.IllegalStateException;import javax.jms.JMSException;import javax.jms.JMSSecurityException;import org.apache.soap.Constants;import org.apache.soap.Fault;import org.apache.soap.SOAPException;import org.apache.soap.encoding.SOAPMappingRegistry;import org.apache.soap.encoding.soapenc.BeanSerializer;import org.apache.soap.rpc.Call;import org.apache.soap.rpc.Parameter;import org.apache.soap.rpc.Response;import org.apache.soap.util.xml.QName;import org.objectweb.joram.client.jms.FactoryParameters;import org.objectweb.joram.shared.client.*;import org.objectweb.joram.client.jms.connection.RequestChannel;import org.objectweb.joram.client.jms.JoramTracing;import org.objectweb.util.monolog.api.BasicLevel;/** * A <code>SoapConnection</code> links a Joram client and a Joram platform * with HTTP connections. * <p> * Requests and replies travel through the connections in SOAP (XML) format. */public class SoapConnection implements RequestChannel { /** The user's name */ private String name; private String password; private FactoryParameters factParams; /** URL of the SOAP service this object communicates with. */ private URL serviceUrl = null; /** SOAP call object for sending the requests. */ private Call sendCall; private Call receiveCall; /** Identifier of the connection. */ private int cnxId; /** * Creates a <code>SoapConnection</code> instance. * * @param params Factory parameters. * @param name Name of user. * @param password Password of user. * * @exception JMSSecurityException If the user identification is incorrrect. * @exception IllegalStateException If the server is not reachable. */ public SoapConnection(FactoryParameters factParams2, String name2, String password2) throws JMSException { factParams = factParams2; name = name2; password = password2; } public void setTimer(Timer timer) { // No timer is useful } public void connect() throws Exception { connect(factParams, name, password); // Building the Call object for sending the requests: SOAPMappingRegistry mappingReg = new SOAPMappingRegistry(); BeanSerializer beanSer = new BeanSerializer(); mappingReg.mapTypes(Constants.NS_URI_SOAP_ENC, new QName("urn:ProxyService", "AbstractJmsRequest"), AbstractJmsRequest.class, beanSer, beanSer); mappingReg.mapTypes(Constants.NS_URI_SOAP_ENC, new QName("urn:ProxyService", "CnxConnectRequest"), CnxConnectRequest.class, beanSer, beanSer); mappingReg.mapTypes(Constants.NS_URI_SOAP_ENC, new QName("urn:ProxyService", "CnxStartRequest"), CnxStartRequest.class, beanSer, beanSer); mappingReg.mapTypes(Constants.NS_URI_SOAP_ENC, new QName("urn:ProxyService", "CnxStopRequest"), CnxStopRequest.class, beanSer, beanSer); mappingReg.mapTypes(Constants.NS_URI_SOAP_ENC, new QName("urn:ProxyService", "CnxCloseRequest"), CnxCloseRequest.class, beanSer, beanSer); mappingReg.mapTypes(Constants.NS_URI_SOAP_ENC, new QName("urn:ProxyService", "ConsumerAckRequest"), ConsumerAckRequest.class, beanSer, beanSer); mappingReg.mapTypes(Constants.NS_URI_SOAP_ENC, new QName("urn:ProxyService", "ConsumerDenyRequest"), ConsumerDenyRequest.class, beanSer, beanSer); mappingReg.mapTypes(Constants.NS_URI_SOAP_ENC, new QName("urn:ProxyService", "ConsumerReceiveRequest"), ConsumerReceiveRequest.class, beanSer, beanSer); mappingReg.mapTypes(Constants.NS_URI_SOAP_ENC, new QName("urn:ProxyService", "ConsumerSetListRequest"), ConsumerSetListRequest.class, beanSer, beanSer); mappingReg.mapTypes(Constants.NS_URI_SOAP_ENC, new QName("urn:ProxyService", "ConsumerUnsetListRequest"), ConsumerUnsetListRequest.class, beanSer, beanSer); mappingReg.mapTypes(Constants.NS_URI_SOAP_ENC, new QName("urn:ProxyService", "ConsumerSubRequest"), ConsumerSubRequest.class, beanSer, beanSer); mappingReg.mapTypes(Constants.NS_URI_SOAP_ENC, new QName("urn:ProxyService", "ConsumerUnsubRequest"), ConsumerUnsubRequest.class, beanSer, beanSer); mappingReg.mapTypes(Constants.NS_URI_SOAP_ENC, new QName("urn:ProxyService", "ConsumerCloseSubRequest"), ConsumerCloseSubRequest.class, beanSer, beanSer); mappingReg.mapTypes(Constants.NS_URI_SOAP_ENC, new QName("urn:ProxyService", "QBrowseRequest"), QBrowseRequest.class, beanSer, beanSer); mappingReg.mapTypes(Constants.NS_URI_SOAP_ENC, new QName("urn:ProxyService", "SessAckRequest"), SessAckRequest.class, beanSer, beanSer); mappingReg.mapTypes(Constants.NS_URI_SOAP_ENC, new QName("urn:ProxyService", "SessDenyRequest"), SessDenyRequest.class, beanSer, beanSer); mappingReg.mapTypes(Constants.NS_URI_SOAP_ENC, new QName("urn:ProxyService", "SessCreateTQRequest"), SessCreateTQRequest.class, beanSer, beanSer); mappingReg.mapTypes(Constants.NS_URI_SOAP_ENC, new QName("urn:ProxyService", "SessCreateTTRequest"), SessCreateTTRequest.class, beanSer, beanSer); mappingReg.mapTypes(Constants.NS_URI_SOAP_ENC, new QName("urn:ProxyService", "TempDestDeleteRequest"), TempDestDeleteRequest.class, beanSer, beanSer); mappingReg.mapTypes(Constants.NS_URI_SOAP_ENC, new QName("urn:ProxyService", "GetAdminTopicRequest"), GetAdminTopicRequest.class, beanSer, beanSer); sendCall = new Call(); sendCall.setSOAPMappingRegistry(mappingReg); sendCall.setTargetObjectURI("urn:ProxyService"); sendCall.setMethodName("send"); sendCall.setEncodingStyleURI(Constants.NS_URI_SOAP_ENC); mappingReg = new SOAPMappingRegistry(); mappingReg.mapTypes(Constants.NS_URI_SOAP_ENC, new QName("urn:ProxyService", "AbstractJmsReply"), AbstractJmsReply.class, beanSer, beanSer); mappingReg.mapTypes(Constants.NS_URI_SOAP_ENC, new QName("urn:ProxyService", "CnxConnectReply"), CnxConnectReply.class, beanSer, beanSer); mappingReg.mapTypes(Constants.NS_URI_SOAP_ENC, new QName("urn:ProxyService", "ServerReply"), ServerReply.class, beanSer, beanSer); mappingReg.mapTypes(Constants.NS_URI_SOAP_ENC, new QName("urn:ProxyService", "SessCreateTDReply"), SessCreateTDReply.class, beanSer, beanSer); mappingReg.mapTypes(Constants.NS_URI_SOAP_ENC, new QName("urn:ProxyService", "CnxCloseReply"), CnxCloseReply.class, beanSer, beanSer); mappingReg.mapTypes(Constants.NS_URI_SOAP_ENC,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -