M
M
MagDarkElf2020-01-28 12:35:56
SOAP
MagDarkElf, 2020-01-28 12:35:56

Can't get body of soap message?

There is an incoming Soap message of the form

<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>


This is the object into which the data from the Soap message should be pushed.
[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;
}


The message header (MessageHeader) is shoved normally, and openIncidentsResponse = null
The problem is in the ns2 prefix, if you remove it, everything works fine
I don’t understand how to make it work with the prefix as well

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir Korotenko, 2020-01-28
@firedragon

Why not get the code after auto-generation and adapt it after?
In addition, there is a soapclient in the sdk, it will give you a working proxy

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question