コード例 #1
0
        public UddiException(SoapException soapException) : base("", soapException)
        {
            dispositionReport        = null;
            hasDispositionReportData = false;

            //
            // The soap exception passed in SHOULD contain a disposition report.
            // Deserialize it into an object and use the error number in this exception
            //
            if (false == Utility.StringEmpty(soapException.Detail.InnerXml))
            {
                //
                // Translate the XML into the current version.
                //
                string dispositionReportXml = UddiVersionSupport.Translate(soapException.Detail.InnerXml, UddiVersionSupport.CurrentVersion);

                StringReader reader = new StringReader(dispositionReportXml);
                if (null == serializer)
                {
                    serializer = new XmlSerializer(typeof(DispositionReport));
                }

                dispositionReport = ( DispositionReport )serializer.Deserialize(reader);
                reader.Close();
            }

            hasDispositionReportData = (null != dispositionReport) &&
                                       (null != dispositionReport.Results) &&
                                       (dispositionReport.Results.Count > 0);
        }
コード例 #2
0
        //
        // TODO: at some point it may be necessary to pass in the current version as a parameter if the transforms become
        // more complicated.
        //

        /// <summary>
        /// Constructor.  We read all the XML sent from the server, do our version manipulation, then write the new XML
        /// into our inner responseStream object.
        /// </summary>
        /// <param name="responseStream">This object should be the responseStream from a WebResponse object.</param>
        public UddiResponseStream(Stream responseStream)
        {
            try
            {
                //
                // Get the XML the server sent to us.
                //
                StreamReader reader      = new StreamReader(responseStream);
                string       responseXml = reader.ReadToEnd();
                reader.Close();

                //
                // TODO: Consider making this class more generic, ie. have a IUddiResponseHandler interface:
                //	IUddiResponseHandler
                //		string HandleResponse( string xml );
                //

                //
                // Translate the incoming XML into the current version.
                //
                string transformedXml = UddiVersionSupport.Translate(responseXml, UddiVersionSupport.CurrentVersion);

                //
                // Write this transformed XML into the 'real' stream.
                //
                StreamUtility.WriteStringToStream(this, transformedXml);
            }
            finally
            {
                this.Position = 0;
            }
        }
コード例 #3
0
        /// <summary>
        /// Before we actually close the request stream, we want to manipulate the XML.
        /// </summary>
        public override void Close()
        {
            try
            {
                //
                // Rewind ourselves.
                //
                this.Position = 0;

                //
                // Read the XML that was written; this is the XML request that will be sent to the Uddi server.
                //
                StreamReader reader     = new StreamReader(this);
                string       requestXml = reader.ReadToEnd();

                //
                // TODO: Consider making this class more generic, ie. have a IUddiRequestHandler interface:
                //	IUddiResponseHandler
                //		string HandleRequest( string xml );
                //

                //
                // Transform the content to a correct version on the server if we are not using the current version.
                //
                string transformedXml = requestXml;
                if (uddiVersion != UddiVersionSupport.CurrentVersion)
                {
                    transformedXml = UddiVersionSupport.Translate(requestXml, uddiVersion);
                }

                //
                // Write the transformed data to the 'real' stream.
                //
                StreamUtility.WriteStringToStream(innerStream, transformedXml);
            }
            finally
            {
                //
                // Make sure we clean up properly.
                //
                innerStream.Close();
                base.Close();
            }
        }