当前位置: 首页 > 编程语言 > C#

soap1.1服务栈序列化异常分享

时间:2023-04-10 11:23:40 C#

soap1.1服务栈序列化异常请求消息:StringStringStringString响应消息/错误:SerializationExceptionCouldnotdeserialize'application/xml'requestusingEServices_Response.SendGetAccountNotification'Error:System.Runtime.Serialization.SerializationException:第1行位置170出错。期望来自命名空间“mynamespace”的元素“SendGetAccountNotification”。遇到名称为“Envelope”、命名空间“http://schemas.xmlsoap”的“Element”。组织/肥皂/信封/'。在System.Runtime.Serialization.DataContractSerializer.InternalReadObject(XmlReaderDelegatorxmlReader、BooleanverifyObjectName、DataContractResolverdataContractResolver).DeserializeContentType(类型操作类型,IHttpRequesthttpReq,字符串内容类型)在ServiceStack.WebHost.Endpoints.Support.EndpointHandlerBase.DeserializeContentType(类型operationType,IHttpRequesthttpReq,字符串内容类型)在ServiceStack.WebHost.Endpoints.GenericHandler.ProcessRequest(IHttpRequestNamehttpReq,IHtResponseResponse)http服务:[DataContract(Namespace="mynamespace")]publicclassSendGetAccountResponseService:IService{publicobjectExecute(SendGetAccountNotificationrequest){Console.WriteLine("Reached");返回空值;}}问题:好的,所以我一直在挖掘几个小时,我找不到解决方案我将请求XML插入SoapUI,但我收到错误响应。看起来它不喜欢soap信封,并且尝试序列化请求开始忽略信封并将soap主体序列化到模型。我不知道为什么会这样,有没有人知道?我需要在某处添加一些属性吗?任何帮助将不胜感激。解决方案:寻找绿色勾号。通过检查我的端点解决了这个问题,它指向XML端点,所以我收到了错误消息。我按照解决了我的问题的帖子改进了服务。还注意到我有一个旧版本的服务堆栈,所以现在更新了,一切都很顺利。以下是我(简化的)为您服务的尝试。它忽略了“命名空间”,但这里有更多信息。我能够使用SoapUI获得成功的响应。SoapUI设置:端点-http://localhost:1337/soap11请求消息:(从ServiceStack元数据页面复制)String12345StringStringServiceStack代码:帐户类(请求的一部分):[DataContract]publicclassAccount{[DataMember]}[DataMember]publicstringExternalAccountId{get;放;}}请求类[DataContract][Route("/SendGetAccountNotification")]publicclassSendGetAccountNotification{[DataMember]publicAccountAccount{get;放;}[DataMember]publicstringExternalAccountID{get;放;}[DataMember]publicstringMessage{get;得到;放;}[DataMember]publicResponseStatusResponseStatus{get;放;}}ServicepublicclassSendGetAccountResponseService:Service{publicSendGetAccountNotificationResponseAny(SendGetAccountNotificationrequest){Console.WriteLine("Reached");返回新的SendGetAccountNotificationResponse(){Result="SuccessforAccount"+request.Account.ExternalAccountId};我有同样的问题,我不得不修改我不明白为什么的请求,但我不得不删除前缀。试试看:以上就是C#学习教程:soap1.1的服务栈序列化异常的全部内容。如果对你有用,需要了解更多C#学习教程,希望大家多多关注——网络收藏不代表立场,如涉及侵权,请点击右边联系管理员删除。如需转载请注明出处:

最新推荐
猜你喜欢