Example #1
0
        /*
         #if DEBUG
         * private static void CopyStream(Stream source, Stream dest) {
         *  byte[] bytes = new byte[1024];
         *  int numRead = 0;
         *  while ((numRead = source.Read(bytes, 0, 1024)) > 0)
         *      dest.Write(bytes, 0, numRead);
         * }
         #endif
         */

        private void SetHelper(SoapServerProtocolHelper helper)
        {
            this.helper  = helper;
            this.version = helper.Version;
            // SOAP12: disabled
            //Context.Items[WebService.SoapVersionContextSlot] = helper.Version;
        }
        /// <summary>
        /// Initializes the services of MS-WEBSS with the specified transport type, soap version and user authentication provided by the test case.
        /// </summary>
        /// <param name="transportType">The type of the connection</param>
        /// <param name="soapVersion">The soap version of the protocol message</param>
        /// <param name="userAuthentication">a user authenticated</param>
        /// <param name="serverRelativeUrl"> a Server related URL</param>
        public void InitializeService(TransportProtocol transportType, SoapProtocolVersion soapVersion, UserAuthentication userAuthentication, string serverRelativeUrl)
        {
            this.service = Proxy.CreateProxy<WebsSoap>(this.Site);
            this.service.SoapVersion = soapVersion;

            // select transport protocol
            switch (transportType)
            {
                case TransportProtocol.HTTP:
                    this.service.Url = serverRelativeUrl;
                    break;
                default: 
                    this.service.Url = serverRelativeUrl;

                    // when request URL include HTTPS prefix, avoid closing base connection.
                    // local client will accept all certificate after execute this function. 
                    Common.AcceptServerCertificate();

                    break;
            }

            this.service.Credentials = AdapterHelper.ConfigureCredential(userAuthentication);

            // Configure the service timeout.
            int soapTimeOut = Common.GetConfigurationPropertyValue<int>("ServiceTimeOut", this.Site);

            // 60000 means the configure SOAP Timeout is in minute.
            this.service.Timeout = soapTimeOut * 60000;
        }
Example #3
0
		public WebService ()
		{
			_context = HttpContext.Current;
			object o = _context != null ? _context.Items ["WebServiceSoapVersion"] : null;
			if (o is SoapProtocolVersion)
				_soapVersion = (SoapProtocolVersion) o;
		}
Example #4
0
 static SoapException CreateSuppressedException(SoapProtocolVersion soapVersion, string message, Exception innerException)
 {
     return(new SoapException(Res.GetString(Res.WebSuppressedExceptionMessage),
                              soapVersion == SoapProtocolVersion.Soap12
         ? new XmlQualifiedName(Soap12.Code.Receiver, Soap12.Namespace)
         : new XmlQualifiedName(Soap.Code.Server, Soap.Namespace)));
 }
