Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/301.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# soap 1.1的服务堆栈序列化异常_C#_Serialization_Soap_<img Src="//i.stack.imgur.com/WM7S8.png" Height="16" Width="18" Alt="" Class="sponsor Tag Img">servicestack_Soapui - Fatal编程技术网 servicestack,soapui,C#,Serialization,Soap,servicestack,Soapui" /> servicestack,soapui,C#,Serialization,Soap,servicestack,Soapui" />

C# soap 1.1的服务堆栈序列化异常

C# soap 1.1的服务堆栈序列化异常,c#,serialization,soap,servicestack,soapui,C#,Serialization,Soap,servicestack,Soapui,请求消息: <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Body> <SendGetAccountNotification xmlns:i="http://w

请求消息:

<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
  <SendGetAccountNotification xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="mynamespace">
     <getAccountResponse xmlns:d2p1="mynamespace">
        <d2p1:Account>
           <d2p1:BusOpsDesc>String</d2p1:BusOpsDesc>
           <d2p1:ExternalAccountID>String</d2p1:ExternalAccountID>
        </d2p1:Account>
        <d2p1:ExternalAccountID>String</d2p1:ExternalAccountID>
        <d2p1:Message>String</d2p1:Message>
     </getAccountResponse>
  </SendGetAccountNotification>
</soap:Body>
</soap:Envelope>

一串
一串
一串
一串
响应消息/错误:

<SendGetAccountNotificationResponse xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="mynamespace">
   <ResponseStatus>
      <ErrorCode>SerializationException</ErrorCode>
      <Message>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)</Message>
      <StackTrace>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)</StackTrace>
   </ResponseStatus>
</SendGetAccountNotificationResponse>

序列化异常
无法使用EServices\u响应反序列化“application/xml”请求。SendGetAccountNotification'
错误:System.Runtime.Serialization.SerializationException:第1行位置170处出错。应为命名空间“mynamespace”中的元素“SendGetAccountNotification”。。遇到名称为“信封”的“元素”,命名空间为http://schemas.xmlsoap.org/soap/envelope/'. 
在System.Runtime.Serialization.DataContractSerializer.InternalReadObject(XmlReaderDelegator xmlReader,布尔verifyObjectName,DataContractResolver DataContractResolver)
在System.Runtime.Serialization.XmlObjectSerializer.ReadObjectHandleExceptions(XmlReaderDelegator读取器、布尔verifyObjectName、DataContractResolver DataContractResolver)
位于ServiceStack.WebHost.Endpoints.Support.EndpointHandlerBase.DeserializeContentType(类型operationType,IHttpRequest httpReq,字符串contentType)
位于ServiceStack.WebHost.Endpoints.Support.EndpointHandlerBase.DeserializeContentType(类型operationType,IHttpRequest httpReq,字符串contentType)
在ServiceStack.WebHost.Endpoints.GenericHandler.ProcessRequest(IHttpRequest httpReq、IHTTPreponse httpRes、String operationName)上
C#服务:

[DataContract(Namespace=“mynamespace”)]
公共类SendGetAccountResponseService:IService
{
公共对象执行(SendGetAccountNotification请求)
{
Console.WriteLine(“到达”);
返回null;
}
}
问题:

好吧,我已经挖了好几个小时了,我找不到解决办法。我将该请求XML插入到Soap UI中,得到了错误响应。它看起来不喜欢soap信封,并且正在尝试序列化请求,开始不考虑忽略信封并将soap主体序列化为模型。我不知道为什么会这样,还有谁知道吗?我是否需要在某处添加一些属性?任何帮助都将不胜感激

解决方案:


寻找绿色的滴答声。通过检查我的端点解决了这个问题,它指向XML端点,因此我得到了错误消息。我按照解决我问题的帖子改进了服务。还注意到我有一个旧版本的service stack,所以现在已经更新了,所有的工作都很顺利。

我遇到了同样的问题,我不得不修改请求。我不能理解为什么,但我不得不删除前缀。 试试这个:

<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
  <SendGetAccountNotification xmlns="http://www.w3.org/2001/XMLSchema-instance" xmlns="mynamespace">
     <getAccountResponse>
        <Account>
           <BusOpsDesc>String</BusOpsDesc>
           <ExternalAccountID>String</ExternalAccountID>
        </Account>
        <ExternalAccountID>String</ExternalAccountID>
        <Message>String</Message>
     </getAccountResponse>
  </SendGetAccountNotification>
</soap:Body>
</soap:Envelope>

一串
一串
一串
一串
以下是我(简化)为您服务的尝试。它忽略了“名称空间”,但没有。我能够使用soapui收到成功的响应

SoapUI设置:

端点-
http://localhost:1337/soap11

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

请求类

[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; }
}
服务

[DataContract]
public class Account
{
    [DataMember]
    public string BusOpsDesc { get; set; }
    [DataMember]
    public string ExternalAccountId { get; set; }
}
public class SendGetAccountResponseService : Service
{
    public SendGetAccountNotificationResponse Any(SendGetAccountNotification request)
    {
        Console.WriteLine("Reached");
        return new SendGetAccountNotificationResponse() {Result = "Success for Account " + request.Account.ExternalAccountId};
    }
}

您正在使用SoapUI生成的请求吗?您没有列出您的请求/响应类,但它似乎不是由SS生成的XML。请参阅此处->我尝试使用SoapUI生成的请求和SS生成的请求脚本,但都失败了。同样的结果
[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};
    }
}