Esempio n. 1
0
        public object ExecuteText(string operationName, string requestXml, Type requestType, IRequestContext requestContext)
        {
            var          request = WrappedXmlSerializer.DeserializeFromString(requestXml, requestType);
            IHttpRequest httpReq = requestContext.Get <IHttpRequest>();

            if (httpReq != null)
            {
                httpReq.RequestObject = request;
            }
            var response    = Execute(operationName, request, requestContext);
            var responseXml = WrappedXmlSerializer.SerializeToString(response, false);

            return(responseXml);
        }
Esempio n. 2
0
        public object GetRequest(IHttpRequest httpReq, string operationName)
        {
            var requestType = GetRequestType(operationName, httpReq.ServicePath);

            AssertOperationExists(operationName, requestType);

            if (httpReq.ContentLength <= 0)
            {
                throw new ArgumentNullException("Missing request body");
            }

            try
            {
                // Deserialize to soap11 envelope
                var soap11Envelope = WrappedXmlSerializer.DeserializeFromStream <Envelope>(httpReq.InputStream);

                // check existence of the request xml element
                if (soap11Envelope != null && soap11Envelope.Body != null && soap11Envelope.Body.Any.Count > 0)
                {
                    // Get request xml element
                    var requestXmlElement = soap11Envelope.Body.Any[0];
                    if (requestXmlElement != null)
                    {
                        // Get request xml
                        var requestXml = requestXmlElement.OuterXml;
                        if (!string.IsNullOrEmpty(requestXml))
                        {
                            // Deserialize to object of request type
                            return(WrappedXmlSerializer.DeserializeFromString(requestXml, requestType));
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                var msg = "Could not deserialize soap11 request into instance of {0}'\nError: {1}"
                          .Fmt(requestType, ex);
                throw new SerializationException(msg);
            }


            throw new ArgumentNullException("Invalid soap11 request message");
        }
        public object DeserializeFromString(string contentType, Type type, string request)
        {
            var contentTypeAttr = ContentType.GetEndpointAttributes(contentType);

            switch (contentTypeAttr)
            {
            case EndpointAttributes.Xml:
                return(WrappedXmlSerializer.DeserializeFromString(request, type));

            case EndpointAttributes.Json:
                return(WrappedJsonDeserializer.Instance.DeserializeFromString(request, type));

            case EndpointAttributes.Jsv:
                return(TypeSerializer.DeserializeFromString(request, type));

            default:
                throw new NotSupportedException("ContentType not supported: " + contentType);
            }
        }