Example #5
0
        /// <summary>
        /// Initializes the services of MS-WEBSS with the specified transport type, soap version and user authentication provided by the test case.
        /// </summary>
        /// <param name="transportType">The type of the connection</param>
        /// <param name="soapVersion">The soap version of the protocol message</param>
        /// <param name="userAuthentication">a user authenticated</param>
        /// <param name="serverRelativeUrl"> a Server related URL</param>
        public void InitializeService(TransportProtocol transportType, SoapProtocolVersion soapVersion, UserAuthentication userAuthentication, string serverRelativeUrl)
        {
            this.service             = Proxy.CreateProxy <WebsSoap>(this.Site);
            this.service.SoapVersion = soapVersion;

            // select transport protocol
            switch (transportType)
            {
            case TransportProtocol.HTTP:
                this.service.Url = serverRelativeUrl;
                break;

            default:
                this.service.Url = serverRelativeUrl;

                // when request URL include HTTPS prefix, avoid closing base connection.
                // local client will accept all certificate after execute this function.
                Common.AcceptServerCertificate();

                break;
            }

            this.service.Credentials = AdapterHelper.ConfigureCredential(userAuthentication);

            // Configure the service timeout.
            int soapTimeOut = Common.GetConfigurationPropertyValue <int>("ServiceTimeOut", this.Site);

            // 60000 means the configure SOAP Timeout is in minute.
            this.service.Timeout = soapTimeOut * 60000;
        }
        /// <summary>
        /// Verify the requirements related to SOAP version.
        /// </summary>
        /// <param name="soapVersion">The soap protocol version.</param>
        private void VerifySOAPVersion(SoapProtocolVersion soapVersion)
        {
            if (soapVersion == SoapProtocolVersion.Soap11)
            {
                // Add the debug information
                Site.Log.Add(LogEntryKind.Debug, "Verify MS-VERSS_R701");

                // Verify MS-VERSS requirement: MS-VERSS_R701
                // According to the implementation of adapter, the message is formatted as SOAP1.1.
                // If this operation is invoked successfully, then this requirement can be verified.
                Site.CaptureRequirement(
                    701,
                    @"[In Transport] Protocol messages can be formatted as specified in [SOAP1.1] section 4.");
            }

            if (soapVersion == SoapProtocolVersion.Soap12)
            {
                // Add the debug information
                Site.Log.Add(LogEntryKind.Debug, "Verify MS-VERSS_R702");

                // Verify MS-VERSS requirement: MS-VERSS_R702
                // According to the implementation of adapter, the message is formatted as SOAP1.2.
                // If this operation is invoked successfully, then this requirement can be verified.
                Site.CaptureRequirement(
                    702,
                    @"[In Transport] Protocol messages can be formatted as specified in [SOAP1.2/-1/2007] section 5.");
            }
        }
 public static SoapException Create(SoapProtocolVersion soapVersion, string message, XmlQualifiedName code, Exception innerException)
 {
     //if (WebServicesSection.Current.Diagnostics.SuppressReturningExceptions)
     //{
     //    return SoapException.CreateSuppressedException(soapVersion, Res.GetString("WebSuppressedExceptionMessage"), innerException);
     //}
     return(new SoapException(message, code, innerException));
 }
 internal static SoapException Create(SoapProtocolVersion soapVersion, string message, XmlQualifiedName code, string actor, string role, XmlNode detail, SoapFaultSubCode subCode, Exception innerException)
 {
     if (WebServicesSection.Current.Diagnostics.SuppressReturningExceptions)
     {
         return(CreateSuppressedException(soapVersion, System.Web.Services.Res.GetString("WebSuppressedExceptionMessage"), innerException));
     }
     return(new SoapException(message, code, actor, role, detail, subCode, innerException));
 }
Example #9
0
        public WebService()
        {
            _context = HttpContext.Current;
            object o = _context != null ? _context.Items ["WebServiceSoapVersion"] : null;

            if (o is SoapProtocolVersion)
            {
                _soapVersion = (SoapProtocolVersion)o;
            }
        }
Example #10
0
        /// <summary>
        /// This getter returns the resource location of the soap schemas
        /// </summary>
        /// <param name="version">
        /// The Soap version
        /// </param>
        /// <returns>
        /// The resource location
        /// </returns>
        public static string GetSoapXsdLocation(SoapProtocolVersion version)
        {
            switch (version)
            {
            case SoapProtocolVersion.Soap11:
                return(Soap11Location);

            default:
                return(Soap12Location);
            }
        }
Example #11
0
 internal static SoapException Create(SoapProtocolVersion soapVersion, string message, XmlQualifiedName code, Exception innerException)
 {
     if (System.Web.Services.Configuration.WebServicesSection.Current.Diagnostics.SuppressReturningExceptions)
     {
         return(CreateSuppressedException(soapVersion, Res.GetString(Res.WebSuppressedExceptionMessage), innerException));
     }
     else
     {
         return(new SoapException(message, code, innerException));
     }
 }
Example #12
0
        /// <summary>
        /// Get Soap version.
        /// </summary>
        /// <returns>The current Soap version</returns>
        protected SoapProtocolVersion GetSoapVersion()
        {
            string soapVersionString = Common.GetConfigurationPropertyValue("SoapVersion", this.Site);
            SoapProtocolVersion soapVersionCurrent = SoapProtocolVersion.Soap12;

            if (string.Compare(soapVersionString, SoapVersion.SOAP11.ToString(), true) == 0)
            {
                soapVersionCurrent = SoapProtocolVersion.Soap11;
            }
            else if (string.Compare(soapVersionString, SoapVersion.SOAP12.ToString(), true) == 0)
            {
                soapVersionCurrent = SoapProtocolVersion.Soap12;
            }

            return(soapVersionCurrent);
        }
