M
M
MagDarkElf2020-01-28 17:26:23
SOAP
MagDarkElf, 2020-01-28 17:26:23

Why doesn't MessageContract accept prefixed values?

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
   <SOAP-ENV:Header xmlns:wsa="http://www.w3.org/2005/08/addressing">
      <wsa:To>[email protected]</wsa:To>
      <wsa:From>
         <wsa:Address>[email protected]</wsa:Address>
      </wsa:From>
      <wsa:MessageID>urn:uuid:330ee93a-8a42-4ac7-bbfa-fa9636e8d75c</wsa:MessageID>
      <wsa:RelatesTo>urn:uuid:1c4d8d00-9dce-43dc-aacd-61f20d9e98d6</wsa:RelatesTo>
      <wsa:Action>sm://messages/application/some/response</wsa:Action>
   </SOAP-ENV:Header>
   <SOAP-ENV:Body>
      <openIncidentsResponse xmlns:ns2="http://www..ru/sc/schema/pm">
         <ns2:OpenIncidentsCount>1</ns2:OpenIncidentsCount>
         <ns2:UserId>a6275872-74f3-4bf2-bd17-3147ca4ad9a2</ns2:UserId>
         <ns2:LastDate>2020-01-27T11:51:07.3516144+03:00</ns2:LastDate>
      </openIncidentsResponse>
   </SOAP-ENV:Body>
</SOAP-ENV:Envelope>


Soap message is not serialized due to ns2 prefix
[MessageContract(IsWrapped = false)]
public partial class OpenIncidentsResponseMessage
{
  protected static string prefix = "urn:uuid:";

  [XmlIgnore]
  public Guid MessageId
  {
    get
    {
      String cut;
      if (MessageIdSer.StartsWith(prefix, true, CultureInfo.InvariantCulture))
      {
        cut = MessageIdSer.Substring(prefix.Length);
      }
      else
      {
        cut = MessageIdSer;
      }
      return Guid.Parse(cut);
    }
    set
    {
      MessageIdSer = prefix + value;
    }
  }

  [MessageHeader(Namespace = "http://www.w3.org/2005/08/addressing", Name = "MessageID")]
  public String MessageIdSer
  {
    get;
    set;
  }

  [MessageHeader(Namespace = "http://www.w3.org/2005/08/addressing")]
  public String To { get; set; }

  [MessageBodyMember(Name = "openIncidentsResponse", Namespace = "http://www..ru/sc/schema/pm", Order = 0)]
  public openIncidentsResponse openIncidentsResponse;
}

public partial class openIncidentsResponse
{
        [MessageBodyMember(Namespace = "http://www..ru/sc/schema/pm", Order = 0)]
        public int OpenIncidentsCount;

        [MessageBodyMember(Namespace = "http://www..ru/sc/schema/pm", Order = 1)]
        public Guid UserId;

        [MessageBodyMember(Namespace = "http://www..ru/sc/schema/pm", Order = 2)]
        public DateTime LastDate;
}

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question