Задать вопрос
tentrun
@tentrun
Fullstack (asp.net /react, vue, angular) deletant

Не видит заголовок SOAP?

Всем привет. Пришлось первый раз использовать soap.
В soap ui запрос проходит.

Пример запроса

<?xml version="1.0" encoding="UTF-8"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
   <s:Header>
      <Security xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
         <wsse:UsernameToken xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
            <wsse:Username>ad</wsse:Username>
            <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest">V9ryhODmkSb+YH+RrugFn0Fe1Zc=</wsse:Password>
            <wsse:Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">Uflrhc5221IfwxXTJrUgluSyksvq7nyFOfPMEbdY8UJ80kqoK1UxZfpFHfoTszg3oDCHpX+zmYZaJ/vuXrAm1g==</wsse:Nonce>
            <wsu:Created>2016-06-29T21:07:59Z</wsu:Created>
         </wsse:UsernameToken>
      </Security>
   </s:Header>
   <s:Body xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
      <getById xmlns="...">
         <id xmlns="">777</id>
      </getById>
   </s:Body>
</s:Envelope>


Вроде понятно, сделал модель запроса
Модель

[XmlRoot(ElementName = "UsernameToken")]
public class UsernameToken
{

    [XmlElement(ElementName = "Username")]
    public string Username { get; set; }

    [XmlElement(ElementName = "Password")]
    public Password Password { get; set; }

    [XmlElement(ElementName = "Nonce")]
    public Nonce Nonce { get; set; }

    [XmlElement(ElementName = "Created")]
    public DateTime Created { get; set; }

    [XmlAttribute(AttributeName = "wsse")]
    public string Wsse { get; set; }

    [XmlAttribute(AttributeName = "wsu")]
    public string Wsu { get; set; }

    [XmlText]
    public string Text { get; set; }
}

[XmlRoot(ElementName = "Security")]
public class Security
{

    [XmlElement(ElementName = "UsernameToken")]
    public UsernameToken UsernameToken { get; set; }

    [XmlAttribute(AttributeName = "xmlns")]
    public string Xmlns { get; set; }
 
    [XmlText]
    public string Text { get; set; }
}

[XmlRoot(ElementName = "Header")]
public class Header
{

    [XmlElement(ElementName = "Security")]
    public Security Security { get; set; }
}

[XmlRoot(ElementName = "Password")]
public class Password
{

    [XmlAttribute(AttributeName = "Type")]
    public string Type { get; set; }

    [XmlText]
    public string Text { get; set; }
}

[XmlRoot(ElementName = "Nonce")]
public class Nonce
{

    [XmlAttribute(AttributeName = "EncodingType")]
    public string EncodingType { get; set; }

    [XmlText]
    public string Text { get; set; }
}

public class GetUpdatesRequest : getUpdates
{
    [XmlAttribute(AttributeName = "Header")]
    public ReqLogin _reqLogin { get; set; }
}



Сам запрос

var request = new GetUpdatesRequest
        {
            from = DateTime.Now,
            _reqLogin = new ReqLogin
            {
                UserName = "UserTestSOAP",
                Password = "testPassword1231123",
                Nonce = "Uflrhc5221IfwxXTJrUgluSyksvq7nyFOfPMEbdY8UJ80kqoK1UxZfpFHfoTszg3oDCHpX",
                Created = DateTimeOffset.Now
            },
            
        };
        var result = await _service.getUpdatesAsync(request).ConfigureAwait(false);



И в итоге ловлю FaultException
Exception
System.ServiceModel.FaultException: An error was discovered processing the <wsse:Security> header
   at System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc& rpc)
   at System.ServiceModel.Channels.ServiceChannel.EndCall(String action, Object[] outs, IAsyncResult result)
   at System.ServiceModel.Channels.ServiceChannelProxy.TaskCreator.<>c__DisplayClass1_0.<CreateGenericTask>b__0(IAsyncResult asyncResult)
--- End of stack trace from previous location ---


В чем причина? Что я делаю не так?
  • Вопрос задан
  • 53 просмотра
Подписаться 1 Простой 6 комментариев
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Похожие вопросы