Example #1
0
 public ZimbraException(String msg, ResponseEnvelope sf, RequestEnvelope req) : base(msg)
 {
     fault    = sf;
     this.req = req;
 }
Example #2
0
 public ZimbraException(ResponseEnvelope sf, RequestEnvelope req)
 {
     fault    = sf;
     this.req = req;
 }
Example #3
0
        public ResponseEnvelope SendRequest(RequestEnvelope re)
        {
            XmlDocument requestDoc = re.ToXmlDocument();
            String      serviceUri = "http";

            if (useSecure)
            {
                serviceUri += "s";
            }
            serviceUri += "://" + server + ":" + port;

            serviceUri += re.ApiRequest.ServicePath;

            if (debugStream != null)
            {
                debugStream.WriteLine("Request:");
                debugStream.WriteLine(requestDoc.OuterXml);
                debugStream.WriteLine("");
            }

            HttpWebRequest wr = (HttpWebRequest)WebRequest.Create(serviceUri);

            wr.AllowWriteStreamBuffering = true;
            wr.Method = re.ApiRequest.HttpMethod;

            Stream stream = wr.GetRequestStream();

            requestDoc.Save(stream);
            stream.Close();

            HttpWebResponse resp;

            try
            {
                resp = (HttpWebResponse)wr.GetResponse();
            }
            catch (WebException wex)
            {
                if (wex.Response == null)
                {
                    throw wex;
                }
                resp = (HttpWebResponse)wex.Response;
            }
            stream = resp.GetResponseStream();

            XmlDocument responseDoc = new XmlDocument();

            responseDoc.Load(stream);
            stream.Close();

            if (debugStream != null)
            {
                debugStream.WriteLine("Response:");
                debugStream.WriteLine(responseDoc.OuterXml);
                debugStream.WriteLine("\n");
            }

            ResponseEnvelope respEnv = new ResponseEnvelope(
                ResponseManager.NewResponseContext(responseDoc),
                ResponseManager.NewResponse(responseDoc));

            if (faultToException && respEnv.ApiResponse is SoapFault)
            {
                throw new ZimbraException(respEnv, re);
            }

            return(respEnv);
        }
Example #4
0
		public ResponseEnvelope SendRequest( RequestEnvelope re )
		{
			XmlDocument requestDoc = re.ToXmlDocument();
			String serviceUri = "http";
			if( useSecure )
				serviceUri += "s";
			serviceUri += "://" + server + ":" + port;

			serviceUri += re.ApiRequest.ServicePath;

			if( debugStream != null )
			{
				debugStream.WriteLine( "Request:" );
				debugStream.WriteLine( requestDoc.OuterXml );
				debugStream.WriteLine( "" );
			}

			HttpWebRequest wr = (HttpWebRequest)WebRequest.Create(serviceUri);
            wr.AllowWriteStreamBuffering = true;
			wr.Method = re.ApiRequest.HttpMethod;

			Stream stream = wr.GetRequestStream();
			requestDoc.Save( stream );
			stream.Close();

			HttpWebResponse resp;
			try
			{
				resp = (HttpWebResponse)wr.GetResponse();
			}
			catch( WebException wex )
			{
                if (wex.Response == null)
                    throw wex;
				resp = (HttpWebResponse)wex.Response;
			}
			stream = resp.GetResponseStream();

			XmlDocument responseDoc = new XmlDocument();
			responseDoc.Load( stream );
			stream.Close();
			
			if( debugStream != null )
			{
				debugStream.WriteLine( "Response:" );
				debugStream.WriteLine( responseDoc.OuterXml );
				debugStream.WriteLine( "\n" );
			}
			
			ResponseEnvelope respEnv = new ResponseEnvelope(
				ResponseManager.NewResponseContext(responseDoc),
				ResponseManager.NewResponse(responseDoc) );

			if( faultToException && respEnv.ApiResponse is SoapFault )
				throw new ZimbraException( respEnv, re );

			return respEnv;
		}
Example #5
0
		public ZimbraException( String msg, ResponseEnvelope sf, RequestEnvelope req ) : base(msg)
		{
			fault = sf;
			this.req = req;
		}
Example #6
0
		public ZimbraException( ResponseEnvelope sf, RequestEnvelope req )
		{
			fault = sf;
			this.req = req;
		}