This request works just fine, Id is an integer, it gets deserialized fine.
Now I want to test a malformed request, so instead of 1, I specify a non-valid integer value:
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:typ="http://schemas.servicestack.net/types">
<soap:Header/>
<soap:Body>
<typ:LisServiceDTO>
<!--Optional:-->
<typ:Id>this is not an integer</typ:Id>
</typ:LisServiceDTO>
</soap:Body>
</soap:Envelope>
Testing this request with SOAP UI gives timeout. It seems that the request does not get terminated correctly by ServiceStack. Using SOAP 1.1 yields the same result.
I verified that the ProcessRequestContext gets called.
Also I don’t get any errors in the logger.
I’m using ServiceStack 5.4.1.
EDIT: note that if I call the method using REST, that works, in both cases. It works correctly when I pass Id as integer, and throws me an error when I pass a string. The only case that does not work is the malformed SOAP request.
Please provide the full HTTP Request/Response Headers.
Note the SOAP support only supports requests from the built-in Soap11ServiceClient, Soap12ServiceClient .NET Service Clients and WCF’s Add Service Reference feature.
var responseXml = ServiceClientBaseUri.CombineWith("/soap12")
.PostToUrl(soap, requestFilter: req => req.ContentType = "application/soap+xml; charset=utf-8");
var doc = new XmlDocument();
doc.LoadXml(responseXml);
var responseMsg = Message.CreateMessage(new XmlNodeReader(doc), int.MaxValue,
MessageVersion.Soap12WSAddressingAugust2004);
using (var reader = responseMsg.GetReaderAtBodyContents())
{
var bodyXml = reader.ReadOuterXml();
var responseType = typeof(AddIntsResponse);
var response = (AddIntsResponse)DataContractSerializer.Instance
.DeserializeFromString(bodyXml, responseType);
response.ResponseStatus.ErrorCode //= SerializationException
response.ResponseStatus.Message //= Error trying to deserialize requestType...
}
Using DTOs + Service:
[assembly: ContractNamespace("http://schemas.servicestack.net/types",
ClrNamespace = "Your.ServiceModel.Namespace")] // in AssemblyInfo.cs
[DataContract]
public class AddInts : IReturn<AddIntsResponse>
{
[DataMember]
public int A { get; set; }
[DataMember]
public int B { get; set; }
}
[DataContract]
public class AddIntsResponse
{
[DataMember]
public int Result { get; set; }
[DataMember]
public ResponseStatus ResponseStatus { get; set; }
}
public class MyServices : Service
{
public object Any(AddInts request) => new AddIntsResponse {
Result = request.A + request.B
};
}