Hi,
First time posting here.
Recently our app has been connected via API/SOAP with WSDL (Servicestack.Service) to a customer that makes lots of requests (for us at least 50k/hour) to our API.
Since then, we’ve started getting an error trying to deserialize the XML they send. This is ServiceStack 5.4.0, under NET4.7.1
I tried the same request using a simple load testing app and above 10 simultaneous requests, I see the same error.
What I’m not sure is, if it’s a NET issue, a ServiceStack issue, a configuration issue.
This is the trace for the error:
{"ClassName":"System.Runtime.Serialization.SerializationException","Message":"Could not deserialize 'application/xml' request using te_webservices.hotels_search_v2'\nError: System.Runtime.Serialization.SerializationException: There was an error deserializing the object of type te_webservices.hotels_search_v2. Start element 'hotels_search_v2' does not match end element 'hotels_search_vX-'. Line 1, position 200. ---> System.Xml.XmlException: Start element 'hotels_search_v2' does not match end element 'hotels_search_vX-'. Line 1, position 200.\r\n at System.Xml.XmlExceptionHelper.ThrowXmlException(XmlDictionaryReader reader, String res, String arg1, String arg2, String arg3)\r\n at System.Xml.XmlUTF8TextReader.ReadEndElement()\r\n at System.Xml.XmlUTF8TextReader.Read()\r\n at System.Runtime.Serialization.CollectionDataContract.ReadXmlValue(XmlReaderDelegator xmlReader, XmlObjectSerializerReadContext context)\r\n at System.Runtime.Serialization.XmlObjectSerializerReadContext.InternalDeserialize(XmlReaderDelegator reader, String name, String ns, Type declaredType, DataContract& dataContract)\r\n at System.Runtime.Serialization.XmlObjectSerializerReadContext.InternalDeserialize(XmlReaderDelegator xmlReader, Int32 id, RuntimeTypeHandle declaredTypeHandle, String name, String ns)\r\n at Readhotels_search_v2FromXml(XmlReaderDelegator , XmlObjectSerializerReadContext , XmlDictionaryString[] , XmlDictionaryString[] )\r\n at System.Runtime.Serialization.ClassDataContract.ReadXmlValue(XmlReaderDelegator xmlReader, XmlObjectSerializerReadContext context)\r\n at System.Runtime.Serialization.XmlObjectSerializerReadContext.InternalDeserialize(XmlReaderDelegator reader, String name, String ns, Type declaredType, DataContract& dataContract)\r\n at System.Runtime.Serialization.XmlObjectSerializerReadContext.InternalDeserialize(XmlReaderDelegator xmlReader, Type declaredType, DataContract dataContract, String name, String ns)\r\n at System.Runtime.Serialization.DataContractSerializer.InternalReadObject(XmlReaderDelegator xmlReader, Boolean verifyObjectName, DataContractResolver dataContractResolver)\r\n at System.Runtime.Serialization.XmlObjectSerializer.ReadObjectHandleExceptions(XmlReaderDelegator reader, Boolean verifyObjectName, DataContractResolver dataContractResolver)\r\n --- End of inner exception stack trace ---\r\n at System.Runtime.Serialization.XmlObjectSerializer.ReadObjectHandleExceptions(XmlReaderDelegator reader, Boolean verifyObjectName, DataContractResolver dataContractResolver)\r\n at System.Runtime.Serialization.XmlObjectSerializer.ReadObject(XmlDictionaryReader reader)\r\n at ServiceStack.Host.ContentTypes.<>c__DisplayClass35_0.<GetStreamDeserializerAsync>b__0(Type type, Stream stream)\r\n at ServiceStack.Host.Handlers.ServiceStackHandlerBase.CreateContentTypeRequestAsync(IRequest httpReq, Type requestType, String contentType)","Data":null,"InnerException":{"ClassName":"System.Runtime.Serialization.SerializationException","Message":"There was an error deserializing the object of type te_webservices.hotels_search_v2. Start element 'hotels_search_v2' does not match end element 'hotels_search_vX-'. Line 1, position 200.","Data":null,"InnerException":{"ClassName":"System.Xml.XmlException","Message":"Start element 'hotels_search_v2' does not match end element 'hotels_search_vX-'. Line 1, position 200.","Data":null,"InnerException":null,"HelpURL":null,"StackTraceString":" at System.Xml.XmlExceptionHelper.ThrowXmlException(XmlDictionaryReader reader, String res, String arg1, String arg2, String arg3)\r\n at System.Xml.XmlUTF8TextReader.ReadEndElement()\r\n at System.Xml.XmlUTF8TextReader.Read()\r\n at System.Runtime.Serialization.CollectionDataContract.ReadXmlValue(XmlReaderDelegator xmlReader, XmlObjectSerializerReadContext context)\r\n at System.Runtime.Serialization.XmlObjectSerializerReadContext.InternalDeserialize(XmlReaderDelegator reader, String name, String ns, Type declaredType, DataContract& dataContract)\r\n at System.Runtime.Serialization.XmlObjectSerializerReadContext.InternalDeserialize(XmlReaderDelegator xmlReader, Int32 id, RuntimeTypeHandle declaredTypeHandle, String name, String ns)\r\n at Readhotels_search_v2FromXml(XmlReaderDelegator , XmlObjectSerializerReadContext , XmlDictionaryString[] , XmlDictionaryString[] )\r\n at System.Runtime.Serialization.ClassDataContract.ReadXmlValue(XmlReaderDelegator xmlReader, XmlObjectSerializerReadContext context)\r\n at System.Runtime.Serialization.XmlObjectSerializerReadContext.InternalDeserialize(XmlReaderDelegator reader, String name, String ns, Type declaredType, DataContract& dataContract)\r\n at System.Runtime.Serialization.XmlObjectSerializerReadContext.InternalDeserialize(XmlReaderDelegator xmlReader, Type declaredType, DataContract dataContract, String name, String ns)\r\n at System.Runtime.Serialization.DataContractSerializer.InternalReadObject(XmlReaderDelegator xmlReader, Boolean verifyObjectName, DataContractResolver dataContractResolver)\r\n at System.Runtime.Serialization.XmlObjectSerializer.ReadObjectHandleExceptions(XmlReaderDelegator reader, Boolean verifyObjectName, DataContractResolver dataContractResolver)","RemoteStackTraceString":null,"RemoteStackIndex":0,"ExceptionMethod":"8\nThrowXmlException\nSystem.Runtime.Serialization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089\nSystem.Xml.XmlExceptionHelper\nVoid ThrowXmlException(System.Xml.XmlDictionaryReader, System.String, System.String, System.String, System.String)","HResult":-2146232000,"Source":"System.Runtime.Serialization","WatsonBuckets":null,"res":"Xml_UserException","args":["Start element 'hotels_search_v2' does not match end element 'hotels_search_vX-'. Line 1, position 200."],"lineNumber":0,"linePosition":0,"sourceUri":null,"version":"2.0"},"HelpURL":null,"StackTraceString":" at System.Runtime.Serialization.XmlObjectSerializer.ReadObjectHandleExceptions(XmlReaderDelegator reader, Boolean verifyObjectName, DataContractResolver dataContractResolver)\r\n at System.Runtime.Serialization.XmlObjectSerializer.ReadObject(XmlDictionaryReader reader)\r\n at ServiceStack.Host.ContentTypes.<>c__DisplayClass35_0.<GetStreamDeserializerAsync>b__0(Type type, Stream stream)\r\n at ServiceStack.Host.Handlers.ServiceStackHandlerBase.CreateContentTypeRequestAsync(IRequest httpReq, Type requestType, String contentType)","RemoteStackTraceString":null,"RemoteStackIndex":0,"ExceptionMethod":"8\nReadObjectHandleExceptions\nSystem.Runtime.Serialization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089\nSystem.Runtime.Serialization.XmlObjectSerializer\nSystem.Object ReadObjectHandleExceptions(System.Runtime.Serialization.XmlReaderDelegator, Boolean, System.Runtime.Serialization.DataContractResolver)","HResult":-2146233076,"Source":"System.Runtime.Serialization","WatsonBuckets":null},"HelpURL":null,"StackTraceString":" at ServiceStack.Host.Handlers.ServiceStackHandlerBase.CreateContentTypeRequestAsync(IRequest httpReq, Type requestType, String contentType)\r\n at ServiceStack.Host.RestHandler.<CreateRequestAsync>d__16.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at ServiceStack.Host.RestHandler.<CreateRequestAsync>d__15.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at ServiceStack.Host.RestHandler.<ProcessRequestAsync>d__14.MoveNext()","RemoteStackTraceString":null,"RemoteStackIndex":0,"ExceptionMethod":"8\nCreateContentTypeRequestAsync\nServiceStack, Version=5.0.0.0, Culture=neutral, PublicKeyToken=02c12cbda47e6587\nServiceStack.Host.Handlers.ServiceStackHandlerBase\nSystem.Threading.Tasks.Task`1[System.Object] CreateContentTypeRequestAsync(ServiceStack.Web.IRequest, System.Type, System.String)","HResult":-2146233076,"Source":"ServiceStack","WatsonBuckets":null}
What confuses me the most, is the error we get: Start element ‘hotels_search_v2’ does not match end element ‘hotels_search_vX-’,
The XML that’s sent is the following:
<?xml version="1.0" encoding="utf-8"?><hotels_search_v2 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.datacontract.org/2004/07/te_webservices"><timeoutMilliseconds>0</timeoutMilliseconds><optionsQuota>0</optionsQuota><checkin_date>2019-04-06</checkin_date><checkout_date>2019-04-07</checkout_date><destination_id>MzM%3D_MjM0MTQ%3D</destination_id><destination_type>4</destination_type><nationality_code>US</nationality_code><rooms><hotels_search_room_v2><adults>2</adults><children>0</children></hotels_search_room_v2></rooms></hotels_search_v2>
So, there is no ‘hotels_search_vX-’.
This is how the service is configured:
Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture("en-US");
Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-US");
ServiceStack.Text.JsConfig.EmitCamelCaseNames = false;
ServiceStack.Text.JsConfig.DateHandler = ServiceStack.Text.DateHandler.ISO8601;
Plugins.Add(new CorsFeature(
allowOriginWhitelist: new List<string>() { "http://localhost:2093", "http://localhost:3000" },
allowCredentials: true,
allowedHeaders: "Content-Type, Allow, Authorization, ss-id, Origin, Accept, Access-Control-Request-Method"
));
container.Register<IRedisClientsManager>(c =>new RedisManagerPool(travtion.generic.setting.api.redis_cache_connection_string));
container.Register(c => c.Resolve<IRedisClientsManager>().GetCacheClient());
// solo requestlog y postman en desarrollo
if (travtion.generic.setting.system.is_debug)
{
Plugins.Add(new PostmanFeature());
Plugins.Add(new RequestLogsFeature
{
EnableSessionTracking = true,
RequiredRoles = null,
});
}
//this.GetPlugin<PostmanFeature>();
SetConfig(new HostConfig
{
WsdlServiceNamespace = "http://api.travtion.com/v1",
DefaultContentType = MimeTypes.Json,
HandlerFactoryPath = "/api"
});
Plugins.Add(new SoapFormat());
SuppressFormsAuthenticationRedirectModule.PathToSupress = Config.HandlerFactoryPath;
//Handle Exceptions occurring in Services:
ServiceExceptionHandlers.Add((httpReq, request, exception) =>
{
//log your exceptions here
travtion.generic.function.logging_engine.log_errors(exception);
//call default exception handler or prepare your own custom response
return DtoUtils.CreateErrorResponse(request, exception);
});
//Handle Unhandled Exceptions occurring outside of Services
//E.g. Exceptions during Request binding or in filters:
UncaughtExceptionHandlers.Add((req, res, operationName, ex) =>
{
travtion.generic.function.logging_engine.log_errors(ex);
res.WriteAsync("Error: {0}: {1}".Fmt(ex.GetType().Name, ex.Message));
res.EndRequest(skipHeaders: true);
});
AuthFeature authFeature = new AuthFeature(() => new AuthUserSession(), new IAuthProvider[] { new api_authprovider(), new api_authprovider_basic() }, null);
authFeature.IncludeAssignRoleServices = false;
authFeature.HtmlRedirect = null;
Plugins.Add(authFeature);
container.Register<ICacheClient>(c =>
(ICacheClient)c.Resolve<IRedisClientsManager>()
.GetCacheClient())
.ReusedWithin(Funq.ReuseScope.None);
Any help will be greatly appreciated.
Regards!