soap 1.1的服务堆栈序列化例外

请求消息:

     String String  String String     

响应消息/错误:

   SerializationException Could not deserialize 'application/xml' request using EServices_Response.SendGetAccountNotification' Error: System.Runtime.Serialization.SerializationException: Error in line 1 position 170. Expecting element 'SendGetAccountNotification' from namespace 'mynamespace'.. Encountered 'Element' with name 'Envelope', namespace 'http://schemas.xmlsoap.org/soap/envelope/'. at System.Runtime.Serialization.DataContractSerializer.InternalReadObject(XmlReaderDelegator xmlReader, Boolean verifyObjectName, DataContractResolver dataContractResolver) at System.Runtime.Serialization.XmlObjectSerializer.ReadObjectHandleExceptions(XmlReaderDelegator reader, Boolean verifyObjectName, DataContractResolver dataContractResolver) at ServiceStack.WebHost.Endpoints.Support.EndpointHandlerBase.DeserializeContentType(Type operationType, IHttpRequest httpReq, String contentType) at ServiceStack.WebHost.Endpoints.Support.EndpointHandlerBase.DeserializeContentType(Type operationType, IHttpRequest httpReq, String contentType) at ServiceStack.WebHost.Endpoints.GenericHandler.ProcessRequest(IHttpRequest httpReq, IHttpResponse httpRes, String operationName)   

C#服务:

 [DataContract(Namespace = "mynamespace")] public class SendGetAccountResponseService : IService { public object Execute (SendGetAccountNotification request) { Console.WriteLine ("Reached"); return null; } } 

题:

好的,所以我一直在挖掘几个小时,我找不到解决方案。 我将请求XML插入到Soap UI中,我得到了错误响应。 看起来它不喜欢肥皂信封,并试图序列化请求开始不考虑忽略信封和序列化肥皂体到模型。 我不知道为什么会这样,其他人都知道吗? 我是否需要在某个地方添加一些属性? 任何帮助将不胜感激。

解:

寻找绿色的勾选。 通过检查我的端点解决了这个问题,它指向了XML端点,因此我收到了该错误消息。 我通过关注解决了我的问题的post改进了服务。 还注意到我有一个旧版本的服务堆栈,所以现在更新,所有工作就像一个魅力。

以下是我(简化)您的服务尝试。 它忽略了’命名空间’,但这里有更多信息 。 我能够使用Soap UI获得成功的响应。

SoapUI设置:

端点http://localhost:1337/soap11

请求消息:(从ServiceStack元数据页面复制)

     String 12345  String String    

ServiceStack代码:

帐户类(请求的一部分):

 [DataContract] public class Account { [DataMember] public string BusOpsDesc { get; set; } [DataMember] public string ExternalAccountId { get; set; } } 

请求类

 [DataContract] [Route("/SendGetAccountNotification")] public class SendGetAccountNotification { [DataMember] public Account Account { get; set; } [DataMember] public string ExternalAccountID { get; set; } [DataMember] public string Message { get; set; } } 

具有匹配命名约定的响应类

 [DataContract] public class SendGetAccountNotificationResponse : IHasResponseStatus { [DataMember] public String Result { get; set; } [DataMember] public ResponseStatus ResponseStatus { get; set; } } 

服务

 public class SendGetAccountResponseService : Service { public SendGetAccountNotificationResponse Any(SendGetAccountNotification request) { Console.WriteLine("Reached"); return new SendGetAccountNotificationResponse() {Result = "Success for Account " + request.Account.ExternalAccountId}; } } 

我有同样的问题,我不得不修改请求。 我不明白为什么,但我不得不删除前缀。 试试这个:

      String String  String String