Example #13
0
        /// <summary>
        /// Validate a piece of Xml fragment.
        /// </summary>
        /// <param name="testSite">Transfer ITestSite into this class, make this class can use ITestSite's function.</param>
        /// <param name="ignoreSoapFaultSchemaValidationForSoap12">Indicate that whether ignore schema validation for SOAP fault in SOAP1.2.</param>
        /// <returns>The result of validation.</returns>
        internal static ValidationResult ValidateXml(ITestSite testSite, bool ignoreSoapFaultSchemaValidationForSoap12)
        {
            XmlNodeList         nodesForSoapFault = SchemaValidation.LastRawResponseXml.GetElementsByTagName("Fault", SoapNamespace);
            SoapProtocolVersion soapVersion       = Common.GetConfigurationPropertyValue <SoapProtocolVersion>("SoapVersion", testSite);

            if (ignoreSoapFaultSchemaValidationForSoap12 &&
                (soapVersion == SoapProtocolVersion.Soap12) && (nodesForSoapFault.Count > 0))
            {
                site             = testSite;
                validationResult = ValidationResult.Inconclusive;
                return(validationResult);
            }
            else
            {
                return(ValidateXml(testSite, rawResponseXml.OuterXml));
            }
        }
 internal static SoapException Create(SoapProtocolVersion soapVersion, string message, XmlQualifiedName code, Exception innerException) { 
     if (System.Web.Services.Configuration.WebServicesSection.Current.Diagnostics.SuppressReturningExceptions) {
         return CreateSuppressedException(soapVersion, Res.GetString(Res.WebSuppressedExceptionMessage), innerException);
     }
     else {
         return new SoapException(message, code, innerException);
     }
 }
Example #15
0
		internal void SetSoapVersion (SoapProtocolVersion value)
		{
			soapVersion = value;
		}
 internal static SoapException Create(SoapProtocolVersion soapVersion, string message, XmlQualifiedName code, string actor, string role, XmlNode detail, SoapFaultSubCode subCode, Exception innerException)
 {
     if (WebServicesSection.Current.Diagnostics.SuppressReturningExceptions)
     {
         return CreateSuppressedException(soapVersion, System.Web.Services.Res.GetString("WebSuppressedExceptionMessage"), innerException);
     }
     return new SoapException(message, code, actor, role, detail, subCode, innerException);
 }
 private static SoapException CreateSuppressedException(SoapProtocolVersion soapVersion, string message, Exception innerException)
 {
     return new SoapException(System.Web.Services.Res.GetString("WebSuppressedExceptionMessage"), (soapVersion == SoapProtocolVersion.Soap12) ? new XmlQualifiedName("Receiver", "http://www.w3.org/2003/05/soap-envelope") : new XmlQualifiedName("Server", "http://schemas.xmlsoap.org/soap/envelope/"));
 }
 private static SoapException CreateSuppressedException(SoapProtocolVersion soapVersion, string message, Exception innerException)
 {
     return(new SoapException(System.Web.Services.Res.GetString("WebSuppressedExceptionMessage"), (soapVersion == SoapProtocolVersion.Soap12) ? new XmlQualifiedName("Receiver", "http://www.w3.org/2003/05/soap-envelope") : new XmlQualifiedName("Server", "http://schemas.xmlsoap.org/soap/envelope/")));
 }
Example #19
0
 public SoapRequest(String url, String soapXml, String method, String accept, String headers = null, String contentType = null, SoapProtocolVersion version = SoapProtocolVersion.Soap11)
 {
     this.Url         = url;
     this.SoapXml     = soapXml;
     this.Headers     = ParseHeaders(headers);
     this.ContentType = contentType;
     this.Version     = version;
     this.Method      = method;
     this.Accept      = accept;
 }
 static SoapException CreateSuppressedException(SoapProtocolVersion soapVersion, string message, Exception innerException) {
     return new SoapException(Res.GetString(Res.WebSuppressedExceptionMessage), 
         soapVersion == SoapProtocolVersion.Soap12 
         ? new XmlQualifiedName(Soap12.Code.Receiver, Soap12.Namespace) 
         : new XmlQualifiedName(Soap.Code.Server, Soap.Namespace));
 }
        /*
        #if DEBUG
        private static void CopyStream(Stream source, Stream dest) {
            byte[] bytes = new byte[1024];
            int numRead = 0;
            while ((numRead = source.Read(bytes, 0, 1024)) > 0)
                dest.Write(bytes, 0, numRead);
        }
        #endif
        */

        private void SetHelper(SoapServerProtocolHelper helper) {
            this.helper = helper;
            this.version = helper.Version;
            Context.Items[WebService.SoapVersionContextSlot] = helper.Version;
        }
Example #22
0
 internal XmlSpecialTextWriter(TextWriter w, SoapProtocolVersion version) : base(w)
 {
     Version = version; // set property
 }
        /// <summary>
        /// Verify underlying transport protocol related requirements. These requirements can be captured directly
        /// when the server returns a SOAP response successfully, which includes web service output message and soap fault.
        /// </summary>
        private void VerifyTransportRelatedRequirments()
        {
            TransportType transportType = Common.Common.GetConfigurationPropertyValue <TransportType>("TransportType", this.Site);

            // As SOAP response successfully returned, the following requirements can be captured directly
            switch (transportType)
            {
            case TransportType.HTTP:
                // Transport soap over HTTP
                // Verify MS-OFFICIALFILE requirement: MS-OFFICIALFILE_R1
                Site.CaptureRequirement(
                    "MS-OFFICIALFILE",
                    1,
                    @"[In Transport] Protocol servers MUST support SOAP over HTTP.");
                break;

            case TransportType.HTTPS:
                if (Common.Common.IsRequirementEnabled(301, this.Site))
                {
                    // Having received the response successfully has proved the HTTPS transport is supported.
                    // Verify MS-OFFICIALFILE requirement: MS-OFFICIALFILE_R301
                    Site.CaptureRequirement(
                        301,
                        @"[In Appendix C: Product Behavior] Implementation does additionally support SOAP over HTTPS for securing communication with protocol clients. (Microsoft Office SharePoint Server 2007 and above products follow this behavior.)");
                }
                else
                {
                    this.Site.Assume.Inconclusive("Implementation does not additionally support SOAP over HTTPS for securing communication with protocol clients.");
                }

                break;

            default:
                Site.Assert.Fail("Transport can only either HTTP or HTTPS.");
                break;
            }

            SoapProtocolVersion soapVersion = Common.Common.GetConfigurationPropertyValue <SoapProtocolVersion>("SoapVersion", this.Site);

            // Add the log information for current SoapVersion.
            Site.Log.Add(Microsoft.Protocols.TestTools.LogEntryKind.Comment, "Current SoapVersion is {0}.", soapVersion.ToString());

            // As the transport is successful, the following requirements can be captured directly.
            if (soapVersion == SoapProtocolVersion.Soap11)
            {
                // Verify MS-OFFICIALFILE requirement: MS-OFFICIALFILE_R6
                Site.CaptureRequirement(
                    "MS-OFFICIALFILE",
                    6,
                    @"[In Transport] Protocol messages MUST be formatted as specified either in [SOAP1.1] (Section 4, SOAP Envelope).");
            }
            else if (soapVersion == SoapProtocolVersion.Soap12)
            {
                // Verify MS-OFFICIALFILE requirement: MS-OFFICIALFILE_R6001
                Site.CaptureRequirement(
                    "MS-OFFICIALFILE",
                    6001,
                    @"[In Transport] Protocol messages MUST be formatted as specified either in [SOAP1.1] (Section 4, SOAP Envelope) or in [SOAP1.2/1] (Section 5, SOAP Message Construct).");
            }
            else
            {
                Site.Assume.Fail("The SOAP type is not recognized.");
            }
        }
Example #24
0
 private void SetHelper(SoapServerProtocolHelper helper)
 {
     this.helper  = helper;
     this.version = helper.Version;
     base.Context.Items[WebService.SoapVersionContextSlot] = helper.Version;
 }
Example #25
0
        internal static void WriteHeaders(XmlWriter writer, XmlSerializer serializer, SoapHeaderCollection headers, SoapHeaderMapping[] mappings, SoapHeaderDirection direction, bool isEncoded, string defaultNs, bool serviceDefaultIsEncoded, string envelopeNs)
        {
            if (headers.Count == 0)
            {
                return;
            }
            if (isEncoded && writer is XmlSpecialTextWriter)
            {
                ((XmlSpecialTextWriter)writer).EncodeIds = true;
            }
            writer.WriteStartElement(Soap.Header, envelopeNs);
            // SOAP12: always soap 1.1, not using encodingStyle;
            //SoapProtocolVersion version;
            SoapProtocolVersion version = SoapProtocolVersion.Soap11;
            // SOAP12: not using encodingStyle

            /*string encodingStyle;
             * if (envelopeNs == Soap12.Namespace) {
             *  version = SoapProtocolVersion.Soap12;
             *  encodingStyle = Soap12.Encoding;
             * }
             * else {
             *  version = SoapProtocolVersion.Soap11;
             *  encodingStyle = Soap.Encoding;
             * }*/

            int       unknownHeaderCount = 0;
            ArrayList otherHeaders       = new ArrayList();

            SoapHeader[] headerArray = new SoapHeader[mappings.Length];
            bool[]       headerSet   = new bool[headerArray.Length];
            for (int i = 0; i < headers.Count; i++)
            {
                SoapHeader header = headers[i];
                if (header == null)
                {
                    continue;
                }
                int headerPosition;
                header.version = version;
                if (header is SoapUnknownHeader)
                {
                    otherHeaders.Add(header);
                    unknownHeaderCount++;
                }
                else if ((headerPosition = FindMapping(mappings, header, direction)) >= 0 && !headerSet[headerPosition])
                {
                    headerArray[headerPosition] = header;
                    headerSet[headerPosition]   = true;
                }
                else
                {
                    otherHeaders.Add(header);
                }
            }
            int otherHeaderCount = otherHeaders.Count - unknownHeaderCount;

            if (isEncoded && otherHeaderCount > 0)
            {
                SoapHeader[] newHeaderArray = new SoapHeader[mappings.Length + otherHeaderCount];
                headerArray.CopyTo(newHeaderArray, 0);

                // fill in the non-statically known headers (otherHeaders) starting after the statically-known ones
                int count = mappings.Length;
                for (int i = 0; i < otherHeaders.Count; i++)
                {
                    if (!(otherHeaders[i] is SoapUnknownHeader))
                    {
                        newHeaderArray[count++] = (SoapHeader)otherHeaders[i];
                    }
                }

                headerArray = newHeaderArray;
            }

            // SOAP12: not using encodingStyle
            //serializer.Serialize(writer, headerArray, null, isEncoded ? encodingStyle : null);
            serializer.Serialize(writer, headerArray, null);

            foreach (SoapHeader header in otherHeaders)
            {
                if (header is SoapUnknownHeader)
                {
                    SoapUnknownHeader unknown = (SoapUnknownHeader)header;
                    if (unknown.Element != null)
                    {
                        unknown.Element.WriteTo(writer);
                    }
                }
                else if (!isEncoded)   // encoded headers already appended to members mapping
                {
                    string ns = SoapReflector.GetLiteralNamespace(defaultNs, serviceDefaultIsEncoded);
                    new XmlSerializer(header.GetType(), ns).Serialize(writer, header);
                }
            }

            // reset the soap version
            for (int i = 0; i < headers.Count; i++)
            {
                SoapHeader header = headers[i];
                if (header != null)
                {
                    header.version = SoapProtocolVersion.Default;
                }
            }

            writer.WriteEndElement();
            writer.Flush();

            if (isEncoded && writer is XmlSpecialTextWriter)
            {
                ((XmlSpecialTextWriter)writer).EncodeIds = false;
            }
        }
 internal void SetSoapVersion(SoapProtocolVersion value)
 {
     soapVersion = value;
 }
Example #27
0
 /// <summary>
 /// This getter returns the resource location of the soap schemas
 /// </summary>
 /// <param name="version">
 /// The Soap version
 /// </param>
 /// <returns>
 /// The resource location
 /// </returns>
 public static string GetSoapXsdLocation(SoapProtocolVersion version)
 {
     switch (version)
     {
         case SoapProtocolVersion.Soap11:
             return Soap11Location;
         default:
             return Soap12Location;
     }
 }
        /// <summary>
        /// Verify the requirements related to SOAP version.
        /// </summary>
        /// <param name="soapVersion">The soap protocol version.</param>
        private void VerifySOAPVersion(SoapProtocolVersion soapVersion)
        {
            if (soapVersion == SoapProtocolVersion.Soap11)
            {
                // Add the debug information
                Site.Log.Add(LogEntryKind.Debug, "Verify MS-VERSS_R701");

                // Verify MS-VERSS requirement: MS-VERSS_R701
                // According to the implementation of adapter, the message is formatted as SOAP1.1.
                // If this operation is invoked successfully, then this requirement can be verified.
                Site.CaptureRequirement(
                    701,
                    @"[In Transport] Protocol messages can be formatted as specified in [SOAP1.1] section 4.");
            }

            if (soapVersion == SoapProtocolVersion.Soap12)
            {
                // Add the debug information
                Site.Log.Add(LogEntryKind.Debug, "Verify MS-VERSS_R702");

                // Verify MS-VERSS requirement: MS-VERSS_R702
                // According to the implementation of adapter, the message is formatted as SOAP1.2.
                // If this operation is invoked successfully, then this requirement can be verified.
                Site.CaptureRequirement(
                    702,
                    @"[In Transport] Protocol messages can be formatted as specified in [SOAP1.2/1] section 5.");
            }
        }